Skip to content

Commit 9549166

Browse files
committed
add test
1 parent dfe1b8c commit 9549166

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ compile-flags: -Copt-level=3 --crate-type=rlib
2+
//@ build-pass
3+
4+
// A regression test for #149081. The environment of `size` and `align`
5+
// currently means that the item bound of`T::Assoc` doesn't hold. This can
6+
// result in normalization failures and ICE during MIR optimizations.
7+
//
8+
// This will no longer be an issue once #149283 is implemented.
9+
10+
pub fn align<T: WithAssoc<Assoc = U>, U>() -> usize {
11+
std::mem::align_of::<Wrapper<T>>()
12+
}
13+
14+
pub fn size<T: WithAssoc<Assoc = U>, U>() -> usize {
15+
std::mem::size_of::<Wrapper<T>>()
16+
}
17+
18+
pub struct Wrapper<T: WithAssoc> {
19+
assoc2: <T::Assoc as WithAssoc>::Assoc,
20+
value: T,
21+
}
22+
23+
pub trait WithAssoc {
24+
type Assoc: WithAssoc;
25+
}

0 commit comments

Comments
 (0)