diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-11-08 18:54:34 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-11-22 14:14:27 -0800 |
| commit | 48fa974211990ec2dd2b8d8c6949d101fb51bb45 (patch) | |
| tree | 2d3395ec5e84232d2d1832bf56d968ef1c0ab8d5 /src/test/ui/suggestions | |
| parent | b6f4b29c6df3fc78adbda9c915f01f8e354d9ca1 (diff) | |
| download | rust-48fa974211990ec2dd2b8d8c6949d101fb51bb45.tar.gz rust-48fa974211990ec2dd2b8d8c6949d101fb51bb45.zip | |
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>`.
Diffstat (limited to 'src/test/ui/suggestions')
| -rw-r--r-- | src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr | 31 |
2 files changed, 39 insertions, 0 deletions
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..053f7010421 --- /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>> } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | missing associated type `A` value + | missing associated type `C` value +help: if you meant to assign the missing associated type, use the name + | +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`. |
