add regression test

This commit is contained in:
lcnr 2026-01-29 11:47:21 +01:00
parent ba284f468c
commit d4454e59d3
2 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,30 @@
//@ compile-flags: -O -Cdebug-assertions=on
//@ build-pass
// A regression test for #151791. Computing the layout of
// `<AsOwned as ArchiveWith<'a>>::Archived` fails as the alias
// is still rigid as the where-bound in scope shadows the impl.
//
// This previously caused an incorrect error during MIR optimizations.
struct ArchivedString;
pub trait ArchiveWith<'a> {
type Archived;
}
struct AsOwned;
impl ArchiveWith<'_> for AsOwned {
type Archived = ArchivedString;
}
fn foo<'a>()
where
AsOwned: ArchiveWith<'a>,
{
let _ = unsafe { &*std::ptr::dangling::<<AsOwned as ArchiveWith<'a>>::Archived>() };
}
fn main() {
foo();
}

View file

@ -2,7 +2,7 @@
//@ build-pass
// A regression test for #149081. The environment of `size` and `align`
// currently means that the item bound of`T::Assoc` doesn't hold. This can
// currently means that the item bound of `T::Assoc` doesn't hold. This can
// result in normalization failures and ICE during MIR optimizations.
//
// This will no longer be an issue once #149283 is implemented.