diff options
| author | bors <bors@rust-lang.org> | 2018-11-23 11:26:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-11-23 11:26:48 +0000 |
| commit | aecbcd1ce24373a5077a4ea96f17cc2b7c8bb5eb (patch) | |
| tree | 9d5029637dfe08c6ac6167209619f626af3f6d3e /src/test | |
| parent | 6a2d1b4e15d5de90f8c36181b1d429da658adfd2 (diff) | |
| parent | 510f836d2378bc9d7ec48e3c39ca83006aadb197 (diff) | |
| download | rust-aecbcd1ce24373a5077a4ea96f17cc2b7c8bb5eb.tar.gz rust-aecbcd1ce24373a5077a4ea96f17cc2b7c8bb5eb.zip | |
Auto merge of #55808 - estebank:type-arguments, r=petrochenkov
Suggest correct syntax when writing type arg instead of assoc type - When confusing an associated type with a type argument, suggest the appropriate syntax. Given `Iterator<isize>`, suggest `Iterator<Item = isize>`. - When encountering multiple missing associated types, emit only one diagnostic. - Point at associated type def span for context. - Point at each extra type argument. Follow up to #48288, fix #20977.
Diffstat (limited to 'src/test')
17 files changed, 92 insertions, 30 deletions
diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs index a3422d859c6..1e615c4c0db 100644 --- a/src/test/compile-fail/issue-23595-1.rs +++ b/src/test/compile-fail/issue-23595-1.rs @@ -16,9 +16,7 @@ trait Hierarchy { type Value; type ChildKey; type Children = Index<Self::ChildKey, Output=Hierarchy>; - //~^ ERROR: the value of the associated type `ChildKey` - //~^^ ERROR: the value of the associated type `Children` - //~^^^ ERROR: the value of the associated type `Value` + //~^ ERROR: the value of the associated types `Value` (from the trait `Hierarchy`), `ChildKey` fn data(&self) -> Option<(Self::Value, Self::Children)>; } diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr index 7a10b6d021f..b4285c0de29 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr @@ -25,8 +25,11 @@ LL | fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) { error[E0191]: the value of the associated type `Color` (from the trait `Vehicle`) must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:33:26 | +LL | type Color; + | ----------- `Color` defined here +... LL | fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) { - | ^^^^^^^^^^^^^^^^^^^ missing associated type `Color` value + | ^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-from-multiple-supertraits.rs:38:29 diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.rs b/src/test/ui/associated-types/associated-types-incomplete-object.rs index 9f1df14605b..e575fd695b2 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.rs +++ b/src/test/ui/associated-types/associated-types-incomplete-object.rs @@ -37,6 +37,5 @@ pub fn main() { //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified let d = &42isize as &Foo; - //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified - //~| ERROR the value of the associated type `B` (from the trait `Foo`) must be specified + //~^ ERROR the value of the associated types `A` (from the trait `Foo`), `B` (from the trait } diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.stderr b/src/test/ui/associated-types/associated-types-incomplete-object.stderr index 95b1c631250..eb8e6f998a5 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.stderr +++ b/src/test/ui/associated-types/associated-types-incomplete-object.stderr @@ -1,27 +1,35 @@ error[E0191]: the value of the associated type `B` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:33:26 | +LL | type B; + | ------- `B` defined here +... LL | let b = &42isize as &Foo<A=usize>; - | ^^^^^^^^^^^^ missing associated type `B` value + | ^^^^^^^^^^^^ associated type `B` must be specified error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:36:26 | +LL | type A; + | ------- `A` defined here +... LL | let c = &42isize as &Foo<B=char>; - | ^^^^^^^^^^^ missing associated type `A` value + | ^^^^^^^^^^^ associated type `A` must be specified -error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified - --> $DIR/associated-types-incomplete-object.rs:39:26 - | -LL | let d = &42isize as &Foo; - | ^^^ missing associated type `A` value - -error[E0191]: the value of the associated type `B` (from the trait `Foo`) must be specified +error[E0191]: the value of the associated types `A` (from the trait `Foo`), `B` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:39:26 | +LL | type A; + | ------- `A` defined here +LL | type B; + | ------- `B` defined here +... LL | let d = &42isize as &Foo; - | ^^^ missing associated type `B` value + | ^^^ + | | + | associated type `A` must be specified + | associated type `B` must be specified -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0191`. diff --git a/src/test/ui/error-codes/E0107.rs b/src/test/ui/error-codes/E0107.rs index 815c7fefd2a..87ac9e37853 100644 --- a/src/test/ui/error-codes/E0107.rs +++ b/src/test/ui/error-codes/E0107.rs @@ -26,7 +26,8 @@ struct Baz<'a, 'b, 'c> { //~| unexpected lifetime argument foo2: Foo<'a, 'b, 'c>, //~^ ERROR E0107 - //~| 2 unexpected lifetime arguments + //~| unexpected lifetime argument + //~| unexpected lifetime argument } fn main() {} diff --git a/src/test/ui/error-codes/E0107.stderr b/src/test/ui/error-codes/E0107.stderr index 497fa91bd4f..a07c92cf26a 100644 --- a/src/test/ui/error-codes/E0107.stderr +++ b/src/test/ui/error-codes/E0107.stderr @@ -11,10 +11,12 @@ LL | bar: Bar<'a>, | ^^ unexpected lifetime argument error[E0107]: wrong number of lifetime arguments: expected 1, found 3 - --> $DIR/E0107.rs:27:11 + --> $DIR/E0107.rs:27:19 | LL | foo2: Foo<'a, 'b, 'c>, - | ^^^^^^^^^^^^^^^ 2 unexpected lifetime arguments + | ^^ ^^ unexpected lifetime argument + | | + | unexpected lifetime argument error: aborting due to 3 previous errors diff --git a/src/test/ui/error-codes/E0191.stderr b/src/test/ui/error-codes/E0191.stderr index 08b0a845814..f07529e7e9e 100644 --- a/src/test/ui/error-codes/E0191.stderr +++ b/src/test/ui/error-codes/E0191.stderr @@ -1,8 +1,11 @@ error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified --> $DIR/E0191.rs:15:12 | +LL | type Bar; + | --------- `Bar` defined here +... LL | type Foo = Trait; //~ ERROR E0191 - | ^^^^^ missing associated type `Bar` value + | ^^^^^ associated type `Bar` must be specified error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr index c8a587f2b53..d26e61fba8c 100644 --- a/src/test/ui/error-codes/E0220.stderr +++ b/src/test/ui/error-codes/E0220.stderr @@ -7,8 +7,11 @@ LL | type Foo = Trait<F=i32>; //~ ERROR E0220 error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified --> $DIR/E0220.rs:15:12 | +LL | type Bar; + | --------- `Bar` defined here +... LL | type Foo = Trait<F=i32>; //~ ERROR E0220 - | ^^^^^^^^^^^^ missing associated type `Bar` value + | ^^^^^^^^^^^^ associated type `Bar` must be specified error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-19482.stderr b/src/test/ui/issues/issue-19482.stderr index 5e2d427ab72..d125438b851 100644 --- a/src/test/ui/issues/issue-19482.stderr +++ b/src/test/ui/issues/issue-19482.stderr @@ -1,8 +1,11 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified --> $DIR/issue-19482.rs:20:12 | +LL | type A; + | ------- `A` defined here +... LL | fn bar(x: &Foo) {} - | ^^^ missing associated type `A` value + | ^^^ associated type `A` must be specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index a2f74a29aab..33c89dd4994 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -10,7 +10,7 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op --> $DIR/issue-21950.rs:17:14 | LL | &Add; - | ^^^ missing associated type `Output` value + | ^^^ associated type `Output` must be specified error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-22434.stderr b/src/test/ui/issues/issue-22434.stderr index 914da801ad4..3ba77346a1f 100644 --- a/src/test/ui/issues/issue-22434.stderr +++ b/src/test/ui/issues/issue-22434.stderr @@ -1,8 +1,11 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified --> $DIR/issue-22434.rs:15:19 | +LL | type A; + | ------- `A` defined here +... LL | type I<'a> = &'a (Foo + 'a); - | ^^^^^^^^ missing associated type `A` value + | ^^^^^^^^ associated type `A` must be specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index b5524036fae..715f84011f6 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -28,7 +28,7 @@ LL | type Test = Add + LL | | //~^ ERROR E0393 LL | | //~| ERROR E0191 LL | | Sub; - | |_______________^ missing associated type `Output` value + | |_______________^ associated type `Output` must be specified error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index 129d0945303..adee12a36d3 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -16,7 +16,7 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op --> $DIR/issue-23024.rs:19:35 | LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ missing associated type `Output` value + | ^^ associated type `Output` must be specified error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-28344.stderr b/src/test/ui/issues/issue-28344.stderr index 7ef2e906422..734c761d0b7 100644 --- a/src/test/ui/issues/issue-28344.stderr +++ b/src/test/ui/issues/issue-28344.stderr @@ -2,7 +2,7 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op --> $DIR/issue-28344.rs:14:17 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - | ^^^^^^^^^^^^^ missing associated type `Output` value + | ^^^^^^^^^^^^^ associated type `Output` must be specified error[E0599]: no function or associated item named `bitor` found for type `dyn std::ops::BitXor<_>` in the current scope --> $DIR/issue-28344.rs:14:17 @@ -16,7 +16,7 @@ error[E0191]: the value of the associated type `Output` (from the trait `std::op --> $DIR/issue-28344.rs:18:13 | LL | let g = BitXor::bitor; - | ^^^^^^^^^^^^^ missing associated type `Output` value + | ^^^^^^^^^^^^^ associated type `Output` must be specified error[E0599]: no function or associated item named `bitor` found for type `dyn std::ops::BitXor<_>` in the current scope --> $DIR/issue-28344.rs:18:13 diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs new file mode 100644 index 00000000000..58e7718ba5b --- /dev/null +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs @@ -0,0 +1,8 @@ +pub trait T<X, Y> { + type A; + type B; + type C; +} + pub struct Foo { i: Box<T<usize, usize, usize, usize, B=usize>> } + + fn main() {} diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr new file mode 100644 index 00000000000..b62b5d3b04c --- /dev/null +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -0,0 +1,31 @@ +error[E0107]: wrong number of type arguments: expected 2, found 4 + --> $DIR/use-type-argument-instead-of-assoc-type.rs:6:42 + | +LL | pub struct Foo { i: Box<T<usize, usize, usize, usize, B=usize>> } + | ^^^^^ ^^^^^ unexpected type argument + | | + | unexpected type argument + +error[E0191]: the value of the associated types `A` (from the trait `T`), `C` (from the trait `T`) must be specified + --> $DIR/use-type-argument-instead-of-assoc-type.rs:6:26 + | +LL | type A; + | ------- `A` defined here +LL | type B; +LL | type C; + | ------- `C` defined here +LL | } +LL | pub struct Foo { i: Box<T<usize, usize, usize, usize, B=usize>> } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | associated type `A` must be specified + | associated type `C` must be specified +help: if you meant to specify the associated types, write + | +LL | pub struct Foo { i: Box<T<usize, usize, A = usize, C = usize, B=usize>> } + | ^^^^^^^^^ ^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0107, E0191. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/traits/trait-alias-object.stderr b/src/test/ui/traits/trait-alias-object.stderr index 6b7b322a53d..fdb9427cba7 100644 --- a/src/test/ui/traits/trait-alias-object.stderr +++ b/src/test/ui/traits/trait-alias-object.stderr @@ -10,7 +10,7 @@ error[E0191]: the value of the associated type `Item` (from the trait `std::iter --> $DIR/trait-alias-object.rs:18:13 | LL | let _: &dyn IteratorAlias = &vec![123].into_iter(); - | ^^^^^^^^^^^^^^^^^ missing associated type `Item` value + | ^^^^^^^^^^^^^^^^^ associated type `Item` must be specified error: aborting due to 2 previous errors |
