forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move type parameter shadowing errors to resolve
For some reason type checking did this. Further it didn't consider hygiene.
- Loading branch information
1 parent
3296d0e
commit f70c90c
Showing
14 changed files
with
108 additions
and
109 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
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
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
error[E0194]: type parameter `T` shadows another type parameter of the same name | ||
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters | ||
--> $DIR/E0194.rs:3:26 | ||
| | ||
LL | trait Foo<T> { | ||
| - first `T` declared here | ||
| - first use of `T` | ||
LL | fn do_something(&self) -> T; | ||
LL | fn do_something_else<T: Clone>(&self, bar: T); | ||
| ^ shadows another type parameter | ||
| ^ already used | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0194`. | ||
For more information about this error, try `rustc --explain E0403`. |
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 |
---|---|---|
@@ -1,32 +1,30 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
//FIXME(#44265): The lifetime shadowing and type parameter shadowing | ||
// should cause an error. Now it compiles (erroneously) and this will be addressed | ||
// by a future PR. Then remove the following: | ||
// build-pass (FIXME(62277): could be check-pass?) | ||
|
||
trait Shadow<'a> { | ||
type Bar<'a>; // Error: shadowed lifetime | ||
//FIXME(#44265): The lifetime parameter shadowing should cause an error. | ||
type Bar<'a>; | ||
} | ||
|
||
trait NoShadow<'a> { | ||
type Bar<'b>; // OK | ||
} | ||
|
||
impl<'a> NoShadow<'a> for &'a u32 { | ||
type Bar<'a> = i32; // Error: shadowed lifetime | ||
//FIXME(#44265): The lifetime parameter shadowing should cause an error. | ||
type Bar<'a> = i32; | ||
} | ||
|
||
trait ShadowT<T> { | ||
type Bar<T>; // Error: shadowed type parameter | ||
type Bar<T>; //~ ERROR the name `T` is already used | ||
} | ||
|
||
trait NoShadowT<T> { | ||
type Bar<U>; // OK | ||
} | ||
|
||
impl<T> NoShadowT<T> for Option<T> { | ||
type Bar<T> = i32; // Error: shadowed type parameter | ||
type Bar<T> = i32; //~ ERROR the name `T` is already used | ||
} | ||
|
||
fn main() {} |
21 changes: 16 additions & 5 deletions
21
src/test/ui/rfc1598-generic-associated-types/shadowing.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 |
---|---|---|
@@ -1,8 +1,19 @@ | ||
warning: the feature `generic_associated_types` is incomplete and may cause the compiler to crash | ||
--> $DIR/shadowing.rs:1:12 | ||
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters | ||
--> $DIR/shadowing.rs:19:14 | ||
| | ||
LL | #![feature(generic_associated_types)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | trait ShadowT<T> { | ||
| - first use of `T` | ||
LL | type Bar<T>; | ||
| ^ already used | ||
|
||
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters | ||
--> $DIR/shadowing.rs:27:14 | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
LL | impl<T> NoShadowT<T> for Option<T> { | ||
| - first use of `T` | ||
LL | type Bar<T> = i32; | ||
| ^ already used | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0403`. |
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
Oops, something went wrong.