diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 13d38d3c9609a..6f587df6e33c2 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -433,6 +433,8 @@ mod spec_extend; #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "Vec"] #[rustc_insignificant_dtor] +#[doc(alias = "list")] +#[doc(alias = "vector")] pub struct Vec { buf: RawVec, len: usize, diff --git a/tests/ui/dyn-compatibility/no-duplicate-e0038.rs b/tests/ui/dyn-compatibility/no-duplicate-e0038.rs new file mode 100644 index 0000000000000..283164596d065 --- /dev/null +++ b/tests/ui/dyn-compatibility/no-duplicate-e0038.rs @@ -0,0 +1,17 @@ +// Test that E0038 is not emitted twice for the same trait object coercion +// regression test for issue + +#![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 +} diff --git a/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr b/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr new file mode 100644 index 0000000000000..94037387c3e11 --- /dev/null +++ b/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr @@ -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 + --> $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`.