Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report missing cases of
bare_trait_objects
- Loading branch information
1 parent
38ed36b
commit b48530b
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![feature(associated_type_defaults)] | ||
|
||
trait Assoc { | ||
fn func() {} | ||
const CONST: u8 = 0; | ||
type Ty = u8; | ||
} | ||
|
||
trait Dyn {} | ||
|
||
impl Assoc for dyn Dyn {} | ||
|
||
fn main() { | ||
Dyn::func(); //~ WARN trait objects without an explicit `dyn` are deprecated | ||
::Dyn::func(); //~ WARN trait objects without an explicit `dyn` are deprecated | ||
Dyn::CONST; //~ WARN trait objects without an explicit `dyn` are deprecated | ||
let _: Dyn::Ty; //~ ERROR ambiguous associated type | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error[E0223]: ambiguous associated type | ||
--> $DIR/bare-trait-objects-path.rs:17:12 | ||
| | ||
LL | let _: Dyn::Ty; | ||
| ^^^^^^^ help: use fully-qualified syntax: `<dyn Dyn as Trait>::Ty` | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/bare-trait-objects-path.rs:14:5 | ||
| | ||
LL | Dyn::func(); | ||
| ^^^ help: use `dyn`: `<dyn Dyn>` | ||
| | ||
= note: `#[warn(bare_trait_objects)]` on by default | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/bare-trait-objects-path.rs:15:5 | ||
| | ||
LL | ::Dyn::func(); | ||
| ^^^^^ help: use `dyn`: `<dyn (::Dyn)>` | ||
|
||
warning: trait objects without an explicit `dyn` are deprecated | ||
--> $DIR/bare-trait-objects-path.rs:16:5 | ||
| | ||
LL | Dyn::CONST; | ||
| ^^^ help: use `dyn`: `<dyn Dyn>` | ||
|
||
error: aborting due to previous error; 3 warnings emitted | ||
|
||
For more information about this error, try `rustc --explain E0223`. |