Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #124239

Closed
wants to merge 8 commits into from
Closed
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/layout/ice-type-error-in-tail-124031.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
12 changes: 12 additions & 0 deletions tests/ui/layout/ice-type-error-in-tail-124031.stderr
Original file line number Diff line number Diff line change
@@ -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`.
1 change: 0 additions & 1 deletion triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ compiler-team-contributors = [
"@nnethercote",
"@fmease",
"@fee1-dead",
"@BoxyUwU",
"@jieyouxu",
]
compiler = [
Expand Down
Loading