diff options
Diffstat (limited to 'tests/ui/inference')
-rw-r--r-- | tests/ui/inference/deref-suggestion.rs | 9 | ||||
-rw-r--r-- | tests/ui/inference/deref-suggestion.stderr | 35 | ||||
-rw-r--r-- | tests/ui/inference/issue-70082.rs | 10 | ||||
-rw-r--r-- | tests/ui/inference/issue-70082.stderr | 17 | ||||
-rw-r--r-- | tests/ui/inference/issue-71584.rs | 6 | ||||
-rw-r--r-- | tests/ui/inference/issue-71584.stderr | 17 |
6 files changed, 85 insertions, 9 deletions
diff --git a/tests/ui/inference/deref-suggestion.rs b/tests/ui/inference/deref-suggestion.rs index 0d8e7289d..dc39cc9db 100644 --- a/tests/ui/inference/deref-suggestion.rs +++ b/tests/ui/inference/deref-suggestion.rs @@ -72,4 +72,13 @@ fn main() { } else { &0 }; + + #[derive(PartialEq, Eq)] + struct Foo; + let foo = Foo; + let bar = &Foo; + + if foo == bar { + //~^ ERROR mismatched types + } } diff --git a/tests/ui/inference/deref-suggestion.stderr b/tests/ui/inference/deref-suggestion.stderr index 1626032ae..c58aab422 100644 --- a/tests/ui/inference/deref-suggestion.stderr +++ b/tests/ui/inference/deref-suggestion.stderr @@ -98,19 +98,23 @@ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:40:17 | LL | let s = S { u }; - | ^ - | | - | expected `&u32`, found integer - | help: consider borrowing here: `u: &u` + | ^ expected `&u32`, found integer + | +help: consider borrowing here + | +LL | let s = S { u: &u }; + | ++++ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:42:20 | LL | let s = S { u: u }; - | ^ - | | - | expected `&u32`, found integer - | help: consider borrowing here: `&u` + | ^ expected `&u32`, found integer + | +help: consider borrowing here + | +LL | let s = S { u: &u }; + | + error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:45:17 @@ -175,6 +179,19 @@ LL | || }; | |_____`if` and `else` have incompatible types | expected `i32`, found `&{integer}` -error: aborting due to 13 previous errors +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:81:15 + | +LL | if foo == bar { + | --- ^^^ expected `Foo`, found `&Foo` + | | + | expected because this is `Foo` + | +help: consider dereferencing the borrow + | +LL | if foo == *bar { + | + + +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/issue-70082.rs b/tests/ui/inference/issue-70082.rs new file mode 100644 index 000000000..d54d0a1a4 --- /dev/null +++ b/tests/ui/inference/issue-70082.rs @@ -0,0 +1,10 @@ +fn main() { + // this closure is fine, and should not get any error annotations + let em = |v: f64| -> f64 { v }; + + let x: f64 = em(1i16.into()); + + let y: f64 = 0.01f64 * 1i16.into(); + //~^ ERROR type annotations needed + //~| HELP try using a fully qualified path +} diff --git a/tests/ui/inference/issue-70082.stderr b/tests/ui/inference/issue-70082.stderr new file mode 100644 index 000000000..47229a5fe --- /dev/null +++ b/tests/ui/inference/issue-70082.stderr @@ -0,0 +1,17 @@ +error[E0284]: type annotations needed + --> $DIR/issue-70082.rs:7:33 + | +LL | let y: f64 = 0.01f64 * 1i16.into(); + | - ^^^^ + | | + | type must be known at this point + | + = note: cannot satisfy `<f64 as Mul<_>>::Output == f64` +help: try using a fully qualified path to specify the expected types + | +LL | let y: f64 = 0.01f64 * <i16 as Into<T>>::into(1i16); + | +++++++++++++++++++++++ ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/inference/issue-71584.rs b/tests/ui/inference/issue-71584.rs new file mode 100644 index 000000000..7bf3ed60e --- /dev/null +++ b/tests/ui/inference/issue-71584.rs @@ -0,0 +1,6 @@ +fn main() { + let n: u32 = 1; + let mut d: u64 = 2; + d = d % n.into(); + //~^ ERROR type annotations needed +} diff --git a/tests/ui/inference/issue-71584.stderr b/tests/ui/inference/issue-71584.stderr new file mode 100644 index 000000000..6ddb76573 --- /dev/null +++ b/tests/ui/inference/issue-71584.stderr @@ -0,0 +1,17 @@ +error[E0284]: type annotations needed + --> $DIR/issue-71584.rs:4:15 + | +LL | d = d % n.into(); + | - ^^^^ + | | + | type must be known at this point + | + = note: cannot satisfy `<u64 as Rem<_>>::Output == u64` +help: try using a fully qualified path to specify the expected types + | +LL | d = d % <u32 as Into<T>>::into(n); + | +++++++++++++++++++++++ ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0284`. |