From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/type/issue-91268.rs | 4 - tests/ui/type/issue-91268.stderr | 55 +------------ .../type-ascription-instead-of-initializer.stderr | 9 +-- tests/ui/type/type-ascription-precedence.stderr | 12 +-- tests/ui/type/type-ascription-soundness.stderr | 8 +- tests/ui/type/type-check/assignment-in-if.stderr | 9 +++ .../type-check/cannot_infer_local_or_vec.stderr | 6 +- .../cannot_infer_local_or_vec_in_tuples.stderr | 6 +- .../type-check/coerce-result-return-value-2.rs | 24 ++++++ .../type-check/coerce-result-return-value-2.stderr | 47 +++++++++++ .../type-check/coerce-result-return-value.fixed | 24 ++++++ .../type/type-check/coerce-result-return-value.rs | 24 ++++++ .../type-check/coerce-result-return-value.stderr | 65 +++++++++++++++ .../ui/type/type-check/point-at-inference-2.stderr | 11 ++- .../ui/type/type-check/point-at-inference-3.fixed | 3 +- tests/ui/type/type-check/point-at-inference-3.rs | 3 +- .../ui/type/type-check/point-at-inference-3.stderr | 7 +- tests/ui/type/type-check/point-at-inference-4.rs | 21 +++++ .../ui/type/type-check/point-at-inference-4.stderr | 31 +++++++ tests/ui/type/type-check/point-at-inference.fixed | 13 +++ tests/ui/type/type-check/point-at-inference.rs | 1 + tests/ui/type/type-check/point-at-inference.stderr | 13 ++- tests/ui/type/type-mismatch-same-crate-name.rs | 2 +- tests/ui/type/type-mismatch-same-crate-name.stderr | 8 +- tests/ui/type/type-mismatch.stderr | 94 +++++++++++----------- ...rong-call-return-type-due-to-generic-arg.stderr | 2 +- 26 files changed, 361 insertions(+), 141 deletions(-) create mode 100644 tests/ui/type/type-check/coerce-result-return-value-2.rs create mode 100644 tests/ui/type/type-check/coerce-result-return-value-2.stderr create mode 100644 tests/ui/type/type-check/coerce-result-return-value.fixed create mode 100644 tests/ui/type/type-check/coerce-result-return-value.rs create mode 100644 tests/ui/type/type-check/coerce-result-return-value.stderr create mode 100644 tests/ui/type/type-check/point-at-inference-4.rs create mode 100644 tests/ui/type/type-check/point-at-inference-4.stderr create mode 100644 tests/ui/type/type-check/point-at-inference.fixed (limited to 'tests/ui/type') diff --git a/tests/ui/type/issue-91268.rs b/tests/ui/type/issue-91268.rs index f1e16bc7b..274ea839e 100644 --- a/tests/ui/type/issue-91268.rs +++ b/tests/ui/type/issue-91268.rs @@ -1,8 +1,4 @@ // error-pattern: this file contains an unclosed delimiter -// error-pattern: cannot find type `ţ` in this scope -// error-pattern: parenthesized type parameters may only be used with a `Fn` trait -// error-pattern: type arguments are not allowed on builtin type `u8` -// error-pattern: mismatched types // ignore-tidy-trailing-newlines // `ţ` must be the last character in this file, it cannot be followed by a newline fn main() { diff --git a/tests/ui/type/issue-91268.stderr b/tests/ui/type/issue-91268.stderr index 6c9ee9945..a3619d863 100644 --- a/tests/ui/type/issue-91268.stderr +++ b/tests/ui/type/issue-91268.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/issue-91268.rs:9:12 + --> $DIR/issue-91268.rs:5:12 | LL | fn main() { | - unclosed delimiter @@ -8,56 +8,5 @@ LL | 0: u8(ţ | | | unclosed delimiter -error: this file contains an unclosed delimiter - --> $DIR/issue-91268.rs:9:12 - | -LL | fn main() { - | - unclosed delimiter -LL | 0: u8(ţ - | - ^ - | | - | unclosed delimiter - -error[E0412]: cannot find type `ţ` in this scope - --> $DIR/issue-91268.rs:9:11 - | -LL | 0: u8(ţ - | ^ expecting a type here because of type ascription - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-91268.rs:9:8 - | -LL | 0: u8(ţ - | ^^^^ only `Fn` traits may use parentheses - | -help: use angle brackets instead - | -LL | 0: u8<ţ> - | ~ + - -error[E0109]: type arguments are not allowed on builtin type `u8` - --> $DIR/issue-91268.rs:9:11 - | -LL | 0: u8(ţ - | -- ^ type argument not allowed - | | - | not allowed on builtin type `u8` - | -help: primitive type `u8` doesn't have generic parameters - | -LL - 0: u8(ţ -LL + 0: u8 - | - -error[E0308]: mismatched types - --> $DIR/issue-91268.rs:9:5 - | -LL | fn main() { - | - expected `()` because of default return type -LL | 0: u8(ţ - | ^^^^^^^ expected `()`, found `u8` - -error: aborting due to 6 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0109, E0214, E0308, E0412. -For more information about an error, try `rustc --explain E0109`. diff --git a/tests/ui/type/type-ascription-instead-of-initializer.stderr b/tests/ui/type/type-ascription-instead-of-initializer.stderr index ba8d15d0b..429501c27 100644 --- a/tests/ui/type/type-ascription-instead-of-initializer.stderr +++ b/tests/ui/type/type-ascription-instead-of-initializer.stderr @@ -11,14 +11,13 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/type-ascription-instead-of-initializer.rs:2:12 | LL | let x: Vec::with_capacity(10, 20); - | ^^^^^^^^^^^^^^^^^^ -- argument of type `{integer}` unexpected + | ^^^^^^^^^^^^^^^^^^ ---- + | | | + | | unexpected argument of type `{integer}` + | help: remove the extra argument | note: associated function defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -help: remove the extra argument - | -LL | let x: Vec::with_capacity(10); - | ~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/type/type-ascription-precedence.stderr b/tests/ui/type/type-ascription-precedence.stderr index edc5aeffd..d6d1e1d7d 100644 --- a/tests/ui/type/type-ascription-precedence.stderr +++ b/tests/ui/type/type-ascription-precedence.stderr @@ -2,13 +2,13 @@ error[E0308]: mismatched types --> $DIR/type-ascription-precedence.rs:31:7 | LL | &(S: &S); - | ^ expected `&S`, found struct `S` + | ^ expected `&S`, found `S` error[E0308]: mismatched types --> $DIR/type-ascription-precedence.rs:35:7 | LL | *(S: Z); - | ^ expected struct `Z`, found struct `S` + | ^ expected `Z`, found `S` error[E0614]: type `Z` cannot be dereferenced --> $DIR/type-ascription-precedence.rs:35:5 @@ -20,7 +20,7 @@ error[E0308]: mismatched types --> $DIR/type-ascription-precedence.rs:40:7 | LL | -(S: Z); - | ^ expected struct `Z`, found struct `S` + | ^ expected `Z`, found `S` error[E0600]: cannot apply unary operator `-` to type `Z` --> $DIR/type-ascription-precedence.rs:40:5 @@ -40,19 +40,19 @@ error[E0308]: mismatched types --> $DIR/type-ascription-precedence.rs:45:5 | LL | (S + Z): Z; - | ^^^^^^^ expected struct `Z`, found struct `S` + | ^^^^^^^ expected `Z`, found `S` error[E0308]: mismatched types --> $DIR/type-ascription-precedence.rs:49:5 | LL | (S * Z): Z; - | ^^^^^^^ expected struct `Z`, found struct `S` + | ^^^^^^^ expected `Z`, found `S` error[E0308]: mismatched types --> $DIR/type-ascription-precedence.rs:53:5 | LL | (S .. S): S; - | ^^^^^^^^ expected struct `S`, found struct `Range` + | ^^^^^^^^ expected `S`, found `Range` | = note: expected struct `S` found struct `std::ops::Range` diff --git a/tests/ui/type/type-ascription-soundness.stderr b/tests/ui/type/type-ascription-soundness.stderr index 522d5b2e3..778836a2e 100644 --- a/tests/ui/type/type-ascription-soundness.stderr +++ b/tests/ui/type/type-ascription-soundness.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/type-ascription-soundness.rs:7:31 | LL | let ref x = type_ascribe!(arr, &[u8]); - | ^^^ expected slice `[u8]`, found array `[u8; 3]` + | ^^^ expected `&[u8]`, found `&[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` @@ -11,7 +11,7 @@ error[E0308]: mismatched types --> $DIR/type-ascription-soundness.rs:8:35 | LL | let ref mut x = type_ascribe!(arr, &[u8]); - | ^^^ expected slice `[u8]`, found array `[u8; 3]` + | ^^^ expected `&[u8]`, found `&[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` @@ -20,7 +20,7 @@ error[E0308]: mismatched types --> $DIR/type-ascription-soundness.rs:9:25 | LL | match type_ascribe!(arr, &[u8]) { - | ^^^ expected slice `[u8]`, found array `[u8; 3]` + | ^^^ expected `&[u8]`, found `&[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` @@ -29,7 +29,7 @@ error[E0308]: mismatched types --> $DIR/type-ascription-soundness.rs:12:30 | LL | let _len = type_ascribe!(arr, &[u8]).len(); - | ^^^ expected slice `[u8]`, found array `[u8; 3]` + | ^^^ expected `&[u8]`, found `&[u8; 3]` | = note: expected reference `&[u8]` found reference `&[u8; 3]` diff --git a/tests/ui/type/type-check/assignment-in-if.stderr b/tests/ui/type/type-check/assignment-in-if.stderr index 9f4558ada..de133e559 100644 --- a/tests/ui/type/type-check/assignment-in-if.stderr +++ b/tests/ui/type/type-check/assignment-in-if.stderr @@ -67,6 +67,9 @@ LL | x == 5 error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:44:18 | +LL | if y = (Foo { foo: x }) { + | - here the type of `x` is inferred to be `usize` +... LL | if x == x && x = x && x == x { | ------ ^ expected `bool`, found `usize` | | @@ -75,6 +78,9 @@ LL | if x == x && x = x && x == x { error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:44:22 | +LL | if y = (Foo { foo: x }) { + | - here the type of `x` is inferred to be `usize` +... LL | if x == x && x = x && x == x { | ^ expected `bool`, found `usize` @@ -92,6 +98,9 @@ LL | if x == x && x == x && x == x { error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:51:28 | +LL | if y = (Foo { foo: x }) { + | - here the type of `x` is inferred to be `usize` +... LL | if x == x && x == x && x = x { | ---------------- ^ expected `bool`, found `usize` | | diff --git a/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr b/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr index b63d2a3b6..09c4b2053 100644 --- a/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr +++ b/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr @@ -1,12 +1,12 @@ -error[E0282]: type annotations needed for `Vec` +error[E0282]: type annotations needed for `Vec<_>` --> $DIR/cannot_infer_local_or_vec.rs:2:9 | LL | let x = vec![]; | ^ | -help: consider giving `x` an explicit type, where the type for type parameter `T` is specified +help: consider giving `x` an explicit type, where the placeholders `_` are specified | -LL | let x: Vec = vec![]; +LL | let x: Vec<_> = vec![]; | ++++++++ error: aborting due to previous error diff --git a/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr index e544b3695..1fa253052 100644 --- a/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -1,12 +1,12 @@ -error[E0282]: type annotations needed for `(Vec,)` +error[E0282]: type annotations needed for `(Vec<_>,)` --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:9 | LL | let (x, ) = (vec![], ); | ^^^^^ ---------- type must be known at this point | -help: consider giving this pattern a type, where the type for type parameter `T` is specified +help: consider giving this pattern a type, where the placeholders `_` are specified | -LL | let (x, ): (Vec,) = (vec![], ); +LL | let (x, ): (Vec<_>,) = (vec![], ); | +++++++++++ error: aborting due to previous error diff --git a/tests/ui/type/type-check/coerce-result-return-value-2.rs b/tests/ui/type/type-check/coerce-result-return-value-2.rs new file mode 100644 index 000000000..23bafa6c5 --- /dev/null +++ b/tests/ui/type/type-check/coerce-result-return-value-2.rs @@ -0,0 +1,24 @@ +struct A; +struct B; +impl From for B { + fn from(_: A) -> Self { B } +} +fn foo4(x: Result<(), A>) -> Result<(), B> { + match true { + true => x, //~ ERROR mismatched types + false => x, + } +} +fn foo5(x: Result<(), A>) -> Result<(), B> { + match true { + true => return x, //~ ERROR mismatched types + false => return x, + } +} +fn main() { + let _ = foo4(Ok(())); + let _ = foo5(Ok(())); + let _: Result<(), B> = { //~ ERROR mismatched types + Err(A); + }; +} diff --git a/tests/ui/type/type-check/coerce-result-return-value-2.stderr b/tests/ui/type/type-check/coerce-result-return-value-2.stderr new file mode 100644 index 000000000..b2c409e07 --- /dev/null +++ b/tests/ui/type/type-check/coerce-result-return-value-2.stderr @@ -0,0 +1,47 @@ +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value-2.rs:8:17 + | +LL | fn foo4(x: Result<(), A>) -> Result<(), B> { + | ------------- expected `Result<(), B>` because of return type +LL | match true { +LL | true => x, + | ^ expected `Result<(), B>`, found `Result<(), A>` + | + = note: expected enum `Result<_, B>` + found enum `Result<_, A>` +help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result` + | +LL | true => Ok(x?), + | +++ ++ + +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value-2.rs:14:24 + | +LL | fn foo5(x: Result<(), A>) -> Result<(), B> { + | ------------- expected `Result<(), B>` because of return type +LL | match true { +LL | true => return x, + | ^ expected `Result<(), B>`, found `Result<(), A>` + | + = note: expected enum `Result<_, B>` + found enum `Result<_, A>` +help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result` + | +LL | true => return Ok(x?), + | +++ ++ + +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value-2.rs:21:28 + | +LL | let _: Result<(), B> = { + | ____________________________^ +LL | | Err(A); +LL | | }; + | |_____^ expected `Result<(), B>`, found `()` + | + = note: expected enum `Result<(), B>` + found unit type `()` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type/type-check/coerce-result-return-value.fixed b/tests/ui/type/type-check/coerce-result-return-value.fixed new file mode 100644 index 000000000..8a0540707 --- /dev/null +++ b/tests/ui/type/type-check/coerce-result-return-value.fixed @@ -0,0 +1,24 @@ +// run-rustfix +struct A; +struct B; +impl From for B { + fn from(_: A) -> Self { B } +} +fn foo1(x: Result<(), A>) -> Result<(), B> { + Ok(x?) //~ ERROR mismatched types +} +fn foo2(x: Result<(), A>) -> Result<(), B> { + return Ok(x?); //~ ERROR mismatched types +} +fn foo3(x: Result<(), A>) -> Result<(), B> { + if true { + Ok(x?) //~ ERROR mismatched types + } else { + Ok(x?) //~ ERROR mismatched types + } +} +fn main() { + let _ = foo1(Ok(())); + let _ = foo2(Ok(())); + let _ = foo3(Ok(())); +} diff --git a/tests/ui/type/type-check/coerce-result-return-value.rs b/tests/ui/type/type-check/coerce-result-return-value.rs new file mode 100644 index 000000000..442203add --- /dev/null +++ b/tests/ui/type/type-check/coerce-result-return-value.rs @@ -0,0 +1,24 @@ +// run-rustfix +struct A; +struct B; +impl From for B { + fn from(_: A) -> Self { B } +} +fn foo1(x: Result<(), A>) -> Result<(), B> { + x //~ ERROR mismatched types +} +fn foo2(x: Result<(), A>) -> Result<(), B> { + return x; //~ ERROR mismatched types +} +fn foo3(x: Result<(), A>) -> Result<(), B> { + if true { + x //~ ERROR mismatched types + } else { + x //~ ERROR mismatched types + } +} +fn main() { + let _ = foo1(Ok(())); + let _ = foo2(Ok(())); + let _ = foo3(Ok(())); +} diff --git a/tests/ui/type/type-check/coerce-result-return-value.stderr b/tests/ui/type/type-check/coerce-result-return-value.stderr new file mode 100644 index 000000000..adec2f612 --- /dev/null +++ b/tests/ui/type/type-check/coerce-result-return-value.stderr @@ -0,0 +1,65 @@ +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value.rs:8:5 + | +LL | fn foo1(x: Result<(), A>) -> Result<(), B> { + | ------------- expected `Result<(), B>` because of return type +LL | x + | ^ expected `Result<(), B>`, found `Result<(), A>` + | + = note: expected enum `Result<_, B>` + found enum `Result<_, A>` +help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result` + | +LL | Ok(x?) + | +++ ++ + +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value.rs:11:12 + | +LL | fn foo2(x: Result<(), A>) -> Result<(), B> { + | ------------- expected `Result<(), B>` because of return type +LL | return x; + | ^ expected `Result<(), B>`, found `Result<(), A>` + | + = note: expected enum `Result<_, B>` + found enum `Result<_, A>` +help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result` + | +LL | return Ok(x?); + | +++ ++ + +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value.rs:15:9 + | +LL | fn foo3(x: Result<(), A>) -> Result<(), B> { + | ------------- expected `Result<(), B>` because of return type +LL | if true { +LL | x + | ^ expected `Result<(), B>`, found `Result<(), A>` + | + = note: expected enum `Result<_, B>` + found enum `Result<_, A>` +help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result` + | +LL | Ok(x?) + | +++ ++ + +error[E0308]: mismatched types + --> $DIR/coerce-result-return-value.rs:17:9 + | +LL | fn foo3(x: Result<(), A>) -> Result<(), B> { + | ------------- expected `Result<(), B>` because of return type +... +LL | x + | ^ expected `Result<(), B>`, found `Result<(), A>` + | + = note: expected enum `Result<_, B>` + found enum `Result<_, A>` +help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result` + | +LL | Ok(x?) + | +++ ++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type/type-check/point-at-inference-2.stderr b/tests/ui/type/type-check/point-at-inference-2.stderr index 1368aba0d..1d2777ad6 100644 --- a/tests/ui/type/type-check/point-at-inference-2.stderr +++ b/tests/ui/type/type-check/point-at-inference-2.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/point-at-inference-2.rs:5:9 | LL | bar(v); - | --- ^ expected `i32`, found `&{integer}` + | --- ^ expected `Vec`, found `Vec<&{integer}>` | | | arguments to this function are incorrect | @@ -17,8 +17,11 @@ LL | fn bar(_: Vec) {} error[E0308]: mismatched types --> $DIR/point-at-inference-2.rs:9:9 | +LL | baz(&v); + | - here the type of `v` is inferred to be `Vec<&i32>` +LL | baz(&v); LL | bar(v); - | --- ^ expected `i32`, found `&i32` + | --- ^ expected `Vec`, found `Vec<&i32>` | | | arguments to this function are incorrect | @@ -33,8 +36,10 @@ LL | fn bar(_: Vec) {} error[E0308]: mismatched types --> $DIR/point-at-inference-2.rs:12:9 | +LL | baz(&v); + | - here the type of `v` is inferred to be `Vec<&i32>` LL | bar(v); - | --- ^ expected `i32`, found `&i32` + | --- ^ expected `Vec`, found `Vec<&i32>` | | | arguments to this function are incorrect | diff --git a/tests/ui/type/type-check/point-at-inference-3.fixed b/tests/ui/type/type-check/point-at-inference-3.fixed index 44c057c0d..edd4adf8b 100644 --- a/tests/ui/type/type-check/point-at-inference-3.fixed +++ b/tests/ui/type/type-check/point-at-inference-3.fixed @@ -2,10 +2,11 @@ fn main() { let mut v = Vec::new(); v.push(0i32); + //~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec` v.push(0); v.push(1i32); //~ ERROR mismatched types //~^ NOTE expected `i32`, found `u32` //~| NOTE arguments to this method are incorrect - //~| NOTE associated function defined here + //~| NOTE method defined here //~| HELP change the type of the numeric literal from `u32` to `i32` } diff --git a/tests/ui/type/type-check/point-at-inference-3.rs b/tests/ui/type/type-check/point-at-inference-3.rs index e7ae54384..49d7b5007 100644 --- a/tests/ui/type/type-check/point-at-inference-3.rs +++ b/tests/ui/type/type-check/point-at-inference-3.rs @@ -2,10 +2,11 @@ fn main() { let mut v = Vec::new(); v.push(0i32); + //~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec` v.push(0); v.push(1u32); //~ ERROR mismatched types //~^ NOTE expected `i32`, found `u32` //~| NOTE arguments to this method are incorrect - //~| NOTE associated function defined here + //~| NOTE method defined here //~| HELP change the type of the numeric literal from `u32` to `i32` } diff --git a/tests/ui/type/type-check/point-at-inference-3.stderr b/tests/ui/type/type-check/point-at-inference-3.stderr index d7936e39c..2c4907ed2 100644 --- a/tests/ui/type/type-check/point-at-inference-3.stderr +++ b/tests/ui/type/type-check/point-at-inference-3.stderr @@ -1,12 +1,15 @@ error[E0308]: mismatched types - --> $DIR/point-at-inference-3.rs:6:12 + --> $DIR/point-at-inference-3.rs:7:12 | +LL | v.push(0i32); + | ---- this is of type `i32`, which causes `v` to be inferred as `Vec` +... LL | v.push(1u32); | ---- ^^^^ expected `i32`, found `u32` | | | arguments to this method are incorrect | -note: associated function defined here +note: method defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: change the type of the numeric literal from `u32` to `i32` | diff --git a/tests/ui/type/type-check/point-at-inference-4.rs b/tests/ui/type/type-check/point-at-inference-4.rs new file mode 100644 index 000000000..aea9b2c6c --- /dev/null +++ b/tests/ui/type/type-check/point-at-inference-4.rs @@ -0,0 +1,21 @@ +struct S(Option<(A, B)>); + +impl S { + fn infer(&self, a: A, b: B) {} + //~^ NOTE method defined here + //~| NOTE + //~| NOTE +} + +fn main() { + let s = S(None); + s.infer(0i32); + //~^ ERROR this method takes 2 arguments but 1 argument was supplied + //~| NOTE an argument is missing + //~| HELP provide the argument + let t: S = s; + //~^ ERROR mismatched types + //~| NOTE expected `S`, found `S` + //~| NOTE expected due to this + //~| NOTE expected struct `S` +} diff --git a/tests/ui/type/type-check/point-at-inference-4.stderr b/tests/ui/type/type-check/point-at-inference-4.stderr new file mode 100644 index 000000000..28833d2ed --- /dev/null +++ b/tests/ui/type/type-check/point-at-inference-4.stderr @@ -0,0 +1,31 @@ +error[E0061]: this method takes 2 arguments but 1 argument was supplied + --> $DIR/point-at-inference-4.rs:12:7 + | +LL | s.infer(0i32); + | ^^^^^------ an argument is missing + | +note: method defined here + --> $DIR/point-at-inference-4.rs:4:8 + | +LL | fn infer(&self, a: A, b: B) {} + | ^^^^^ ---- ---- +help: provide the argument + | +LL | s.infer(0i32, /* b */); + | ~~~~~~~~~~~~~~~ + +error[E0308]: mismatched types + --> $DIR/point-at-inference-4.rs:16:24 + | +LL | let t: S = s; + | --------- ^ expected `S`, found `S` + | | + | expected due to this + | + = note: expected struct `S` + found struct `S` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0061, E0308. +For more information about an error, try `rustc --explain E0061`. diff --git a/tests/ui/type/type-check/point-at-inference.fixed b/tests/ui/type/type-check/point-at-inference.fixed new file mode 100644 index 000000000..f41fbe59f --- /dev/null +++ b/tests/ui/type/type-check/point-at-inference.fixed @@ -0,0 +1,13 @@ +// run-rustfix +fn bar(_: Vec) {} +fn baz(_: &impl std::any::Any) {} +fn main() { + let v = vec![1, 2, 3, 4, 5]; + let mut foo = vec![]; + baz(&foo); + for i in &v { + foo.push(*i); + } + baz(&foo); + bar(foo); //~ ERROR E0308 +} diff --git a/tests/ui/type/type-check/point-at-inference.rs b/tests/ui/type/type-check/point-at-inference.rs index 5c46dd4ed..6419e42e7 100644 --- a/tests/ui/type/type-check/point-at-inference.rs +++ b/tests/ui/type/type-check/point-at-inference.rs @@ -1,3 +1,4 @@ +// run-rustfix fn bar(_: Vec) {} fn baz(_: &impl std::any::Any) {} fn main() { diff --git a/tests/ui/type/type-check/point-at-inference.stderr b/tests/ui/type/type-check/point-at-inference.stderr index 2e17e5c5f..a76b4f90c 100644 --- a/tests/ui/type/type-check/point-at-inference.stderr +++ b/tests/ui/type/type-check/point-at-inference.stderr @@ -1,18 +1,25 @@ error[E0308]: mismatched types - --> $DIR/point-at-inference.rs:11:9 + --> $DIR/point-at-inference.rs:12:9 | +LL | foo.push(i); + | - this is of type `&{integer}`, which causes `foo` to be inferred as `Vec<&{integer}>` +... LL | bar(foo); - | --- ^^^ expected `i32`, found `&{integer}` + | --- ^^^ expected `Vec`, found `Vec<&{integer}>` | | | arguments to this function are incorrect | = note: expected struct `Vec` found struct `Vec<&{integer}>` note: function defined here - --> $DIR/point-at-inference.rs:1:4 + --> $DIR/point-at-inference.rs:2:4 | LL | fn bar(_: Vec) {} | ^^^ ----------- +help: consider dereferencing the borrow + | +LL | foo.push(*i); + | + error: aborting due to previous error diff --git a/tests/ui/type/type-mismatch-same-crate-name.rs b/tests/ui/type/type-mismatch-same-crate-name.rs index c9cdc874c..2a59bd994 100644 --- a/tests/ui/type/type-mismatch-same-crate-name.rs +++ b/tests/ui/type/type-mismatch-same-crate-name.rs @@ -16,7 +16,7 @@ fn main() { a::try_foo(foo2); //~^ ERROR mismatched types //~| perhaps two different versions of crate `crate_a1` - //~| expected struct `main::a::Foo` + //~| expected `main::a::Foo`, found a different `main::a::Foo` a::try_bar(bar2); //~^ ERROR mismatched types //~| perhaps two different versions of crate `crate_a1` diff --git a/tests/ui/type/type-mismatch-same-crate-name.stderr b/tests/ui/type/type-mismatch-same-crate-name.stderr index fcafd315e..504812f58 100644 --- a/tests/ui/type/type-mismatch-same-crate-name.stderr +++ b/tests/ui/type/type-mismatch-same-crate-name.stderr @@ -2,17 +2,17 @@ error[E0308]: mismatched types --> $DIR/type-mismatch-same-crate-name.rs:16:20 | LL | a::try_foo(foo2); - | ---------- ^^^^ expected struct `main::a::Foo`, found a different struct `main::a::Foo` + | ---------- ^^^^ expected `main::a::Foo`, found a different `main::a::Foo` | | | arguments to this function are incorrect | - = note: struct `main::a::Foo` and struct `main::a::Foo` have similar names, but are actually distinct types -note: struct `main::a::Foo` is defined in crate `crate_a2` + = note: `main::a::Foo` and `main::a::Foo` have similar names, but are actually distinct types +note: `main::a::Foo` is defined in crate `crate_a2` --> $DIR/auxiliary/crate_a2.rs:1:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^ -note: struct `main::a::Foo` is defined in crate `crate_a1` +note: `main::a::Foo` is defined in crate `crate_a1` --> $DIR/auxiliary/crate_a1.rs:1:1 | LL | pub struct Foo; diff --git a/tests/ui/type/type-mismatch.stderr b/tests/ui/type/type-mismatch.stderr index 6c187bad0..67a1f8930 100644 --- a/tests/ui/type/type-mismatch.stderr +++ b/tests/ui/type/type-mismatch.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:17:17 | LL | want::(f); - | ----------- ^ expected struct `foo`, found `usize` + | ----------- ^ expected `foo`, found `usize` | | | arguments to this function are incorrect | @@ -16,7 +16,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:18:17 | LL | want::(f); - | ----------- ^ expected struct `bar`, found `usize` + | ----------- ^ expected `bar`, found `usize` | | | arguments to this function are incorrect | @@ -30,7 +30,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:19:24 | LL | want::>(f); - | ------------------ ^ expected struct `Foo`, found `usize` + | ------------------ ^ expected `Foo`, found `usize` | | | arguments to this function are incorrect | @@ -46,7 +46,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:20:27 | LL | want::>(f); - | --------------------- ^ expected struct `Foo`, found `usize` + | --------------------- ^ expected `Foo`, found `usize` | | | arguments to this function are incorrect | @@ -62,7 +62,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:21:22 | LL | want::>(f); - | ---------------- ^ expected struct `Foo`, found `usize` + | ---------------- ^ expected `Foo`, found `usize` | | | arguments to this function are incorrect | @@ -78,7 +78,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:22:25 | LL | want::>(f); - | ------------------- ^ expected struct `Foo`, found `usize` + | ------------------- ^ expected `Foo`, found `usize` | | | arguments to this function are incorrect | @@ -94,7 +94,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:23:22 | LL | want::>(f); - | ---------------- ^ expected struct `Foo`, found `usize` + | ---------------- ^ expected `Foo`, found `usize` | | | arguments to this function are incorrect | @@ -110,7 +110,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:24:25 | LL | want::>(f); - | ------------------- ^ expected struct `Foo`, found `usize` + | ------------------- ^ expected `Foo`, found `usize` | | | arguments to this function are incorrect | @@ -126,7 +126,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:28:19 | LL | want::(f); - | ------------- ^ expected `usize`, found struct `foo` + | ------------- ^ expected `usize`, found `foo` | | | arguments to this function are incorrect | @@ -140,7 +140,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:29:17 | LL | want::(f); - | ----------- ^ expected struct `bar`, found struct `foo` + | ----------- ^ expected `bar`, found `foo` | | | arguments to this function are incorrect | @@ -154,7 +154,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:30:24 | LL | want::>(f); - | ------------------ ^ expected struct `Foo`, found struct `foo` + | ------------------ ^ expected `Foo`, found `foo` | | | arguments to this function are incorrect | @@ -170,7 +170,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:31:27 | LL | want::>(f); - | --------------------- ^ expected struct `Foo`, found struct `foo` + | --------------------- ^ expected `Foo`, found `foo` | | | arguments to this function are incorrect | @@ -186,7 +186,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:32:22 | LL | want::>(f); - | ---------------- ^ expected struct `Foo`, found struct `foo` + | ---------------- ^ expected `Foo`, found `foo` | | | arguments to this function are incorrect | @@ -202,7 +202,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:33:25 | LL | want::>(f); - | ------------------- ^ expected struct `Foo`, found struct `foo` + | ------------------- ^ expected `Foo`, found `foo` | | | arguments to this function are incorrect | @@ -218,7 +218,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:34:22 | LL | want::>(f); - | ---------------- ^ expected struct `Foo`, found struct `foo` + | ---------------- ^ expected `Foo`, found `foo` | | | arguments to this function are incorrect | @@ -234,7 +234,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:35:25 | LL | want::>(f); - | ------------------- ^ expected struct `Foo`, found struct `foo` + | ------------------- ^ expected `Foo`, found `foo` | | | arguments to this function are incorrect | @@ -250,7 +250,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:39:19 | LL | want::(f); - | ------------- ^ expected `usize`, found struct `Foo` + | ------------- ^ expected `usize`, found `Foo` | | | arguments to this function are incorrect | @@ -266,7 +266,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:40:17 | LL | want::(f); - | ----------- ^ expected struct `foo`, found struct `Foo` + | ----------- ^ expected `foo`, found `Foo` | | | arguments to this function are incorrect | @@ -282,7 +282,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:41:17 | LL | want::(f); - | ----------- ^ expected struct `bar`, found struct `Foo` + | ----------- ^ expected `bar`, found `Foo` | | | arguments to this function are incorrect | @@ -298,7 +298,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:42:24 | LL | want::>(f); - | ------------------ ^ expected `usize`, found struct `foo` + | ------------------ ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -314,7 +314,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:43:27 | LL | want::>(f); - | --------------------- ^ expected `usize`, found struct `foo` + | --------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -330,7 +330,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:44:25 | LL | want::>(f); - | ------------------- ^ expected struct `B`, found struct `A` + | ------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -346,7 +346,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:45:22 | LL | want::>(f); - | ---------------- ^ expected struct `bar`, found struct `foo` + | ---------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -362,7 +362,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:46:25 | LL | want::>(f); - | ------------------- ^ expected struct `bar`, found struct `foo` + | ------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -380,7 +380,7 @@ error[E0308]: mismatched types LL | want::<&Foo>(f); | ----------------- ^ | | | - | | expected `&Foo`, found struct `Foo` + | | expected `&Foo`, found `Foo` | | help: consider borrowing here: `&f` | arguments to this function are incorrect | @@ -396,7 +396,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:48:26 | LL | want::<&Foo>(f); - | -------------------- ^ expected `&Foo`, found struct `Foo` + | -------------------- ^ expected `&Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -412,7 +412,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:52:19 | LL | want::(f); - | ------------- ^ expected `usize`, found struct `Foo` + | ------------- ^ expected `usize`, found `Foo` | | | arguments to this function are incorrect | @@ -428,7 +428,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:53:17 | LL | want::(f); - | ----------- ^ expected struct `foo`, found struct `Foo` + | ----------- ^ expected `foo`, found `Foo` | | | arguments to this function are incorrect | @@ -444,7 +444,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:54:17 | LL | want::(f); - | ----------- ^ expected struct `bar`, found struct `Foo` + | ----------- ^ expected `bar`, found `Foo` | | | arguments to this function are incorrect | @@ -460,7 +460,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:55:24 | LL | want::>(f); - | ------------------ ^ expected `usize`, found struct `foo` + | ------------------ ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -476,7 +476,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:56:27 | LL | want::>(f); - | --------------------- ^ expected `usize`, found struct `foo` + | --------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -492,7 +492,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:57:22 | LL | want::>(f); - | ---------------- ^ expected struct `A`, found struct `B` + | ---------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -508,7 +508,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:58:22 | LL | want::>(f); - | ---------------- ^ expected struct `bar`, found struct `foo` + | ---------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -524,7 +524,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:59:25 | LL | want::>(f); - | ------------------- ^ expected struct `bar`, found struct `foo` + | ------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -540,7 +540,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:60:23 | LL | want::<&Foo>(f); - | ----------------- ^ expected `&Foo`, found struct `Foo` + | ----------------- ^ expected `&Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -558,7 +558,7 @@ error[E0308]: mismatched types LL | want::<&Foo>(f); | -------------------- ^ | | | - | | expected `&Foo`, found struct `Foo` + | | expected `&Foo`, found `Foo` | | help: consider borrowing here: `&f` | arguments to this function are incorrect | @@ -574,7 +574,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:65:19 | LL | want::(f); - | ------------- ^ expected `usize`, found struct `Foo` + | ------------- ^ expected `usize`, found `Foo` | | | arguments to this function are incorrect | @@ -590,7 +590,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:66:17 | LL | want::(f); - | ----------- ^ expected struct `foo`, found struct `Foo` + | ----------- ^ expected `foo`, found `Foo` | | | arguments to this function are incorrect | @@ -606,7 +606,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:67:17 | LL | want::(f); - | ----------- ^ expected struct `bar`, found struct `Foo` + | ----------- ^ expected `bar`, found `Foo` | | | arguments to this function are incorrect | @@ -622,7 +622,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:68:24 | LL | want::>(f); - | ------------------ ^ expected `usize`, found struct `foo` + | ------------------ ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -638,7 +638,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:69:27 | LL | want::>(f); - | --------------------- ^ expected `usize`, found struct `foo` + | --------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -654,7 +654,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:70:22 | LL | want::>(f); - | ---------------- ^ expected struct `A`, found struct `B` + | ---------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -670,7 +670,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:71:25 | LL | want::>(f); - | ------------------- ^ expected struct `B`, found struct `A` + | ------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -686,7 +686,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:72:22 | LL | want::>(f); - | ---------------- ^ expected struct `bar`, found struct `foo` + | ---------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -702,7 +702,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:73:25 | LL | want::>(f); - | ------------------- ^ expected struct `bar`, found struct `foo` + | ------------------- ^ expected `Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -718,7 +718,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:74:23 | LL | want::<&Foo>(f); - | ----------------- ^ expected `&Foo`, found struct `Foo` + | ----------------- ^ expected `&Foo`, found `Foo` | | | arguments to this function are incorrect | @@ -734,7 +734,7 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:75:26 | LL | want::<&Foo>(f); - | -------------------- ^ expected `&Foo`, found struct `Foo` + | -------------------- ^ expected `&Foo`, found `Foo` | | | arguments to this function are incorrect | diff --git a/tests/ui/type/wrong-call-return-type-due-to-generic-arg.stderr b/tests/ui/type/wrong-call-return-type-due-to-generic-arg.stderr index 4d012cb15..fbe6bfeeb 100644 --- a/tests/ui/type/wrong-call-return-type-due-to-generic-arg.stderr +++ b/tests/ui/type/wrong-call-return-type-due-to-generic-arg.stderr @@ -95,7 +95,7 @@ LL | let x: u16 = (S {}).method(0u32); | ^^^^^^^^^^^^^^----^ | | | this argument influences the return type of `method` -note: associated function defined here +note: method defined here --> $DIR/wrong-call-return-type-due-to-generic-arg.rs:7:8 | LL | fn method(&self, x: T) -> T { -- cgit v1.2.3