Move type parameter shadowing errors to resolve

For some reason type checking did this. Further it didn't consider
hygiene.
This commit is contained in:
Matthew Jasper 2019-08-11 18:09:50 +01:00
parent 3296d0ed6d
commit f70c90c677
14 changed files with 116 additions and 117 deletions

View file

@ -1,4 +1,4 @@
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:1:12
|
LL | type Foo<T,T> = Option<T>;
@ -6,7 +6,7 @@ LL | type Foo<T,T> = Option<T>;
| |
| first use of `T`
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:4:14
|
LL | struct Bar<T,T>(T);
@ -14,7 +14,7 @@ LL | struct Bar<T,T>(T);
| |
| first use of `T`
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:7:14
|
LL | struct Baz<T,T> {
@ -22,7 +22,7 @@ LL | struct Baz<T,T> {
| |
| first use of `T`
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:12:12
|
LL | enum Boo<T,T> {
@ -30,7 +30,7 @@ LL | enum Boo<T,T> {
| |
| first use of `T`
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:18:11
|
LL | fn quux<T,T>(x: T) {}
@ -38,7 +38,7 @@ LL | fn quux<T,T>(x: T) {}
| |
| first use of `T`
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:21:13
|
LL | trait Qux<T,T> {}
@ -46,7 +46,7 @@ LL | trait Qux<T,T> {}
| |
| first use of `T`
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/duplicate-type-parameter.rs:24:8
|
LL | impl<T,T> Qux<T,T> for Option<T> {}

View file

@ -1,7 +1,7 @@
trait Foo<T> {
fn do_something(&self) -> T;
fn do_something_else<T: Clone>(&self, bar: T);
//~^ ERROR E0194
//~^ ERROR E0403
}
fn main() {

View file

@ -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`.

View file

@ -1,4 +1,4 @@
error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/E0403.rs:1:11
|
LL | fn foo<T, T>(s: T, u: T) {}

View file

@ -1,12 +1,9 @@
#![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> {
@ -14,11 +11,12 @@ trait NoShadow<'a> {
}
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> {
@ -26,7 +24,7 @@ trait NoShadowT<T> {
}
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() {}

View file

@ -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)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
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
|
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`.

View file

@ -6,7 +6,7 @@ struct Foo<T>(T);
impl<T> Foo<T> {
fn shadow_in_method<T>(&self) {}
//~^ ERROR type parameter `T` shadows another type parameter
//~^ ERROR the name `T` is already used
fn not_shadow_in_item<U>(&self) {
struct Bar<T, U>(T,U); // not a shadow, separate item
@ -18,10 +18,10 @@ trait Bar<T> {
fn dummy(&self) -> T;
fn shadow_in_required<T>(&self);
//~^ ERROR type parameter `T` shadows another type parameter
//~^ ERROR the name `T` is already used
fn shadow_in_provided<T>(&self) {}
//~^ ERROR type parameter `T` shadows another type parameter
//~^ ERROR the name `T` is already used
fn not_shadow_in_required<U>(&self);
fn not_shadow_in_provided<U>(&self) {}

View file

@ -1,29 +1,29 @@
error[E0194]: type parameter `T` shadows another type parameter of the same name
--> $DIR/shadowed-type-parameter.rs:20:27
|
LL | trait Bar<T> {
| - first `T` declared here
...
LL | fn shadow_in_required<T>(&self);
| ^ shadows another type parameter
error[E0194]: type parameter `T` shadows another type parameter of the same name
--> $DIR/shadowed-type-parameter.rs:23:27
|
LL | trait Bar<T> {
| - first `T` declared here
...
LL | fn shadow_in_provided<T>(&self) {}
| ^ shadows another type parameter
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/shadowed-type-parameter.rs:8:25
|
LL | impl<T> Foo<T> {
| - first `T` declared here
| - first use of `T`
LL | fn shadow_in_method<T>(&self) {}
| ^ shadows another type parameter
| ^ already used
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/shadowed-type-parameter.rs:20:27
|
LL | trait Bar<T> {
| - first use of `T`
...
LL | fn shadow_in_required<T>(&self);
| ^ already used
error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
--> $DIR/shadowed-type-parameter.rs:23:27
|
LL | trait Bar<T> {
| - first use of `T`
...
LL | fn shadow_in_provided<T>(&self) {}
| ^ already used
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0194`.
For more information about this error, try `rustc --explain E0403`.