Update tests

Update the tests to reflect changes to how type mismatch errors are
reported (two previous commits).
This commit is contained in:
Dmitry Kadashev 2019-11-01 10:58:37 +07:00
parent 036f182804
commit 4e10b75951
19 changed files with 116 additions and 40 deletions

View File

@ -4,8 +4,11 @@ error[E0271]: type mismatch resolving `<Adapter<I> as Iterator>::Item == std::op
LL | fn is_iterator_of<A, I: Iterator<Item=A>>(_: &I) {}
| -------------- ------ required by this bound in `is_iterator_of`
...
LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
| - this type parameter
...
LL | is_iterator_of::<Option<T>, _>(&adapter);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found type parameter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found type parameter `T`
|
= note: expected type `std::option::Option<T>`
found type `T`

View File

@ -5,7 +5,10 @@ LL | fn b<C:Clone,D>(&self, x: C) -> C;
| - type in trait
...
LL | fn b<F:Clone,G>(&self, _x: G) -> G { panic!() }
| ^ expected type parameter, found a different type parameter
| - - ^ expected type parameter `F`, found type parameter `G`
| | |
| | found type parameter
| expected type parameter
|
= note: expected type `fn(&E, F) -> F`
found type `fn(&E, G) -> G`

View File

@ -5,7 +5,11 @@ LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug);
| -- type in trait
...
LL | fn foo<B: Debug>(&self, a: &impl Debug, b: &B) { }
| ^^^^^^^^^^^ expected type parameter, found a different type parameter
| - ^----------
| | ||
| | |found type parameter
| | expected type parameter `B`, found type parameter `impl Debug`
| expected type parameter
|
= note: expected type `fn(&(), &B, &impl Debug)`
found type `fn(&(), &impl Debug, &B)`

View File

@ -2,9 +2,11 @@ error[E0308]: mismatched types
--> $DIR/universal-mismatched-type.rs:4:5
|
LL | fn foo(x: impl Debug) -> String {
| ------ expected `std::string::String` because of return type
| ---------- ------ expected `std::string::String` because of return type
| |
| this type parameter
LL | x
| ^ expected struct `std::string::String`, found type parameter
| ^ expected struct `std::string::String`, found type parameter `impl Debug`
|
= note: expected type `std::string::String`
found type `impl Debug`

View File

@ -1,11 +1,16 @@
error[E0308]: mismatched types
--> $DIR/universal-two-impl-traits.rs:5:9
|
LL | fn foo(x: impl Debug, y: impl Debug) -> String {
| ---------- ---------- found type parameter
| |
| expected type parameter
LL | let mut a = x;
LL | a = y;
| ^ expected type parameter, found a different type parameter
| ^ expected type parameter `impl Debug`, found a different type parameter `impl Debug`
|
= note: expected type `impl Debug` (type parameter)
found type `impl Debug` (type parameter)
= note: expected type `impl Debug` (type parameter `impl Debug`)
found type `impl Debug` (type parameter `impl Debug`)
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters

View File

@ -2,10 +2,10 @@ error[E0308]: mismatched types
--> $DIR/issue-13853.rs:14:9
|
LL | fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
| - expected `I` because of return type
| - this type parameter - expected `I` because of return type
...
LL | self.iter()
| ^^^^^^^^^^^ expected type parameter, found struct `std::slice::Iter`
| ^^^^^^^^^^^ expected type parameter `I`, found struct `std::slice::Iter`
|
= note: expected type `I`
found type `std::slice::Iter<'_, N>`

View File

