Skip to content

Commit f8beb8f

Browse files
committed
Add test for extra <> in dyn suggestion.
1 parent 23d2cb8 commit f8beb8f

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

Diff for: src/test/ui/dyn-keyword/dyn-angle-brackets.fixed

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// See https://github.com/rust-lang/rust/issues/88508
2+
// run-rustfix
3+
// edition:2018
4+
#![deny(bare_trait_objects)]
5+
#![allow(dead_code)]
6+
#![allow(unused_imports)]
7+
8+
use std::fmt;
9+
10+
#[derive(Debug)]
11+
pub struct Foo;
12+
13+
impl fmt::Display for Foo {
14+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15+
<dyn fmt::Debug>::fmt(self, f)
16+
//~^ ERROR trait objects without an explicit `dyn` are deprecated
17+
//~| WARNING this is accepted in the current edition
18+
//~| ERROR trait objects without an explicit `dyn` are deprecated
19+
//~| WARNING this is accepted in the current edition
20+
}
21+
}
22+
23+
fn main() {}

Diff for: src/test/ui/dyn-keyword/dyn-angle-brackets.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// See https://github.com/rust-lang/rust/issues/88508
2+
// run-rustfix
3+
// edition:2018
4+
#![deny(bare_trait_objects)]
5+
#![allow(dead_code)]
6+
#![allow(unused_imports)]
7+
8+
use std::fmt;
9+
10+
#[derive(Debug)]
11+
pub struct Foo;
12+
13+
impl fmt::Display for Foo {
14+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15+
<fmt::Debug>::fmt(self, f)
16+
//~^ ERROR trait objects without an explicit `dyn` are deprecated
17+
//~| WARNING this is accepted in the current edition
18+
//~| ERROR trait objects without an explicit `dyn` are deprecated
19+
//~| WARNING this is accepted in the current edition
20+
}
21+
}
22+
23+
fn main() {}

Diff for: src/test/ui/dyn-keyword/dyn-angle-brackets.stderr

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: trait objects without an explicit `dyn` are deprecated
2+
--> $DIR/dyn-angle-brackets.rs:15:10
3+
|
4+
LL | <fmt::Debug>::fmt(self, f)
5+
| ^^^^^^^^^^ help: use `dyn`: `dyn fmt::Debug`
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/dyn-angle-brackets.rs:4:9
9+
|
10+
LL | #![deny(bare_trait_objects)]
11+
| ^^^^^^^^^^^^^^^^^^
12+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
13+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
14+
15+
error: trait objects without an explicit `dyn` are deprecated
16+
--> $DIR/dyn-angle-brackets.rs:15:10
17+
|
18+
LL | <fmt::Debug>::fmt(self, f)
19+
| ^^^^^^^^^^ help: use `dyn`: `dyn fmt::Debug`
20+
|
21+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
22+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
23+
24+
error: aborting due to 2 previous errors
25+

0 commit comments

Comments
 (0)