Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
buf: RawVec<T, A>,
len: usize,
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/dyn-compatibility/no-duplicate-e0038.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions tests/ui/dyn-compatibility/no-duplicate-e0038.stderr
Original file line number Diff line number Diff line change
@@ -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