Add regression test for 128705
This commit is contained in:
parent
5dbf4069dc
commit
a4ee7f8964
2 changed files with 37 additions and 0 deletions
17
tests/ui/dyn-compatibility/no-duplicate-e0038.rs
Normal file
17
tests/ui/dyn-compatibility/no-duplicate-e0038.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Test that E0038 is not emitted twice for the same trait object coercion
|
||||
// regression test for issue <https://github.com/rust-lang/rust/issues/128705>
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
trait Tr {
|
||||
const N: usize;
|
||||
}
|
||||
|
||||
impl Tr for u8 {
|
||||
const N: usize = 1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: &dyn Tr = &0_u8;
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
20
tests/ui/dyn-compatibility/no-duplicate-e0038.stderr
Normal file
20
tests/ui/dyn-compatibility/no-duplicate-e0038.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error[E0038]: the trait `Tr` is not dyn compatible
|
||||
--> $DIR/no-duplicate-e0038.rs:15:17
|
||||
|
|
||||
LL | let x: &dyn Tr = &0_u8;
|
||||
| ^^ `Tr` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/no-duplicate-e0038.rs:7:11
|
||||
|
|
||||
LL | trait Tr {
|
||||
| -- this trait is not dyn compatible...
|
||||
LL | const N: usize;
|
||||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `N` to another trait
|
||||
= help: only type `u8` implements `Tr`; consider using it directly instead.
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue