]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-consts/associated-const-resolution-order.rs
Rollup merge of #105983 - compiler-errors:issue-105981, r=tmiasko
[rust.git] / src / test / ui / associated-consts / associated-const-resolution-order.rs
1 // run-pass
2
3 struct MyType;
4
5 impl MyType {
6     const IMPL_IS_INHERENT: bool = true;
7 }
8
9 trait MyTrait {
10     const IMPL_IS_INHERENT: bool;
11     const IMPL_IS_ON_TRAIT: bool;
12 }
13
14 impl MyTrait for MyType {
15     const IMPL_IS_INHERENT: bool = false;
16     const IMPL_IS_ON_TRAIT: bool = true;
17 }
18
19 fn main() {
20     // Check that the inherent impl is used before the trait, but that the trait
21     // can still be accessed.
22     assert!(<MyType>::IMPL_IS_INHERENT);
23     assert!(!<MyType as MyTrait>::IMPL_IS_INHERENT);
24     assert!(<MyType>::IMPL_IS_ON_TRAIT);
25 }