@ -1,8 +1,10 @@
error[E0053]: method `call` has an incompatible type for trait
--> $DIR/issue-20225.rs:6:3
|
LL | impl<'a, T> Fn<(&'a T,)> for Foo {
| - this type parameter
LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter `T`
|
= note: expected type `extern "rust-call" fn(&Foo, (&'a T,))`
found type `extern "rust-call" fn(&Foo, (T,))`
@ -12,8 +14,10 @@ LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
error[E0053]: method `call_mut` has an incompatible type for trait
--> $DIR/issue-20225.rs:12:3
|
LL | impl<'a, T> FnMut<(&'a T,)> for Foo {
| - this type parameter
LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter `T`
|
= note: expected type `extern "rust-call" fn(&mut Foo, (&'a T,))`
found type `extern "rust-call" fn(&mut Foo, (T,))`
@ -23,8 +27,11 @@ LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
error[E0053]: method `call_once` has an incompatible type for trait
--> $DIR/issue-20225.rs:20:3
|
LL | impl<'a, T> FnOnce<(&'a T,)> for Foo {
| - this type parameter
...
LL | extern "rust-call" fn call_once(self, (_,): (T,)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter `T`
|
= note: expected type `extern "rust-call" fn(Foo, (&'a T,))`
found type `extern "rust-call" fn(Foo, (T,))`

View File

@ -5,7 +5,7 @@ LL | trait Trait: Sized {
| ------------------ required by `Trait`
...
LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found associated type
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
|
= note: expected type `T`
found type `<<T as Trait>::A as MultiDispatch<i32>>::O`

View File

@ -4,7 +4,7 @@ fn foo<T, U>(x: T, y: U) {
//~^ ERROR mismatched types
//~| expected type `T`
//~| found type `U`
//~| expected type parameter, found a different type parameter
//~| expected type parameter `T`, found type parameter `U`
}
fn main() {

View File

@ -1,8 +1,13 @@
error[E0308]: mismatched types
--> $DIR/issue-2951.rs:3:10
|
LL | fn foo<T, U>(x: T, y: U) {
| - - found type parameter
| |
| expected type parameter
LL | let mut xx = x;
LL | xx = y;
| ^ expected type parameter, found a different type parameter
| ^ expected type parameter `T`, found type parameter `U`
|
= note: expected type `T`
found type `U`

View File

@ -1,10 +1,13 @@
error[E0308]: mismatched types
--> $DIR/issue-35030.rs:9:14
|
LL | impl<bool> Parser<bool> for bool {
| ---- this type parameter
LL | fn parse(text: &str) -> Option<bool> {
LL | Some(true)
| ^^^^ expected type parameter, found bool
| ^^^^ expected type parameter `bool`, found bool
|
= note: expected type `bool` (type parameter)
= note: expected type `bool` (type parameter `bool`)
found type `bool` (bool)
= help: type parameters must be constrained to match other types
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters

View File

@ -7,8 +7,13 @@ LL | Self { inner: 1.5f32 };
error[E0308]: mismatched types
--> $DIR/struct-path-self-type-mismatch.rs:15:20
|
LL | impl<T> Foo<T> {
| - expected type parameter
LL | fn new<U>(u: U) -> Foo<U> {
| - found type parameter
...
LL | inner: u
| ^ expected type parameter, found a different type parameter
| ^ expected type parameter `T`, found type parameter `U`
|
= note: expected type `T`
found type `U`
@ -18,14 +23,18 @@ LL | inner: u
error[E0308]: mismatched types
--> $DIR/struct-path-self-type-mismatch.rs:13:9
|
LL | impl<T> Foo<T> {
| - found type parameter
LL | fn new<U>(u: U) -> Foo<U> {
| ------ expected `Foo<U>` because of return type
| - ------ expected `Foo<U>` because of return type
| |
| expected type parameter
LL | / Self {
LL | |
LL | | inner: u
LL | |
LL | | }
| |_________^ expected type parameter, found a different type parameter
| |_________^ expected type parameter `U`, found type parameter `T`
|
= note: expected type `Foo<U>`
found type `Foo<T>`

View File

@ -1,4 +1,4 @@
error[E0071]: expected struct, variant or union type, found type parameter
error[E0071]: expected struct, variant or union type, found type parameter `Self`
--> $DIR/struct-path-self.rs:5:17
|
LL | let s = Self {};
@ -10,13 +10,13 @@ error[E0109]: type arguments are not allowed for this type
LL | let z = Self::<u8> {};
| ^^ type argument not allowed
error[E0071]: expected struct, variant or union type, found type parameter
error[E0071]: expected struct, variant or union type, found type parameter `Self`
--> $DIR/struct-path-self.rs:7:17
|
LL | let z = Self::<u8> {};
| ^^^^^^^^^^ not a struct
error[E0071]: expected struct, variant or union type, found type parameter
error[E0071]: expected struct, variant or union type, found type parameter `Self`
--> $DIR/struct-path-self.rs:11:13
|
LL | Self { .. } => {}

View File

@ -1,8 +1,11 @@
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:13:25
|
LL | impl<T> Enum<T> {
| - this type parameter
LL | fn ts_variant() {
LL | Self::TSVariant(());
| ^^ expected type parameter, found ()
| ^^ expected type parameter `T`, found ()
|
= note: expected type `T`
found type `()`
@ -24,8 +27,11 @@ LL | Self::<()>::TSVariant(());
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:17:31
|
LL | impl<T> Enum<T> {
| - this type parameter
...
LL | Self::<()>::TSVariant(());
| ^^ expected type parameter, found ()
| ^^ expected type parameter `T`, found ()
|
= note: expected type `T`
found type `()`
@ -47,8 +53,11 @@ LL | Self::<()>::TSVariant::<()>(());
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:26:29
|
LL | impl<T> Enum<T> {
| - this type parameter
...
LL | Self::SVariant { v: () };
| ^^ expected type parameter, found ()
| ^^ expected type parameter `T`, found ()
|
= note: expected type `T`
found type `()`
@ -64,8 +73,11 @@ LL | Self::SVariant::<()> { v: () };
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:28:35
|
LL | impl<T> Enum<T> {
| - this type parameter
...
LL | Self::SVariant::<()> { v: () };
| ^^ expected type parameter, found ()
| ^^ expected type parameter `T`, found ()
|
= note: expected type `T`
found type `()`
@ -81,8 +93,11 @@ LL | Self::<()>::SVariant { v: () };
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:31:35
|
LL | impl<T> Enum<T> {
| - this type parameter
...
LL | Self::<()>::SVariant { v: () };
| ^^ expected type parameter, found ()
| ^^ expected type parameter `T`, found ()
|
= note: expected type `T`
found type `()`
@ -104,8 +119,11 @@ LL | Self::<()>::SVariant::<()> { v: () };
error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:34:41
|
LL | impl<T> Enum<T> {
| - this type parameter
...
LL | Self::<()>::SVariant::<()> { v: () };
| ^^ expected type parameter, found ()
| ^^ expected type parameter `T`, found ()
|
= note: expected type `T`
found type `()`

View File

@ -6,7 +6,7 @@ fn foo<Foo, Bar>(x: Foo) -> Bar {
//~^ ERROR mismatched types
//~| expected type `Bar`
//~| found type `Foo`
//~| expected type parameter, found a different type parameter
//~| expected type parameter `Bar`, found type parameter `Foo`
}
fn main() {}

View File

@ -2,9 +2,12 @@ error[E0308]: mismatched types
--> $DIR/type-parameter-names.rs:5:5
|
LL | fn foo<Foo, Bar>(x: Foo) -> Bar {
| --- expected `Bar` because of return type
| --- --- --- expected `Bar` because of return type
| | |
| | expected type parameter
| found type parameter
LL | x
| ^ expected type parameter, found a different type parameter
| ^ expected type parameter `Bar`, found type parameter `Foo`
|
= note: expected type `Bar`
found type `Foo`

View File

@ -5,7 +5,7 @@ trait BrokenAdd: Copy + Add<Output=Self> {
*self + rhs //~ ERROR mismatched types
//~| expected type `Self`
//~| found type `T`
//~| expected type parameter, found a different type parameter
//~| expected type parameter `Self`, found type parameter `T`
}
}

View File

@ -1,8 +1,16 @@
error[E0308]: mismatched types
--> $DIR/type-params-in-different-spaces-1.rs:5:17
|
LL | *self + rhs
| ^^^ expected type parameter, found a different type parameter
LL | / trait BrokenAdd: Copy + Add<Output=Self> {
LL | | fn broken_add<T>(&self, rhs: T) -> Self {
| | - found type parameter
LL | | *self + rhs
| | ^^^ expected type parameter `Self`, found type parameter `T`
LL | |
... |
LL | | }
LL | | }
| |_- expected type parameter
|
= note: expected type `Self`
found type `T`

View File

@ -1,10 +1,16 @@
error[E0308]: mismatched types
--> $DIR/type-params-in-different-spaces-3.rs:3:9
|
LL | fn test<X>(u: X) -> Self {
| ---- expected `Self` because of return type
LL | u
| ^ expected type parameter, found a different type parameter
LL | / trait Tr : Sized {
LL | | fn test<X>(u: X) -> Self {
| | - ---- expected `Self` because of return type
| | |
| | found type parameter
LL | | u
| | ^ expected type parameter `Self`, found type parameter `X`
LL | | }
LL | | }
| |_- expected type parameter
|
= note: expected type `Self`
found type `X`