summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/inference
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/ui/inference/cannot-infer-closure-circular.stderr3
-rw-r--r--tests/ui/inference/issue-104649.stderr2
-rw-r--r--tests/ui/inference/issue-107090.rs6
-rw-r--r--tests/ui/inference/issue-107090.stderr17
-rw-r--r--tests/ui/inference/issue-71584.rs1
-rw-r--r--tests/ui/inference/issue-71584.stderr2
-rw-r--r--tests/ui/inference/issue-72690.stderr16
-rw-r--r--tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs61
-rw-r--r--tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr98
-rw-r--r--tests/ui/inference/multiple-impl-apply.rs48
-rw-r--r--tests/ui/inference/multiple-impl-apply.stderr23
-rw-r--r--tests/ui/inference/need_type_info/concrete-impl.rs2
-rw-r--r--tests/ui/inference/need_type_info/concrete-impl.stderr11
-rw-r--r--tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr14
-rw-r--r--tests/ui/inference/question-mark-type-infer.stderr7
15 files changed, 266 insertions, 45 deletions
diff --git a/tests/ui/inference/cannot-infer-closure-circular.stderr b/tests/ui/inference/cannot-infer-closure-circular.stderr
index b706cd2bc..98639f307 100644
--- a/tests/ui/inference/cannot-infer-closure-circular.stderr
+++ b/tests/ui/inference/cannot-infer-closure-circular.stderr
@@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `Result<(), E>`
|
LL | let x = |r| {
| ^
+LL | let v = r?;
+LL | Ok(v)
+ | ----- type must be known at this point
|
help: consider giving this closure parameter an explicit type, where the type for type parameter `E` is specified
|
diff --git a/tests/ui/inference/issue-104649.stderr b/tests/ui/inference/issue-104649.stderr
index 4962b21f9..281932927 100644
--- a/tests/ui/inference/issue-104649.stderr
+++ b/tests/ui/inference/issue-104649.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `A<std::result::Result<std::result::Re
--> $DIR/issue-104649.rs:24:9
|
LL | let a = A(Result::Ok(Result::Ok(())));
- | ^
+ | ^ -------------- type must be known at this point
|
help: consider giving `a` an explicit type, where the type for type parameter `E` is specified
|
diff --git a/tests/ui/inference/issue-107090.rs b/tests/ui/inference/issue-107090.rs
index a22e12c6d..799c36418 100644
--- a/tests/ui/inference/issue-107090.rs
+++ b/tests/ui/inference/issue-107090.rs
@@ -2,8 +2,8 @@ use std::marker::PhantomData;
struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
where
Foo<'short, 'out, T>: Convert<'a, 'b>;
- //~^ ERROR use of undeclared lifetime name
- //~| ERROR use of undeclared lifetime name `'out`
+//~^ ERROR use of undeclared lifetime name
+//~| ERROR use of undeclared lifetime name `'out`
trait Convert<'a, 'b>: Sized {
fn cast(&'a self) -> &'b Self;
@@ -19,7 +19,7 @@ impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
//~^ ERROR use of undeclared lifetime name
- sadness.cast() //~ ERROR mismatched types
+ sadness.cast()
}
fn main() {}
diff --git a/tests/ui/inference/issue-107090.stderr b/tests/ui/inference/issue-107090.stderr
index 6233b629a..e509e262f 100644
--- a/tests/ui/inference/issue-107090.stderr
+++ b/tests/ui/inference/issue-107090.stderr
@@ -66,19 +66,6 @@ LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short,
| |
| help: consider introducing lifetime `'short` here: `'short,`
-error[E0308]: mismatched types
- --> $DIR/issue-107090.rs:22:5
- |
-LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
- | - this type parameter ------- expected `&'out T` because of return type
-LL |
-LL | sadness.cast()
- | ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>`
- |
- = note: expected reference `&'out T`
- found reference `&Foo<'_, '_, T>`
-
-error: aborting due to 7 previous errors
+error: aborting due to 6 previous errors
-Some errors have detailed explanations: E0261, E0308.
-For more information about an error, try `rustc --explain E0261`.
+For more information about this error, try `rustc --explain E0261`.
diff --git a/tests/ui/inference/issue-71584.rs b/tests/ui/inference/issue-71584.rs
index 7bf3ed60e..c96c32d5c 100644
--- a/tests/ui/inference/issue-71584.rs
+++ b/tests/ui/inference/issue-71584.rs
@@ -1,3 +1,4 @@
+// ignore-windows different list of satisfying impls
fn main() {
let n: u32 = 1;
let mut d: u64 = 2;
diff --git a/tests/ui/inference/issue-71584.stderr b/tests/ui/inference/issue-71584.stderr
index 6ddb76573..22c0f113d 100644
--- a/tests/ui/inference/issue-71584.stderr
+++ b/tests/ui/inference/issue-71584.stderr
@@ -1,5 +1,5 @@
error[E0284]: type annotations needed
- --> $DIR/issue-71584.rs:4:15
+ --> $DIR/issue-71584.rs:5:15
|
LL | d = d % n.into();
| - ^^^^
diff --git a/tests/ui/inference/issue-72690.stderr b/tests/ui/inference/issue-72690.stderr
index 225558805..6c93241ea 100644
--- a/tests/ui/inference/issue-72690.stderr
+++ b/tests/ui/inference/issue-72690.stderr
@@ -24,16 +24,15 @@ help: try using a fully qualified path to specify the expected types
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
-error[E0282]: type annotations needed
- --> $DIR/issue-72690.rs:12:6
+error[E0283]: type annotations needed
+ --> $DIR/issue-72690.rs:12:9
|
LL | |x| String::from("x".as_ref());
- | ^
- |
-help: consider giving this closure parameter an explicit type
+ | ^^^^^^ cannot infer type for reference `&_`
|
-LL | |x: /* Type */| String::from("x".as_ref());
- | ++++++++++++
+ = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
+ - impl From<&String> for String;
+ - impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:12:26
@@ -225,5 +224,4 @@ LL | String::from(<str as AsRef<T>>::as_ref("x"));
error: aborting due to 17 previous errors
-Some errors have detailed explanations: E0282, E0283.
-For more information about an error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs
new file mode 100644
index 000000000..4544c898a
--- /dev/null
+++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs
@@ -0,0 +1,61 @@
+struct MyError;
+
+fn foo(x: bool) -> Result<(), MyError> {
+ if x {
+ Err(MyError);
+ //~^ ERROR type annotations needed
+ }
+
+ Ok(())
+}
+
+fn bar(x: bool) -> Result<(), MyError> {
+ if x {
+ Ok(());
+ //~^ ERROR type annotations needed
+ }
+
+ Ok(())
+}
+
+fn baz(x: bool) -> Result<(), MyError> {
+ //~^ ERROR mismatched types
+ if x {
+ 1;
+ }
+
+ Err(MyError);
+}
+
+fn error() -> Result<(), MyError> {
+ Err(MyError)
+}
+
+fn bak(x: bool) -> Result<(), MyError> {
+ if x {
+ //~^ ERROR mismatched types
+ error();
+ } else {
+ //~^ ERROR mismatched types
+ error();
+ }
+}
+
+fn bad(x: bool) -> Result<(), MyError> {
+ Err(MyError); //~ ERROR type annotations needed
+ Ok(())
+}
+
+fn with_closure<F, A, B>(_: F) -> i32
+where
+ F: FnOnce(A, B),
+{
+ 0
+}
+
+fn a() -> i32 {
+ with_closure(|x: u32, y| {}); //~ ERROR type annotations needed
+ 0
+}
+
+fn main() {}
diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr
new file mode 100644
index 000000000..1fea73529
--- /dev/null
+++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr
@@ -0,0 +1,98 @@
+error[E0282]: type annotations needed
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:5:9
+ |
+LL | Err(MyError);
+ | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result`
+ |
+help: consider specifying the generic arguments
+ |
+LL | Err::<T, MyError>(MyError);
+ | ++++++++++++++
+help: you might have meant to return this to infer its type parameters
+ |
+LL | return Err(MyError);
+ | ++++++
+
+error[E0282]: type annotations needed
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:14:9
+ |
+LL | Ok(());
+ | ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
+ |
+help: consider specifying the generic arguments
+ |
+LL | Ok::<(), E>(());
+ | +++++++++
+help: you might have meant to return this to infer its type parameters
+ |
+LL | return Ok(());
+ | ++++++
+
+error[E0308]: mismatched types
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:21:20
+ |
+LL | fn baz(x: bool) -> Result<(), MyError> {
+ | --- ^^^^^^^^^^^^^^^^^^^ expected `Result<(), MyError>`, found `()`
+ | |
+ | implicitly returns `()` as its body has no tail or `return` expression
+...
+LL | Err(MyError);
+ | - help: remove this semicolon to return this value
+ |
+ = note: expected enum `Result<(), MyError>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:35:10
+ |
+LL | if x {
+ | __________^
+LL | |
+LL | | error();
+ | | - help: remove this semicolon to return this value
+LL | | } else {
+ | |_____^ expected `Result<(), MyError>`, found `()`
+ |
+ = note: expected enum `Result<(), MyError>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:38:12
+ |
+LL | } else {
+ | ____________^
+LL | |
+LL | | error();
+ | | - help: remove this semicolon to return this value
+LL | | }
+ | |_____^ expected `Result<(), MyError>`, found `()`
+ |
+ = note: expected enum `Result<(), MyError>`
+ found unit type `()`
+
+error[E0282]: type annotations needed
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:45:5
+ |
+LL | Err(MyError);
+ | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result`
+ |
+help: consider specifying the generic arguments
+ |
+LL | Err::<T, MyError>(MyError);
+ | ++++++++++++++
+
+error[E0282]: type annotations needed
+ --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:57:27
+ |
+LL | with_closure(|x: u32, y| {});
+ | ^
+ |
+help: consider giving this closure parameter an explicit type
+ |
+LL | with_closure(|x: u32, y: /* Type */| {});
+ | ++++++++++++
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0282, E0308.
+For more information about an error, try `rustc --explain E0282`.
diff --git a/tests/ui/inference/multiple-impl-apply.rs b/tests/ui/inference/multiple-impl-apply.rs
new file mode 100644
index 000000000..314fe0f2a
--- /dev/null
+++ b/tests/ui/inference/multiple-impl-apply.rs
@@ -0,0 +1,48 @@
+struct Foo {
+ inner: u32,
+}
+
+struct Bar {
+ inner: u32,
+}
+
+#[derive(Clone, Copy)]
+struct Baz {
+ inner: u32,
+}
+
+impl From<Baz> for Bar {
+ fn from(other: Baz) -> Self {
+ Self {
+ inner: other.inner,
+ }
+ }
+}
+
+impl From<Baz> for Foo {
+ fn from(other: Baz) -> Self {
+ Self {
+ inner: other.inner,
+ }
+ }
+}
+
+fn main() {
+ let x: Baz = Baz { inner: 42 };
+
+ // DOESN'T Compile: Multiple options!
+ let y = x.into(); //~ ERROR E0283
+
+ let y_1: Foo = x.into();
+ let y_2: Bar = x.into();
+
+ let z_1 = Foo::from(y_1);
+ let z_2 = Bar::from(y_2);
+
+ // No type annotations needed, the compiler KNOWS the type must be `Foo`!
+ let m = magic_foo(x);
+}
+
+fn magic_foo(arg: Baz) -> Foo {
+ arg.into()
+}
diff --git a/tests/ui/inference/multiple-impl-apply.stderr b/tests/ui/inference/multiple-impl-apply.stderr
new file mode 100644
index 000000000..ec49e1520
--- /dev/null
+++ b/tests/ui/inference/multiple-impl-apply.stderr
@@ -0,0 +1,23 @@
+error[E0283]: type annotations needed
+ --> $DIR/multiple-impl-apply.rs:34:9
+ |
+LL | let y = x.into();
+ | ^ ---- type must be known at this point
+ |
+note: multiple `impl`s satisfying `_: From<Baz>` found
+ --> $DIR/multiple-impl-apply.rs:14:1
+ |
+LL | impl From<Baz> for Bar {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | impl From<Baz> for Foo {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ = note: required for `Baz` to implement `Into<_>`
+help: consider giving `y` an explicit type
+ |
+LL | let y: /* Type */ = x.into();
+ | ++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/inference/need_type_info/concrete-impl.rs b/tests/ui/inference/need_type_info/concrete-impl.rs
index fc79e6201..8960f870c 100644
--- a/tests/ui/inference/need_type_info/concrete-impl.rs
+++ b/tests/ui/inference/need_type_info/concrete-impl.rs
@@ -14,6 +14,4 @@ fn main() {
<Struct as Ambiguous<_>>::method();
//~^ ERROR type annotations needed
//~| NOTE cannot infer type of the type parameter `A`
- //~| ERROR type annotations needed
- //~| NOTE infer type of the type parameter `A`
}
diff --git a/tests/ui/inference/need_type_info/concrete-impl.stderr b/tests/ui/inference/need_type_info/concrete-impl.stderr
index 74c3f6cd5..6b86753ca 100644
--- a/tests/ui/inference/need_type_info/concrete-impl.stderr
+++ b/tests/ui/inference/need_type_info/concrete-impl.stderr
@@ -1,9 +1,3 @@
-error[E0282]: type annotations needed
- --> $DIR/concrete-impl.rs:14:5
- |
-LL | <Struct as Ambiguous<_>>::method();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous`
-
error[E0283]: type annotations needed
--> $DIR/concrete-impl.rs:14:5
|
@@ -19,7 +13,6 @@ LL |
LL | impl Ambiguous<Two> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 2 previous errors
+error: aborting due to previous error
-Some errors have detailed explanations: E0282, E0283.
-For more information about an error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr
index 0ec219415..9ca94cd58 100644
--- a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr
+++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr
@@ -1,9 +1,17 @@
-error[E0282]: type annotations needed
+error[E0283]: type annotations needed
--> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:10:16
|
LL | (S {}).owo(None)
- | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
+ | --- ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
+ | |
+ | required by a bound introduced by this call
|
+ = note: cannot satisfy `_: T`
+note: required by a bound in `S::owo`
+ --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:6:35
+ |
+LL | fn owo(&self, _: Option<&impl T>) {}
+ | ^ required by this bound in `S::owo`
help: consider specifying the generic argument
|
LL | (S {}).owo(None::<&_>)
@@ -11,4 +19,4 @@ LL | (S {}).owo(None::<&_>)
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/inference/question-mark-type-infer.stderr b/tests/ui/inference/question-mark-type-infer.stderr
index 7a1e850d1..52baa2133 100644
--- a/tests/ui/inference/question-mark-type-infer.stderr
+++ b/tests/ui/inference/question-mark-type-infer.stderr
@@ -1,9 +1,12 @@
-error[E0282]: type annotations needed
+error[E0283]: type annotations needed
--> $DIR/question-mark-type-infer.rs:10:21
|
LL | l.iter().map(f).collect()?
| ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect`
|
+ = note: cannot satisfy `_: FromIterator<Result<i32, ()>>`
+note: required by a bound in `collect`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider specifying the generic argument
|
LL | l.iter().map(f).collect::<Vec<_>>()?
@@ -11,4 +14,4 @@ LL | l.iter().map(f).collect::<Vec<_>>()?
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0283`.