Skip to content
Open
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
5 changes: 3 additions & 2 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,9 @@ impl<'tcx> Ty<'tcx> {

| ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),

ty::Infer(ty::TyVar(_))
| ty::Pat(..)
ty::Infer(ty::TyVar(_)) => Ok(tcx.types.unit),

ty::Pat(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => bug!(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Regression test for <https://github.com/rust-lang/rust/issues/153431>.
// Used to ICE in `ptr_metadata_ty_or_tail` when computing pointer metadata
// for a struct whose tail field has a recursive associated type.
//~^^^ ERROR overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`

trait Trait {
type Assoc2;
}

struct Bar;
impl Trait for Bar {
type Assoc2 = Result<(), <Bar as Trait>::Assoc2>;
//~^ ERROR overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`
}

struct Foo {
field: <Bar as Trait>::Assoc2,
//~^ ERROR overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`
}

static BAR: u8 = 42;
static FOO2: &Foo = unsafe { std::mem::transmute(&BAR) };

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0275]: overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`
--> $DIR/ptr-metadata-recursive-assoc-type-ice-153431.rs:12:19
|
LL | type Assoc2 = Result<(), <Bar as Trait>::Assoc2>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`
--> $DIR/ptr-metadata-recursive-assoc-type-ice-153431.rs:17:12
|
LL | field: <Bar as Trait>::Assoc2,
| ^^^^^^^^^^^^^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`

error: aborting due to 3 previous errors

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