-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added shadowed hint for overlapping associated types
Added help message to suggest renaming Added rename help message on subtrait Remove rename suggestions on unrelated associated types Added ui test Removed call to filter_by_name_unhygienic
- Loading branch information
1 parent
9c8a269
commit 4a71828
Showing
4 changed files
with
107 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
tests/ui/associated-types/associated-type-shadowed-from-supertrait.rs
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,19 @@ | ||
// Test Setting the value of an associated type | ||
// that is shadowed from a supertrait | ||
|
||
pub trait Super { | ||
type X; | ||
} | ||
|
||
pub trait Sub: Super { | ||
type X; //~INFO shadowed | ||
} | ||
|
||
//~ ERROR missing type | ||
impl<T> Clone for Box<dyn Sub<X = T>> { | ||
fn clone(&self) -> Self { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
pub fn main() {} |
26 changes: 26 additions & 0 deletions
26
tests/ui/associated-types/associated-type-shadowed-from-supertrait.stderr
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,26 @@ | ||
error[E0191]: the value of the associated type `X` in `Super` must be specified | ||
--> $DIR/associated-type-shadowed-from-supertrait.rs:13:27 | ||
| | ||
LL | type X; | ||
| ------ `Super::X` defined here | ||
... | ||
LL | type X; | ||
| ------ `Super::X` shadowed here | ||
... | ||
LL | impl<T> Clone for Box<dyn Sub<X = T>> { | ||
| ^^^^^^^^^^ associated type `X` must be specified | ||
| | ||
help: consider renaming this associated type | ||
--> $DIR/associated-type-shadowed-from-supertrait.rs:5:5 | ||
| | ||
LL | type X; | ||
| ^^^^^^ | ||
help: consider renaming this associated type | ||
--> $DIR/associated-type-shadowed-from-supertrait.rs:9:5 | ||
| | ||
LL | type X; | ||
| ^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0191`. |