Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 0 additions & 2 deletions src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2554,8 +2554,6 @@ ui/suggestions/issue-109991.rs
ui/suggestions/issue-112590-suggest-import.rs
ui/suggestions/issue-114701.rs
ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs
ui/suggestions/issue-116434-2015.rs
ui/suggestions/issue-116434-2021.rs
ui/suggestions/issue-117669.rs
ui/suggestions/issue-21673.rs
ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.rs
Expand Down
40 changes: 40 additions & 0 deletions tests/ui/suggestions/bare_trait_objects.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//@ revisions: rust2015 rust2021
//@[rust2015] edition:2015
//@[rust2021] edition:2021
Comment on lines +1 to +3
Copy link
Copy Markdown
Member

@Zalathar Zalathar Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming this test to bare_trait_objects.rs has ended up losing all the context of #116434 and #120530.

It turns out that this test is specifically trying to test how traits that aren't dyn-compatible influence the diagnostic messages.

View changes since the review



trait Foo {
type Clone;
fn foo() -> Clone;
//[rust2021]~^ ERROR expected a type, found a trait
//[rust2021]~| HELP `Clone` is dyn-incompatible, use `impl Clone` to return an opaque type, as long as you return a single underlying type
//[rust2015]~^^^ WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
//[rust2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
//[rust2015]~| HELP if this is a dyn-compatible trait, use `dyn`
//[rust2015]~| WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
//[rust2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
//[rust2015]~| HELP if this is a dyn-compatible trait, use `dyn`
//[rust2015]~| ERROR the trait `Clone` is not dyn compatible [E0038]
//~| HELP there is an associated type with the same name
//[rust2015]~| HELP use `Self` to refer to the implementing type
Comment on lines +9 to +19
Copy link
Copy Markdown
Member

@Zalathar Zalathar Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the greatly decreased readability of these error annotations, I'm inclined to think that merging these particular tests is not worthwhile.

View changes since the review

}

trait DbHandle: Sized {}

trait DbInterface {
type DbHandle;
fn handle() -> DbHandle;
//[rust2021]~^ ERROR expected a type, found a trait
//[rust2021]~| HELP `DbHandle` is dyn-incompatible, use `impl DbHandle` to return an opaque type, as long as you return a single underlying type
//[rust2015]~^^^ WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
//[rust2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
//[rust2015]~| HELP if this is a dyn-compatible trait, use `dyn`
//[rust2015]~| WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
//[rust2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
//[rust2015]~| HELP if this is a dyn-compatible trait, use `dyn`
//[rust2015]~| ERROR the trait `DbHandle` is not dyn compatible [E0038]
//~| HELP there is an associated type with the same name
//[rust2015]~| HELP use `Self` to refer to the implementing type
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-116434-2015.rs:5:17
--> $DIR/bare_trait_objects.rs:8:17
|
LL | fn foo() -> Clone;
| ^^^^^
Expand All @@ -13,7 +13,7 @@ LL | fn foo() -> dyn Clone;
| +++

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-116434-2015.rs:5:17
--> $DIR/bare_trait_objects.rs:8:17
|
LL | fn foo() -> Clone;
| ^^^^^
Expand All @@ -27,7 +27,7 @@ LL | fn foo() -> dyn Clone;
| +++

error[E0038]: the trait `Clone` is not dyn compatible
--> $DIR/issue-116434-2015.rs:5:17
--> $DIR/bare_trait_objects.rs:8:17
|
LL | fn foo() -> Clone;
| ^^^^^ `Clone` is not dyn compatible
Expand All @@ -46,7 +46,7 @@ LL | fn foo() -> Self::Clone;
| ++++++

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-116434-2015.rs:21:20
--> $DIR/bare_trait_objects.rs:26:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^
Expand All @@ -59,7 +59,7 @@ LL | fn handle() -> dyn DbHandle;
| +++

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-116434-2015.rs:21:20
--> $DIR/bare_trait_objects.rs:26:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^
Expand All @@ -73,14 +73,14 @@ LL | fn handle() -> dyn DbHandle;
| +++

error[E0038]: the trait `DbHandle` is not dyn compatible
--> $DIR/issue-116434-2015.rs:21:20
--> $DIR/bare_trait_objects.rs:26:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^ `DbHandle` 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/issue-116434-2015.rs:17:17
--> $DIR/bare_trait_objects.rs:22:17
|
LL | trait DbHandle: Sized {}
| -------- ^^^^^ ...because it requires `Self: Sized`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0782]: expected a type, found a trait
--> $DIR/issue-116434-2021.rs:5:17
--> $DIR/bare_trait_objects.rs:8:17
|
LL | fn foo() -> Clone;
| ^^^^^
Expand All @@ -14,7 +14,7 @@ LL | fn foo() -> Self::Clone;
| ++++++

error[E0782]: expected a type, found a trait
--> $DIR/issue-116434-2021.rs:15:20
--> $DIR/bare_trait_objects.rs:26:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^
Expand Down
33 changes: 0 additions & 33 deletions tests/ui/suggestions/issue-116434-2015.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ui/suggestions/issue-116434-2021.rs

This file was deleted.

Loading