diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index d340a08ee79b1..dd76862451c6f 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -228,8 +228,8 @@ pub fn lower_generic_args<'tcx: 'a, 'a>( // Check whether this segment takes generic arguments and the user has provided any. let (generic_args, infer_args) = ctx.args_for_def_id(def_id); - let args_iter = generic_args.iter().flat_map(|generic_args| generic_args.args.iter()); - let mut args_iter = args_iter.clone().peekable(); + let mut args_iter = + generic_args.iter().flat_map(|generic_args| generic_args.args.iter()).peekable(); // If we encounter a type or const when we expect a lifetime, we infer the lifetimes. // If we later encounter a lifetime, we know that the arguments were provided in the diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 6381bd190ac0a..897d6f5662f60 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -338,6 +338,10 @@ impl<'tcx> SizeSkeleton<'tcx> { debug_assert!(tail.has_non_region_param()); Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(tail) }) } + ty::Error(guar) => { + // Fixes ICE #124031 + return Err(tcx.arena.alloc(LayoutError::ReferencesError(*guar))); + } _ => bug!( "SizeSkeleton::compute({ty}): layout errored ({err:?}), yet \ tail `{tail}` is not a type parameter or a projection", diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index c223b9f43240f..f3972346bb5be 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -56,6 +56,7 @@ static TARGETS: &[&str] = &[ "aarch64-apple-ios-sim", "aarch64-unknown-fuchsia", "aarch64-linux-android", + "aarch64-pc-windows-gnullvm", "aarch64-pc-windows-msvc", "aarch64-unknown-hermit", "aarch64-unknown-linux-gnu", @@ -96,6 +97,7 @@ static TARGETS: &[&str] = &[ "i686-apple-darwin", "i686-linux-android", "i686-pc-windows-gnu", + "i686-pc-windows-gnullvm", "i686-pc-windows-msvc", "i686-unknown-freebsd", "i686-unknown-linux-gnu", @@ -157,6 +159,7 @@ static TARGETS: &[&str] = &[ "x86_64-unknown-fuchsia", "x86_64-linux-android", "x86_64-pc-windows-gnu", + "x86_64-pc-windows-gnullvm", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unikraft-linux-musl", diff --git a/tests/ui/layout/ice-type-error-in-tail-124031.rs b/tests/ui/layout/ice-type-error-in-tail-124031.rs new file mode 100644 index 0000000000000..0a2be11740358 --- /dev/null +++ b/tests/ui/layout/ice-type-error-in-tail-124031.rs @@ -0,0 +1,20 @@ +// Regression test for issue #124031 +// Checks that we don't ICE when the tail +// of an ADT has a type error + +trait Trait { + type RefTarget; +} + +impl Trait for () {} +//~^ ERROR not all trait items implemented, missing: `RefTarget` + +struct Other { + data: <() as Trait>::RefTarget, +} + +fn main() { + unsafe { + std::mem::transmute::<Option<()>, Option<&Other>>(None); + } +} diff --git a/tests/ui/layout/ice-type-error-in-tail-124031.stderr b/tests/ui/layout/ice-type-error-in-tail-124031.stderr new file mode 100644 index 0000000000000..57dc83f92dfda --- /dev/null +++ b/tests/ui/layout/ice-type-error-in-tail-124031.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `RefTarget` + --> $DIR/ice-type-error-in-tail-124031.rs:9:1 + | +LL | type RefTarget; + | -------------- `RefTarget` from trait +... +LL | impl Trait for () {} + | ^^^^^^^^^^^^^^^^^ missing `RefTarget` in implementation + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/triagebot.toml b/triagebot.toml index 66b8f44d68898..903569bf44549 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -851,7 +851,6 @@ compiler-team-contributors = [ "@nnethercote", "@fmease", "@fee1-dead", - "@BoxyUwU", "@jieyouxu", ] compiler = [