Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions compiler/rustc_codegen_gcc/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
pub fn is_two_register_pair_type(&self, typ: Type<'gcc>) -> bool {
self.two_register_pair_type_set.borrow().contains(&typ)
}

#[cfg_attr(feature = "master", expect(unused_mut))]
pub fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
#[cfg(not(feature = "master"))]
if let Some(struct_type) = ty.is_struct()
&& struct_type.get_field_count() == 0
{
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs.
len = 0;
}

new_array_type(self.context, None, ty, len)
}
}

/// An attribute that can be set on a GCC struct type.
Expand Down Expand Up @@ -411,21 +426,6 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> {
fn val_ty(&self, value: RValue<'gcc>) -> Type<'gcc> {
value.get_type()
}

#[cfg_attr(feature = "master", expect(unused_mut))]
fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
#[cfg(not(feature = "master"))]
if let Some(struct_type) = ty.is_struct()
&& struct_type.get_field_count() == 0
{
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs.
len = 0;
}

new_array_type(self.context, None, ty, len)
}
}

impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
pub(crate) fn type_bf16(&self) -> &'ll Type {
unsafe { llvm::LLVMBFloatTypeInContext(self.llcx()) }
}

pub(crate) fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMArrayType2(ty, len) }
}
}

impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
Expand Down Expand Up @@ -280,10 +284,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
common::val_ty(v)
}

fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMArrayType2(ty, len) }
}
}

