File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
tests/ui/dyn-compatibility Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // Test that E0038 is not emitted twice for the same trait object coercion
2+ // regression test for issue <https://github.com/rust-lang/rust/issues/128705>
3+
4+ #![ allow( dead_code) ]
5+
6+ trait Tr {
7+ const N : usize ;
8+ }
9+
10+ impl Tr for u8 {
11+ const N : usize = 1 ;
12+ }
13+
14+ fn main ( ) {
15+ let x: & dyn Tr = & 0_u8 ;
16+ //~^ ERROR E0038
17+ }
Original file line number Diff line number Diff line change 1+ error[E0038]: the trait `Tr` is not dyn compatible
2+ --> $DIR/no-duplicate-e0038.rs:15:17
3+ |
4+ LL | let x: &dyn Tr = &0_u8;
5+ | ^^ `Tr` is not dyn compatible
6+ |
7+ note: for a trait to be dyn compatible it needs to allow building a vtable
8+ for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
9+ --> $DIR/no-duplicate-e0038.rs:7:11
10+ |
11+ LL | trait Tr {
12+ | -- this trait is not dyn compatible...
13+ LL | const N: usize;
14+ | ^ ...because it contains this associated `const`
15+ = help: consider moving `N` to another trait
16+ = help: only type `u8` implements `Tr`; consider using it directly instead.
17+
18+ error: aborting due to 1 previous error
19+
20+ For more information about this error, try `rustc --explain E0038`.
You can’t perform that action at this time.
0 commit comments