diff options
| author | Caio <c410.f3r@gmail.com> | 2021-04-17 18:53:54 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2021-04-17 18:53:54 -0300 |
| commit | 4e6d6abc6a514988ae13cea41993688d8cf9dd4a (patch) | |
| tree | 8949623d58304ad65b5e095f7ac026938adbad06 /src/test/ui/generics | |
| parent | 4029d4d0be03b10edccb65588b522ad541b5ccaf (diff) | |
| download | rust-4e6d6abc6a514988ae13cea41993688d8cf9dd4a.tar.gz rust-4e6d6abc6a514988ae13cea41993688d8cf9dd4a.zip | |
Move some tests to more reasonable directories - 6
Diffstat (limited to 'src/test/ui/generics')
| -rw-r--r-- | src/test/ui/generics/bad-mid-path-type-params.rs | 44 | ||||
| -rw-r--r-- | src/test/ui/generics/bad-mid-path-type-params.stderr | 73 |
2 files changed, 117 insertions, 0 deletions
diff --git a/src/test/ui/generics/bad-mid-path-type-params.rs b/src/test/ui/generics/bad-mid-path-type-params.rs new file mode 100644 index 00000000000..c42ce602e99 --- /dev/null +++ b/src/test/ui/generics/bad-mid-path-type-params.rs @@ -0,0 +1,44 @@ +struct S<T> { + contents: T, +} + +impl<T> S<T> { + fn new<U>(x: T, _: U) -> S<T> { + S { + contents: x, + } + } +} + +trait Trait<T> { + fn new<U>(x: T, y: U) -> Self; +} + +struct S2 { + contents: isize, +} + +impl Trait<isize> for S2 { + fn new<U>(x: isize, _: U) -> S2 { + S2 { + contents: x, + } + } +} + +fn foo<'a>() { + let _ = S::new::<isize,f64>(1, 1.0); + //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied + + let _ = S::<'a,isize>::new::<f64>(1, 1.0); + //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied + + let _: S2 = Trait::new::<isize,f64>(1, 1.0); + //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied + + let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0); + //~^ ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied + //~| ERROR this associated function takes 1 type argument but 2 type arguments were supplied +} + +fn main() {} diff --git a/src/test/ui/generics/bad-mid-path-type-params.stderr b/src/test/ui/generics/bad-mid-path-type-params.stderr new file mode 100644 index 00000000000..dd96856e563 --- /dev/null +++ b/src/test/ui/generics/bad-mid-path-type-params.stderr @@ -0,0 +1,73 @@ +error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied + --> $DIR/bad-mid-path-type-params.rs:30:16 + | +LL | let _ = S::new::<isize,f64>(1, 1.0); + | ^^^ ---- help: remove this type argument + | | + | expected 1 type argument + | +note: associated function defined here, with 1 type parameter: `U` + --> $DIR/bad-mid-path-type-params.rs:6:8 + | +LL | fn new<U>(x: T, _: U) -> S<T> { + | ^^^ - + +error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/bad-mid-path-type-params.rs:33:13 + | +LL | let _ = S::<'a,isize>::new::<f64>(1, 1.0); + | ^ --- help: remove this lifetime argument + | | + | expected 0 lifetime arguments + | +note: struct defined here, with 0 lifetime parameters + --> $DIR/bad-mid-path-type-params.rs:1:8 + | +LL | struct S<T> { + | ^ + +error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied + --> $DIR/bad-mid-path-type-params.rs:36:24 + | +LL | let _: S2 = Trait::new::<isize,f64>(1, 1.0); + | ^^^ ---- help: remove this type argument + | | + | expected 1 type argument + | +note: associated function defined here, with 1 type parameter: `U` + --> $DIR/bad-mid-path-type-params.rs:14:8 + | +LL | fn new<U>(x: T, y: U) -> Self; + | ^^^ - + +error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/bad-mid-path-type-params.rs:39:17 + | +LL | let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0); + | ^^^^^ --- help: remove this lifetime argument + | | + | expected 0 lifetime arguments + | +note: trait defined here, with 0 lifetime parameters + --> $DIR/bad-mid-path-type-params.rs:13:7 + | +LL | trait Trait<T> { + | ^^^^^ + +error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied + --> $DIR/bad-mid-path-type-params.rs:39:36 + | +LL | let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0); + | ^^^ ---- help: remove this type argument + | | + | expected 1 type argument + | +note: associated function defined here, with 1 type parameter: `U` + --> $DIR/bad-mid-path-type-params.rs:14:8 + | +LL | fn new<U>(x: T, y: U) -> Self; + | ^^^ - + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0107`. |