pub(crate) fn llvm_type_ptr(llcx: &llvm::Context) -> &Type {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub trait BaseTypeCodegenMethods: BackendTypes {
fn type_f128(&self) -> Self::Type;
fn type_ppcf128(&self) -> Self::Type;

fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::FunctionSignature;
fn type_kind(&self, ty: Self::Type) -> TypeKind;
fn type_ptr(&self) -> Self::Type;
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/num/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ impl TryFromIntError {
/// Outputs the detailed cause of converting an integer failing.
#[must_use]
#[unstable(feature = "try_from_int_error_kind", issue = "153978")]
pub const fn kind(&self) -> &IntErrorKind {
&self.0
pub const fn kind(&self) -> IntErrorKind {
self.0
}
}

Expand Down
8 changes: 4 additions & 4 deletions library/coretests/tests/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ fn test_nonzero_from_int_on_success() {

#[test]
fn test_nonzero_from_int_on_err() {
assert_eq!(NonZero::<u8>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<u32>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<u8>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);
assert_eq!(NonZero::<u32>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);

assert_eq!(NonZero::<i8>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<i32>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<i8>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);
assert_eq!(NonZero::<i32>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);
}

#[test]
Expand Down
25 changes: 11 additions & 14 deletions library/coretests/tests/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,14 @@ macro_rules! test_impl_try_from_integer_to_bool {
let zero: $source = 0;
let one: $source = 1;
let two: $source = 2;
assert_eq!(bool::try_from(max).unwrap_err().kind(), &IntErrorKind::PosOverflow);
assert_eq!(bool::try_from(max).unwrap_err().kind(), IntErrorKind::PosOverflow);
if min != 0 {
assert_eq!(bool::try_from(min).unwrap_err().kind(), &IntErrorKind::NegOverflow);
assert_eq!(
bool::try_from(zero - 1).unwrap_err().kind(),
&IntErrorKind::NegOverflow
);
assert_eq!(bool::try_from(min).unwrap_err().kind(), IntErrorKind::NegOverflow);
assert_eq!(bool::try_from(zero - 1).unwrap_err().kind(), IntErrorKind::NegOverflow);
}
assert_eq!(bool::try_from(zero).unwrap(), false);
assert_eq!(bool::try_from(one).unwrap(), true);
assert_eq!(bool::try_from(two).unwrap_err().kind(), &IntErrorKind::PosOverflow);
assert_eq!(bool::try_from(two).unwrap_err().kind(), IntErrorKind::PosOverflow);
}
};
}
Expand Down Expand Up @@ -540,12 +537,12 @@ macro_rules! test_impl_try_from_signed_to_unsigned_upper_ok {
assert_eq!(<$target as TryFrom<$source>>::try_from(max).unwrap(), max as $target);
assert_eq!(
<$target as TryFrom<$source>>::try_from(min).unwrap_err().kind(),
&IntErrorKind::NegOverflow
IntErrorKind::NegOverflow
);
assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target);
assert_eq!(
<$target as TryFrom<$source>>::try_from(neg_one).unwrap_err().kind(),
&IntErrorKind::NegOverflow
IntErrorKind::NegOverflow
);
}
};
Expand Down Expand Up @@ -609,7 +606,7 @@ macro_rules! test_impl_try_from_unsigned_to_signed_upper_err {
let zero: $source = 0;
assert_eq!(
<$target as TryFrom<$source>>::try_from(max).unwrap_err().kind(),
&IntErrorKind::PosOverflow
IntErrorKind::PosOverflow
);
assert_eq!(<$target as TryFrom<$source>>::try_from(min).unwrap(), min as $target);
assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target);
Expand Down Expand Up @@ -675,12 +672,12 @@ macro_rules! test_impl_try_from_same_sign_err {
let t_min = <$target>::MIN;
assert_eq!(
<$target as TryFrom<$source>>::try_from(max).unwrap_err().kind(),
&IntErrorKind::PosOverflow
IntErrorKind::PosOverflow
);
if min != 0 {
assert_eq!(
<$target as TryFrom<$source>>::try_from(min).unwrap_err().kind(),
&IntErrorKind::NegOverflow
IntErrorKind::NegOverflow
);
}
assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target);
Expand Down Expand Up @@ -770,11 +767,11 @@ macro_rules! test_impl_try_from_signed_to_unsigned_err {
let t_min = <$target>::MIN;
assert_eq!(
<$target as TryFrom<$source>>::try_from(max).unwrap_err().kind(),
&IntErrorKind::PosOverflow
IntErrorKind::PosOverflow
);
assert_eq!(
<$target as TryFrom<$source>>::try_from(min).unwrap_err().kind(),
&IntErrorKind::NegOverflow
IntErrorKind::NegOverflow
);
assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target);
assert_eq!(
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl !Sync for VarsOs {}
/// [`env::vars_os()`]: vars_os
#[must_use]
#[stable(feature = "env", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "env_vars")]
pub fn vars() -> Vars {
Vars { inner: vars_os() }
}
Expand All @@ -157,6 +158,7 @@ pub fn vars() -> Vars {
/// ```
#[must_use]
#[stable(feature = "env", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "env_vars_os")]
pub fn vars_os() -> VarsOs {
VarsOs { inner: env_imp::env() }
}
Expand Down
8 changes: 7 additions & 1 deletion src/tools/remote-test-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ fn get_status_code(status: &ExitStatus) -> (u8, i32) {
}
}

#[cfg(any(windows, target_os = "motor", target_os = "uefi"))]
#[cfg(target_os = "uefi")]
fn get_status_code(status: &ExitStatus) -> (u8, i32) {
let status = status.code().unwrap();
if (status & i32::MIN) != 0 { (1, status & !i32::MIN) } else { (0, status) }
}

#[cfg(any(windows, target_os = "motor"))]
fn get_status_code(status: &ExitStatus) -> (u8, i32) {
(0, status.code().unwrap())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/157774>.
//!
//! A self-referential inherent associated type used to ICE with
//! `item_bounds called on` an impl item.

//@ compile-flags: -Zassumptions-on-binders -Znext-solver=globally

#![feature(inherent_associated_types)]
#![expect(incomplete_features)]

struct Foo<'a> {
x: &'a (),
}

impl<'a> Foo<'a> {
type Assoc = &'a Foo<'a>::Assoc;
//~^ ERROR overflow evaluating the requirement `Foo<'a>::Assoc == _`
//~| ERROR overflow evaluating whether `&'a Foo<'a>::Assoc` is well-formed
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0275]: overflow evaluating the requirement `Foo<'a>::Assoc == _`
--> $DIR/self-referential-inherent-assoc-type-issue-157774.rs:16:5
|
LL | type Assoc = &'a Foo<'a>::Assoc;
| ^^^^^^^^^^

error[E0275]: overflow evaluating whether `&'a Foo<'a>::Assoc` is well-formed
--> $DIR/self-referential-inherent-assoc-type-issue-157774.rs:16:5
|
LL | type Assoc = &'a Foo<'a>::Assoc;
| ^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0275`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/156699>.
//!
//! The target type of a `CoerceShared` impl that could not be normalized
//! used to cause an ICE instead of an error.
#![feature(reborrow)]

use std::marker::{CoerceShared, Reborrow};

struct Wrapper<'a, T>(&'a mut T);

impl<'a, T> Reborrow for Wrapper<'a, T> {}

impl<'a, T> CoerceShared<<T as Iterator>::Item> for Wrapper<'a, T> {}
//~^ ERROR `T` is not an iterator

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0277]: `T` is not an iterator
--> $DIR/coerce-shared-unnormalizable-target-issue-156699.rs:14:1
|
LL | impl<'a, T> CoerceShared<<T as Iterator>::Item> for Wrapper<'a, T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` is not an iterator
|
help: consider restricting type parameter `T` with trait `Iterator`
|
LL | impl<'a, T: std::iter::Iterator> CoerceShared<<T as Iterator>::Item> for Wrapper<'a, T> {}
| +++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading