summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/suggestions')
-rw-r--r--src/test/ui/suggestions/abi-typo.fixed6
-rw-r--r--src/test/ui/suggestions/abi-typo.rs6
-rw-r--r--src/test/ui/suggestions/abi-typo.stderr14
-rw-r--r--src/test/ui/suggestions/assoc_fn_without_self.stderr12
-rw-r--r--src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr9
-rw-r--r--src/test/ui/suggestions/boxed-variant-field.rs1
-rw-r--r--src/test/ui/suggestions/boxed-variant-field.stderr4
-rw-r--r--src/test/ui/suggestions/call-on-unimplemented-ctor.rs17
-rw-r--r--src/test/ui/suggestions/call-on-unimplemented-ctor.stderr21
-rw-r--r--src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs15
-rw-r--r--src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr21
-rw-r--r--src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr9
-rw-r--r--src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr14
-rw-r--r--src/test/ui/suggestions/fn-to-method.rs19
-rw-r--r--src/test/ui/suggestions/fn-to-method.stderr38
-rw-r--r--src/test/ui/suggestions/format-borrow.stderr16
-rw-r--r--src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr12
-rw-r--r--src/test/ui/suggestions/inner_type.fixed40
-rw-r--r--src/test/ui/suggestions/inner_type.rs40
-rw-r--r--src/test/ui/suggestions/inner_type.stderr83
-rw-r--r--src/test/ui/suggestions/inner_type2.rs26
-rw-r--r--src/test/ui/suggestions/inner_type2.stderr29
-rw-r--r--src/test/ui/suggestions/into-convert.rs26
-rw-r--r--src/test/ui/suggestions/into-convert.stderr44
-rw-r--r--src/test/ui/suggestions/issue-101065.fixed14
-rw-r--r--src/test/ui/suggestions/issue-101065.rs14
-rw-r--r--src/test/ui/suggestions/issue-101065.stderr23
-rw-r--r--src/test/ui/suggestions/issue-101623.rs25
-rw-r--r--src/test/ui/suggestions/issue-101623.stderr14
-rw-r--r--src/test/ui/suggestions/issue-101984.stderr4
-rw-r--r--src/test/ui/suggestions/issue-102354.rs10
-rw-r--r--src/test/ui/suggestions/issue-102354.stderr24
-rw-r--r--src/test/ui/suggestions/issue-102892.rs25
-rw-r--r--src/test/ui/suggestions/issue-102892.stderr57
-rw-r--r--src/test/ui/suggestions/issue-103112.rs4
-rw-r--r--src/test/ui/suggestions/issue-103112.stderr15
-rw-r--r--src/test/ui/suggestions/issue-61963.stderr4
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr1
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr4
-rw-r--r--src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr4
-rw-r--r--src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr2
-rw-r--r--src/test/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr4
-rw-r--r--src/test/ui/suggestions/missing-bound-in-manual-copy-impl.stderr4
-rw-r--r--src/test/ui/suggestions/non-existent-field-present-in-subfield-recursion-limit.rs2
-rw-r--r--src/test/ui/suggestions/return-closures.stderr2
-rw-r--r--src/test/ui/suggestions/struct-field-type-including-single-colon.stderr4
-rw-r--r--src/test/ui/suggestions/sugg-else-for-closure.fixed8
-rw-r--r--src/test/ui/suggestions/sugg-else-for-closure.rs8
-rw-r--r--src/test/ui/suggestions/sugg-else-for-closure.stderr23
-rw-r--r--src/test/ui/suggestions/suggest-let-for-assignment.fixed17
-rw-r--r--src/test/ui/suggestions/suggest-let-for-assignment.rs17
-rw-r--r--src/test/ui/suggestions/suggest-let-for-assignment.stderr60
-rw-r--r--src/test/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr2
53 files changed, 867 insertions, 50 deletions
diff --git a/src/test/ui/suggestions/abi-typo.fixed b/src/test/ui/suggestions/abi-typo.fixed
new file mode 100644
index 000000000..04d265865
--- /dev/null
+++ b/src/test/ui/suggestions/abi-typo.fixed
@@ -0,0 +1,6 @@
+// run-rustfix
+extern "cdecl" fn cdedl() {} //~ ERROR invalid ABI
+
+fn main() {
+ cdedl();
+}
diff --git a/src/test/ui/suggestions/abi-typo.rs b/src/test/ui/suggestions/abi-typo.rs
new file mode 100644
index 000000000..6d80db522
--- /dev/null
+++ b/src/test/ui/suggestions/abi-typo.rs
@@ -0,0 +1,6 @@
+// run-rustfix
+extern "cdedl" fn cdedl() {} //~ ERROR invalid ABI
+
+fn main() {
+ cdedl();
+}
diff --git a/src/test/ui/suggestions/abi-typo.stderr b/src/test/ui/suggestions/abi-typo.stderr
new file mode 100644
index 000000000..67a84f119
--- /dev/null
+++ b/src/test/ui/suggestions/abi-typo.stderr
@@ -0,0 +1,14 @@
+error[E0703]: invalid ABI: found `cdedl`
+ --> $DIR/abi-typo.rs:2:8
+ |
+LL | extern "cdedl" fn cdedl() {}
+ | ^^^^^^^
+ | |
+ | invalid ABI
+ | help: did you mean: `"cdecl"`
+ |
+ = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions.
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0703`.
diff --git a/src/test/ui/suggestions/assoc_fn_without_self.stderr b/src/test/ui/suggestions/assoc_fn_without_self.stderr
index 4a0e62e73..88920b852 100644
--- a/src/test/ui/suggestions/assoc_fn_without_self.stderr
+++ b/src/test/ui/suggestions/assoc_fn_without_self.stderr
@@ -1,10 +1,4 @@
error[E0425]: cannot find function `foo` in this scope
- --> $DIR/assoc_fn_without_self.rs:14:13
- |
-LL | foo();
- | ^^^ not found in this scope
-
-error[E0425]: cannot find function `foo` in this scope
--> $DIR/assoc_fn_without_self.rs:16:9
|
LL | foo();
@@ -32,6 +26,12 @@ help: consider using the associated function
LL | Self::baz(2, 3);
| ~~~~~~~~~
+error[E0425]: cannot find function `foo` in this scope
+ --> $DIR/assoc_fn_without_self.rs:14:13
+ |
+LL | foo();
+ | ^^^ not found in this scope
+
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
index bfd506c9f..8ed62f854 100644
--- a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
+++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
@@ -1,9 +1,6 @@
error[E0277]: `fn() -> impl Future<Output = ()> {foo}` is not a future
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:10:9
|
-LL | async fn foo() {}
- | --- consider calling this function
-...
LL | bar(foo);
| --- ^^^ `fn() -> impl Future<Output = ()> {foo}` is not a future
| |
@@ -16,7 +13,7 @@ note: required by a bound in `bar`
|
LL | fn bar(f: impl Future<Output=()>) {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `bar`
-help: use parentheses to call the function
+help: use parentheses to call this function
|
LL | bar(foo());
| ++
@@ -24,8 +21,6 @@ LL | bar(foo());
error[E0277]: `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9
|
-LL | let async_closure = async || ();
- | -------- consider calling this closure
LL | bar(async_closure);
| --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future
| |
@@ -38,7 +33,7 @@ note: required by a bound in `bar`
|
LL | fn bar(f: impl Future<Output=()>) {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `bar`
-help: use parentheses to call the closure
+help: use parentheses to call this closure
|
LL | bar(async_closure());
| ++
diff --git a/src/test/ui/suggestions/boxed-variant-field.rs b/src/test/ui/suggestions/boxed-variant-field.rs
index e79be2f61..6050963c4 100644
--- a/src/test/ui/suggestions/boxed-variant-field.rs
+++ b/src/test/ui/suggestions/boxed-variant-field.rs
@@ -9,7 +9,6 @@ fn foo(x: Ty) -> Ty {
Ty::List(elem) => foo(elem),
//~^ ERROR mismatched types
//~| HELP consider unboxing the value
- //~| HELP try wrapping
}
}
diff --git a/src/test/ui/suggestions/boxed-variant-field.stderr b/src/test/ui/suggestions/boxed-variant-field.stderr
index 6dfb73480..9ae36a06a 100644
--- a/src/test/ui/suggestions/boxed-variant-field.stderr
+++ b/src/test/ui/suggestions/boxed-variant-field.stderr
@@ -17,10 +17,6 @@ help: consider unboxing the value
|
LL | Ty::List(elem) => foo(*elem),
| +
-help: try wrapping the expression in `Ty::List`
- |
-LL | Ty::List(elem) => foo(Ty::List(elem)),
- | +++++++++ +
error: aborting due to previous error
diff --git a/src/test/ui/suggestions/call-on-unimplemented-ctor.rs b/src/test/ui/suggestions/call-on-unimplemented-ctor.rs
new file mode 100644
index 000000000..5f811044e
--- /dev/null
+++ b/src/test/ui/suggestions/call-on-unimplemented-ctor.rs
@@ -0,0 +1,17 @@
+fn main() {
+ insert_resource(Marker);
+ insert_resource(Time);
+ //~^ ERROR the trait bound `fn(u32) -> Time {Time}: Resource` is not satisfied
+ //~| HELP use parentheses to construct this tuple struct
+}
+
+trait Resource {}
+
+fn insert_resource<R: Resource>(resource: R) {}
+
+struct Marker;
+impl Resource for Marker {}
+
+struct Time(u32);
+
+impl Resource for Time {}
diff --git a/src/test/ui/suggestions/call-on-unimplemented-ctor.stderr b/src/test/ui/suggestions/call-on-unimplemented-ctor.stderr
new file mode 100644
index 000000000..58612cbfb
--- /dev/null
+++ b/src/test/ui/suggestions/call-on-unimplemented-ctor.stderr
@@ -0,0 +1,21 @@
+error[E0277]: the trait bound `fn(u32) -> Time {Time}: Resource` is not satisfied
+ --> $DIR/call-on-unimplemented-ctor.rs:3:21
+ |
+LL | insert_resource(Time);
+ | --------------- ^^^^ the trait `Resource` is not implemented for fn item `fn(u32) -> Time {Time}`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `insert_resource`
+ --> $DIR/call-on-unimplemented-ctor.rs:10:23
+ |
+LL | fn insert_resource<R: Resource>(resource: R) {}
+ | ^^^^^^^^ required by this bound in `insert_resource`
+help: use parentheses to construct this tuple struct
+ |
+LL | insert_resource(Time(/* u32 */));
+ | +++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs
new file mode 100644
index 000000000..86490c724
--- /dev/null
+++ b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.rs
@@ -0,0 +1,15 @@
+struct Foo;
+
+trait Bar {}
+
+impl Bar for Foo {}
+
+fn needs_bar<T: Bar>(_: T) {}
+
+fn blah(f: fn() -> Foo) {
+ needs_bar(f);
+ //~^ ERROR the trait bound `fn() -> Foo: Bar` is not satisfied
+ //~| HELP use parentheses to call this function pointer
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr
new file mode 100644
index 000000000..167f7e592
--- /dev/null
+++ b/src/test/ui/suggestions/call-on-unimplemented-fn-ptr.stderr
@@ -0,0 +1,21 @@
+error[E0277]: the trait bound `fn() -> Foo: Bar` is not satisfied
+ --> $DIR/call-on-unimplemented-fn-ptr.rs:10:15
+ |
+LL | needs_bar(f);
+ | --------- ^ the trait `Bar` is not implemented for `fn() -> Foo`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `needs_bar`
+ --> $DIR/call-on-unimplemented-fn-ptr.rs:7:17
+ |
+LL | fn needs_bar<T: Bar>(_: T) {}
+ | ^^^ required by this bound in `needs_bar`
+help: use parentheses to call this function pointer
+ |
+LL | needs_bar(f());
+ | ++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
index fe603b675..955148315 100644
--- a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
+++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
@@ -1,9 +1,6 @@
error[E0277]: the trait bound `fn() -> impl T<O = ()> {foo}: T` is not satisfied
--> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:17:9
|
-LL | fn foo() -> impl T<O=()> { S }
- | --- consider calling this function
-...
LL | bar(foo);
| --- ^^^ the trait `T` is not implemented for fn item `fn() -> impl T<O = ()> {foo}`
| |
@@ -14,7 +11,7 @@ note: required by a bound in `bar`
|
LL | fn bar(f: impl T<O=()>) {}
| ^^^^^^^ required by this bound in `bar`
-help: use parentheses to call the function
+help: use parentheses to call this function
|
LL | bar(foo());
| ++
@@ -22,8 +19,6 @@ LL | bar(foo());
error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]: T` is not satisfied
--> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9
|
-LL | let closure = || S;
- | -- consider calling this closure
LL | bar(closure);
| --- ^^^^^^^ the trait `T` is not implemented for closure `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]`
| |
@@ -34,7 +29,7 @@ note: required by a bound in `bar`
|
LL | fn bar(f: impl T<O=()>) {}
| ^^^^^^^ required by this bound in `bar`
-help: use parentheses to call the closure
+help: use parentheses to call this closure
|
LL | bar(closure());
| ++
diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr
index 3c7b895e3..597dc61c3 100644
--- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr
+++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr
@@ -49,7 +49,7 @@ LL | let _: S = S;
|
= note: expected struct `S`
found fn item `fn(usize, usize) -> S {S}`
-help: use parentheses to instantiate this tuple struct
+help: use parentheses to construct this tuple struct
|
LL | let _: S = S(/* usize */, /* usize */);
| ++++++++++++++++++++++++++
@@ -85,7 +85,7 @@ LL | let _: V = V;
|
= note: expected struct `V`
found fn item `fn() -> V {V}`
-help: use parentheses to instantiate this tuple struct
+help: use parentheses to construct this tuple struct
|
LL | let _: V = V();
| ++
@@ -139,7 +139,7 @@ LL | let _: E = E::A;
|
= note: expected enum `E`
found fn item `fn(usize) -> E {E::A}`
-help: use parentheses to instantiate this tuple variant
+help: use parentheses to construct this tuple variant
|
LL | let _: E = E::A(/* usize */);
| +++++++++++++
@@ -220,7 +220,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:41:20
|
LL | fn ban(&self) -> usize { 42 }
- | ---------------------- for<'r> fn(&'r X) -> usize {<X as T>::ban} defined here
+ | ---------------------- for<'a> fn(&'a X) -> usize {<X as T>::ban} defined here
...
LL | let _: usize = X::ban;
| ----- ^^^^^^ expected `usize`, found fn item
@@ -228,7 +228,7 @@ LL | let _: usize = X::ban;
| expected due to this
|
= note: expected type `usize`
- found fn item `for<'r> fn(&'r X) -> usize {<X as T>::ban}`
+ found fn item `for<'a> fn(&'a X) -> usize {<X as T>::ban}`
help: use parentheses to call this associated function
|
LL | let _: usize = X::ban(/* &X */);
@@ -238,7 +238,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:42:20
|
LL | fn bal(&self) -> usize;
- | ----------------------- for<'r> fn(&'r X) -> usize {<X as T>::bal} defined here
+ | ----------------------- for<'a> fn(&'a X) -> usize {<X as T>::bal} defined here
...
LL | let _: usize = X::bal;
| ----- ^^^^^^ expected `usize`, found fn item
@@ -246,7 +246,7 @@ LL | let _: usize = X::bal;
| expected due to this
|
= note: expected type `usize`
- found fn item `for<'r> fn(&'r X) -> usize {<X as T>::bal}`
+ found fn item `for<'a> fn(&'a X) -> usize {<X as T>::bal}`
help: use parentheses to call this associated function
|
LL | let _: usize = X::bal(/* &X */);
diff --git a/src/test/ui/suggestions/fn-to-method.rs b/src/test/ui/suggestions/fn-to-method.rs
new file mode 100644
index 000000000..9a35c3efc
--- /dev/null
+++ b/src/test/ui/suggestions/fn-to-method.rs
@@ -0,0 +1,19 @@
+struct Foo;
+
+impl Foo {
+ fn bar(self) {}
+}
+
+fn main() {
+ let x = cmp(&1, &2);
+ //~^ ERROR cannot find function `cmp` in this scope
+ //~| HELP use the `.` operator to call the method `Ord::cmp` on `&{integer}`
+
+ let y = len([1, 2, 3]);
+ //~^ ERROR cannot find function `len` in this scope
+ //~| HELP use the `.` operator to call the method `len` on `&[{integer}]`
+
+ let z = bar(Foo);
+ //~^ ERROR cannot find function `bar` in this scope
+ //~| HELP use the `.` operator to call the method `bar` on `Foo`
+}
diff --git a/src/test/ui/suggestions/fn-to-method.stderr b/src/test/ui/suggestions/fn-to-method.stderr
new file mode 100644
index 000000000..36c17e60d
--- /dev/null
+++ b/src/test/ui/suggestions/fn-to-method.stderr
@@ -0,0 +1,38 @@
+error[E0425]: cannot find function `cmp` in this scope
+ --> $DIR/fn-to-method.rs:8:13
+ |
+LL | let x = cmp(&1, &2);
+ | ^^^ not found in this scope
+ |
+help: use the `.` operator to call the method `Ord::cmp` on `&{integer}`
+ |
+LL | let x = (&1).cmp(&2);
+ | ~ ~~~~~~~~~
+
+error[E0425]: cannot find function `len` in this scope
+ --> $DIR/fn-to-method.rs:12:13
+ |
+LL | let y = len([1, 2, 3]);
+ | ^^^ not found in this scope
+ |
+help: use the `.` operator to call the method `len` on `&[{integer}]`
+ |
+LL - let y = len([1, 2, 3]);
+LL + let y = [1, 2, 3].len();
+ |
+
+error[E0425]: cannot find function `bar` in this scope
+ --> $DIR/fn-to-method.rs:16:13
+ |
+LL | let z = bar(Foo);
+ | ^^^ not found in this scope
+ |
+help: use the `.` operator to call the method `bar` on `Foo`
+ |
+LL - let z = bar(Foo);
+LL + let z = Foo.bar();
+ |
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/suggestions/format-borrow.stderr b/src/test/ui/suggestions/format-borrow.stderr
index fac6a5a5f..8ed2b9c9a 100644
--- a/src/test/ui/suggestions/format-borrow.stderr
+++ b/src/test/ui/suggestions/format-borrow.stderr
@@ -11,6 +11,10 @@ help: consider removing the borrow
LL - let a: String = &String::from("a");
LL + let a: String = String::from("a");
|
+help: alternatively, consider changing the type annotation
+ |
+LL | let a: &String = &String::from("a");
+ | +
error[E0308]: mismatched types
--> $DIR/format-borrow.rs:4:21
@@ -25,6 +29,10 @@ help: consider removing the borrow
LL - let b: String = &format!("b");
LL + let b: String = format!("b");
|
+help: alternatively, consider changing the type annotation
+ |
+LL | let b: &String = &format!("b");
+ | +
error[E0308]: mismatched types
--> $DIR/format-borrow.rs:6:21
@@ -39,6 +47,10 @@ help: consider removing the borrow
LL - let c: String = &mut format!("c");
LL + let c: String = format!("c");
|
+help: alternatively, consider changing the type annotation
+ |
+LL | let c: &mut String = &mut format!("c");
+ | ++++
error[E0308]: mismatched types
--> $DIR/format-borrow.rs:8:21
@@ -53,6 +65,10 @@ help: consider removing the borrow
LL - let d: String = &mut (format!("d"));
LL + let d: String = format!("d"));
|
+help: alternatively, consider changing the type annotation
+ |
+LL | let d: &mut String = &mut (format!("d"));
+ | ++++
error: aborting due to 4 previous errors
diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
index e82a6f769..9833da13f 100644
--- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
+++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
@@ -26,17 +26,25 @@ error[E0658]: anonymous lifetimes in `impl Trait` are unstable
--> $DIR/impl-trait-missing-lifetime-gated.rs:5:31
|
LL | fn f(_: impl Iterator<Item = &'_ ()>) {}
- | ^^
+ | ^^ expected named lifetime parameter
|
= help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable
+help: consider introducing a named lifetime parameter
+ |
+LL | fn f<'a>(_: impl Iterator<Item = &'_'a ()>) {}
+ | ++++ ++
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
--> $DIR/impl-trait-missing-lifetime-gated.rs:8:31
|
LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
- | ^^
+ | ^^ expected named lifetime parameter
|
= help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable
+help: consider introducing a named lifetime parameter
+ |
+LL | fn g<'a>(x: impl Iterator<Item = &'_'a ()>) -> Option<&'_ ()> { x.next() }
+ | ++++ ++
error: aborting due to 4 previous errors
diff --git a/src/test/ui/suggestions/inner_type.fixed b/src/test/ui/suggestions/inner_type.fixed
new file mode 100644
index 000000000..7af7391ca
--- /dev/null
+++ b/src/test/ui/suggestions/inner_type.fixed
@@ -0,0 +1,40 @@
+// compile-flags: --edition=2021
+// run-rustfix
+
+pub struct Struct<T> {
+ pub p: T,
+}
+
+impl<T> Struct<T> {
+ pub fn method(&self) {}
+
+ pub fn some_mutable_method(&mut self) {}
+}
+
+fn main() {
+ let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
+
+ other_item.borrow().method();
+ //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599]
+ //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
+
+ other_item.borrow_mut().some_mutable_method();
+ //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599]
+ //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
+
+ let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
+
+ another_item.lock().unwrap().method();
+ //~^ ERROR no method named `method` found for struct `Mutex` in the current scope [E0599]
+ //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+
+ let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
+
+ another_item.read().unwrap().method();
+ //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599]
+ //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+
+ another_item.write().unwrap().some_mutable_method();
+ //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599]
+ //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+}
diff --git a/src/test/ui/suggestions/inner_type.rs b/src/test/ui/suggestions/inner_type.rs
new file mode 100644
index 000000000..4aca50716
--- /dev/null
+++ b/src/test/ui/suggestions/inner_type.rs
@@ -0,0 +1,40 @@
+// compile-flags: --edition=2021
+// run-rustfix
+
+pub struct Struct<T> {
+ pub p: T,
+}
+
+impl<T> Struct<T> {
+ pub fn method(&self) {}
+
+ pub fn some_mutable_method(&mut self) {}
+}
+
+fn main() {
+ let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
+
+ other_item.method();
+ //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599]
+ //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
+
+ other_item.some_mutable_method();
+ //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599]
+ //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
+
+ let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
+
+ another_item.method();
+ //~^ ERROR no method named `method` found for struct `Mutex` in the current scope [E0599]
+ //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+
+ let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
+
+ another_item.method();
+ //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599]
+ //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+
+ another_item.some_mutable_method();
+ //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599]
+ //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+}
diff --git a/src/test/ui/suggestions/inner_type.stderr b/src/test/ui/suggestions/inner_type.stderr
new file mode 100644
index 000000000..5ac3d04f1
--- /dev/null
+++ b/src/test/ui/suggestions/inner_type.stderr
@@ -0,0 +1,83 @@
+error[E0599]: no method named `method` found for struct `RefCell` in the current scope
+ --> $DIR/inner_type.rs:17:16
+ |
+LL | other_item.method();
+ | ^^^^^^ method not found in `RefCell<Struct<u32>>`
+ |
+note: the method `method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type.rs:9:5
+ |
+LL | pub fn method(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^
+help: use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
+ |
+LL | other_item.borrow().method();
+ | +++++++++
+
+error[E0599]: no method named `some_mutable_method` found for struct `RefCell` in the current scope
+ --> $DIR/inner_type.rs:21:16
+ |
+LL | other_item.some_mutable_method();
+ | ^^^^^^^^^^^^^^^^^^^ method not found in `RefCell<Struct<u32>>`
+ |
+note: the method `some_mutable_method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type.rs:11:5
+ |
+LL | pub fn some_mutable_method(&mut self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: use `.borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
+ |
+LL | other_item.borrow_mut().some_mutable_method();
+ | +++++++++++++
+
+error[E0599]: no method named `method` found for struct `Mutex` in the current scope
+ --> $DIR/inner_type.rs:27:18
+ |
+LL | another_item.method();
+ | ^^^^^^ method not found in `Mutex<Struct<u32>>`
+ |
+note: the method `method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type.rs:9:5
+ |
+LL | pub fn method(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^
+help: use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+ |
+LL | another_item.lock().unwrap().method();
+ | ++++++++++++++++
+
+error[E0599]: no method named `method` found for struct `RwLock` in the current scope
+ --> $DIR/inner_type.rs:33:18
+ |
+LL | another_item.method();
+ | ^^^^^^ method not found in `RwLock<Struct<u32>>`
+ |
+note: the method `method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type.rs:9:5
+ |
+LL | pub fn method(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^
+help: use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+ |
+LL | another_item.read().unwrap().method();
+ | ++++++++++++++++
+
+error[E0599]: no method named `some_mutable_method` found for struct `RwLock` in the current scope
+ --> $DIR/inner_type.rs:37:18
+ |
+LL | another_item.some_mutable_method();
+ | ^^^^^^^^^^^^^^^^^^^ method not found in `RwLock<Struct<u32>>`
+ |
+note: the method `some_mutable_method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type.rs:11:5
+ |
+LL | pub fn some_mutable_method(&mut self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
+ |
+LL | another_item.write().unwrap().some_mutable_method();
+ | +++++++++++++++++
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/inner_type2.rs b/src/test/ui/suggestions/inner_type2.rs
new file mode 100644
index 000000000..c56ea7c03
--- /dev/null
+++ b/src/test/ui/suggestions/inner_type2.rs
@@ -0,0 +1,26 @@
+pub struct Struct<T> {
+ pub p: T,
+}
+
+impl<T> Struct<T> {
+ pub fn method(&self) {}
+
+ pub fn some_mutable_method(&mut self) {}
+}
+
+thread_local! {
+ static STRUCT: Struct<u32> = Struct {
+ p: 42_u32
+ };
+}
+
+fn main() {
+ STRUCT.method();
+ //~^ ERROR no method named `method` found for struct `LocalKey` in the current scope [E0599]
+ //~| HELP use `with` or `try_with` to access thread local storage
+
+ let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 });
+ item.method();
+ //~^ ERROR no method named `method` found for union `MaybeUninit` in the current scope [E0599]
+ //~| HELP if this `MaybeUninit::<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
+}
diff --git a/src/test/ui/suggestions/inner_type2.stderr b/src/test/ui/suggestions/inner_type2.stderr
new file mode 100644
index 000000000..eddfd9d63
--- /dev/null
+++ b/src/test/ui/suggestions/inner_type2.stderr
@@ -0,0 +1,29 @@
+error[E0599]: no method named `method` found for struct `LocalKey` in the current scope
+ --> $DIR/inner_type2.rs:18:12
+ |
+LL | STRUCT.method();
+ | ^^^^^^ method not found in `LocalKey<Struct<u32>>`
+ |
+ = help: use `with` or `try_with` to access thread local storage
+note: the method `method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type2.rs:6:5
+ |
+LL | pub fn method(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error[E0599]: no method named `method` found for union `MaybeUninit` in the current scope
+ --> $DIR/inner_type2.rs:23:10
+ |
+LL | item.method();
+ | ^^^^^^ method not found in `MaybeUninit<Struct<u32>>`
+ |
+ = help: if this `MaybeUninit::<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
+note: the method `method` exists on the type `Struct<u32>`
+ --> $DIR/inner_type2.rs:6:5
+ |
+LL | pub fn method(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/into-convert.rs b/src/test/ui/suggestions/into-convert.rs
new file mode 100644
index 000000000..1c9a9e0aa
--- /dev/null
+++ b/src/test/ui/suggestions/into-convert.rs
@@ -0,0 +1,26 @@
+use std::path::{Path, PathBuf};
+use std::sync::atomic::AtomicU32;
+use std::sync::Arc;
+
+fn main() {
+ let x: A = B;
+ //~^ ERROR mismatched types
+ //~| HELP call `Into::into` on this expression to convert `B` into `A`
+
+ let y: Arc<Path> = PathBuf::new();
+ //~^ ERROR mismatched types
+ //~| HELP call `Into::into` on this expression to convert `PathBuf` into `Arc<Path>`
+
+ let z: AtomicU32 = 1;
+ //~^ ERROR mismatched types
+ //~| HELP call `Into::into` on this expression to convert `{integer}` into `AtomicU32`
+}
+
+struct A;
+struct B;
+
+impl From<B> for A {
+ fn from(_: B) -> Self {
+ A
+ }
+}
diff --git a/src/test/ui/suggestions/into-convert.stderr b/src/test/ui/suggestions/into-convert.stderr
new file mode 100644
index 000000000..d43104a21
--- /dev/null
+++ b/src/test/ui/suggestions/into-convert.stderr
@@ -0,0 +1,44 @@
+error[E0308]: mismatched types
+ --> $DIR/into-convert.rs:6:16
+ |
+LL | let x: A = B;
+ | - ^ expected struct `A`, found struct `B`
+ | |
+ | expected due to this
+ |
+help: call `Into::into` on this expression to convert `B` into `A`
+ |
+LL | let x: A = B.into();
+ | +++++++
+
+error[E0308]: mismatched types
+ --> $DIR/into-convert.rs:10:24
+ |
+LL | let y: Arc<Path> = PathBuf::new();
+ | --------- ^^^^^^^^^^^^^^ expected struct `Arc`, found struct `PathBuf`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Arc<Path>`
+ found struct `PathBuf`
+help: call `Into::into` on this expression to convert `PathBuf` into `Arc<Path>`
+ |
+LL | let y: Arc<Path> = PathBuf::new().into();
+ | +++++++
+
+error[E0308]: mismatched types
+ --> $DIR/into-convert.rs:14:24
+ |
+LL | let z: AtomicU32 = 1;
+ | --------- ^ expected struct `AtomicU32`, found integer
+ | |
+ | expected due to this
+ |
+help: call `Into::into` on this expression to convert `{integer}` into `AtomicU32`
+ |
+LL | let z: AtomicU32 = 1.into();
+ | +++++++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-101065.fixed b/src/test/ui/suggestions/issue-101065.fixed
new file mode 100644
index 000000000..88c716cc8
--- /dev/null
+++ b/src/test/ui/suggestions/issue-101065.fixed
@@ -0,0 +1,14 @@
+// check-fail
+// run-rustfix
+
+enum FakeResult<T> {
+ Ok(T)
+}
+
+fn main() {
+ let _x = if true {
+ FakeResult::Ok(FakeResult::Ok(()))
+ } else {
+ FakeResult::Ok(FakeResult::Ok(())) //~ERROR E0308
+ };
+}
diff --git a/src/test/ui/suggestions/issue-101065.rs b/src/test/ui/suggestions/issue-101065.rs
new file mode 100644
index 000000000..2715f1027
--- /dev/null
+++ b/src/test/ui/suggestions/issue-101065.rs
@@ -0,0 +1,14 @@
+// check-fail
+// run-rustfix
+
+enum FakeResult<T> {
+ Ok(T)
+}
+
+fn main() {
+ let _x = if true {
+ FakeResult::Ok(FakeResult::Ok(()))
+ } else {
+ FakeResult::Ok(()) //~ERROR E0308
+ };
+}
diff --git a/src/test/ui/suggestions/issue-101065.stderr b/src/test/ui/suggestions/issue-101065.stderr
new file mode 100644
index 000000000..6f7ecd24c
--- /dev/null
+++ b/src/test/ui/suggestions/issue-101065.stderr
@@ -0,0 +1,23 @@
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/issue-101065.rs:12:9
+ |
+LL | let _x = if true {
+ | ______________-
+LL | | FakeResult::Ok(FakeResult::Ok(()))
+ | | ---------------------------------- expected because of this
+LL | | } else {
+LL | | FakeResult::Ok(())
+ | | ^^^^^^^^^^^^^^^^^^ expected enum `FakeResult`, found `()`
+LL | | };
+ | |_____- `if` and `else` have incompatible types
+ |
+ = note: expected enum `FakeResult<FakeResult<()>>`
+ found enum `FakeResult<()>`
+help: try wrapping the expression in `FakeResult::Ok`
+ |
+LL | FakeResult::Ok(FakeResult::Ok(()))
+ | +++++++++++++++ +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-101623.rs b/src/test/ui/suggestions/issue-101623.rs
new file mode 100644
index 000000000..d18a4a21f
--- /dev/null
+++ b/src/test/ui/suggestions/issue-101623.rs
@@ -0,0 +1,25 @@
+pub struct Stuff {
+ inner: *mut (),
+}
+
+pub struct Wrap<T>(T);
+
+fn fun<T>(t: T) -> Wrap<T> {
+ todo!()
+}
+
+pub trait Trait<'de> {
+ fn do_stuff(_: Wrap<&'de mut Self>);
+}
+
+impl<'a> Trait<'a> for () {
+ fn do_stuff(_: Wrap<&'a mut Self>) {}
+}
+
+fn fun2(t: &mut Stuff) -> () {
+ let Stuff { inner, .. } = t;
+ Trait::do_stuff({ fun(&mut *inner) });
+ //~^ ERROR the trait bound `*mut (): Trait<'_>` is not satisfied
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/issue-101623.stderr b/src/test/ui/suggestions/issue-101623.stderr
new file mode 100644
index 000000000..361483cc0
--- /dev/null
+++ b/src/test/ui/suggestions/issue-101623.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `*mut (): Trait<'_>` is not satisfied
+ --> $DIR/issue-101623.rs:21:21
+ |
+LL | Trait::do_stuff({ fun(&mut *inner) });
+ | --------------- ^^----------------^^
+ | | |
+ | | the trait `Trait<'_>` is not implemented for `*mut ()`
+ | required by a bound introduced by this call
+ |
+ = help: the trait `Trait<'a>` is implemented for `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/issue-101984.stderr b/src/test/ui/suggestions/issue-101984.stderr
index c744c62d1..81758a700 100644
--- a/src/test/ui/suggestions/issue-101984.stderr
+++ b/src/test/ui/suggestions/issue-101984.stderr
@@ -2,11 +2,11 @@ error[E0308]: mismatched types
--> $DIR/issue-101984.rs:21:13
|
LL | let (cmp, router) = self.router.at()?;
- | ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>`
+ | ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'a> fn(&'a ()), Box<Wrapper>)>`
| |
| expected struct `Match`, found tuple
|
- = note: expected struct `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>`
+ = note: expected struct `Match<&(for<'a> fn(&'a ()), Box<Wrapper>)>`
found tuple `(_, _)`
error: aborting due to previous error
diff --git a/src/test/ui/suggestions/issue-102354.rs b/src/test/ui/suggestions/issue-102354.rs
new file mode 100644
index 000000000..f881feb00
--- /dev/null
+++ b/src/test/ui/suggestions/issue-102354.rs
@@ -0,0 +1,10 @@
+trait Trait {
+ fn func() {}
+}
+
+impl Trait for i32 {}
+
+fn main() {
+ let x: i32 = 123;
+ x.func(); //~ERROR no method
+}
diff --git a/src/test/ui/suggestions/issue-102354.stderr b/src/test/ui/suggestions/issue-102354.stderr
new file mode 100644
index 000000000..4f76c5f2e
--- /dev/null
+++ b/src/test/ui/suggestions/issue-102354.stderr
@@ -0,0 +1,24 @@
+error[E0599]: no method named `func` found for type `i32` in the current scope
+ --> $DIR/issue-102354.rs:9:7
+ |
+LL | x.func();
+ | ^^^^ this is an associated function, not a method
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in the trait `Trait`
+ --> $DIR/issue-102354.rs:2:5
+ |
+LL | fn func() {}
+ | ^^^^^^^^^
+help: use associated function syntax instead
+ |
+LL | i32::func();
+ | ~~~~~~~~~
+help: disambiguate the associated function for the candidate
+ |
+LL | <i32 as Trait>::func(x);
+ | ~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/issue-102892.rs b/src/test/ui/suggestions/issue-102892.rs
new file mode 100644
index 000000000..c1a791d8d
--- /dev/null
+++ b/src/test/ui/suggestions/issue-102892.rs
@@ -0,0 +1,25 @@
+#![allow(dead_code, unused_variables)]
+
+use std::sync::Arc;
+
+#[derive(Debug)]
+struct A;
+#[derive(Debug)]
+struct B;
+
+fn process_without_annot(arc: &Arc<(A, B)>) {
+ let (a, b) = **arc; // suggests putting `&**arc` here; with that, fixed!
+}
+
+fn process_with_annot(arc: &Arc<(A, B)>) {
+ let (a, b): (A, B) = &**arc; // suggests putting `&**arc` here too
+ //~^ ERROR mismatched types
+}
+
+fn process_with_tuple_annot(mutation: &mut (A, B), arc: &Arc<(A, B)>) {
+ let (a, b): ((A, B), A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/issue-102892.stderr b/src/test/ui/suggestions/issue-102892.stderr
new file mode 100644
index 000000000..a3dbc7cb8
--- /dev/null
+++ b/src/test/ui/suggestions/issue-102892.stderr
@@ -0,0 +1,57 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-102892.rs:15:26
+ |
+LL | let (a, b): (A, B) = &**arc; // suggests putting `&**arc` here too
+ | ------ ^^^^^^ expected tuple, found `&(A, B)`
+ | |
+ | expected due to this
+ |
+ = note: expected tuple `(A, B)`
+ found reference `&(A, B)`
+help: consider removing the borrow
+ |
+LL - let (a, b): (A, B) = &**arc; // suggests putting `&**arc` here too
+LL + let (a, b): (A, B) = **arc; // suggests putting `&**arc` here too
+ |
+help: alternatively, consider changing the type annotation
+ |
+LL | let (a, b): &(A, B) = &**arc; // suggests putting `&**arc` here too
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/issue-102892.rs:20:32
+ |
+LL | let (a, b): ((A, B), A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+ | ^^^^^^^^^^^^^^ expected tuple, found `&mut (A, B)`
+ |
+ = note: expected tuple `(A, B)`
+ found mutable reference `&mut (A, B)`
+help: consider removing the borrow
+ |
+LL - let (a, b): ((A, B), A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+LL + let (a, b): ((A, B), A) = (*mutation, &(**arc).0); // suggests putting `&**arc` here too
+ |
+help: alternatively, consider changing the type annotation
+ |
+LL | let (a, b): (&mut (A, B), A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+ | ++++
+
+error[E0308]: mismatched types
+ --> $DIR/issue-102892.rs:20:48
+ |
+LL | let (a, b): ((A, B), A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+ | ^^^^^^^^^^ expected struct `A`, found `&A`
+ |
+help: consider removing the borrow
+ |
+LL - let (a, b): ((A, B), A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+LL + let (a, b): ((A, B), A) = (&mut *mutation, (**arc).0); // suggests putting `&**arc` here too
+ |
+help: alternatively, consider changing the type annotation
+ |
+LL | let (a, b): ((A, B), &A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
+ | +
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-103112.rs b/src/test/ui/suggestions/issue-103112.rs
new file mode 100644
index 000000000..111ae7c73
--- /dev/null
+++ b/src/test/ui/suggestions/issue-103112.rs
@@ -0,0 +1,4 @@
+fn main() {
+ std::process::abort!();
+ //~^ ERROR: failed to resolve
+}
diff --git a/src/test/ui/suggestions/issue-103112.stderr b/src/test/ui/suggestions/issue-103112.stderr
new file mode 100644
index 000000000..4ca7fdf9b
--- /dev/null
+++ b/src/test/ui/suggestions/issue-103112.stderr
@@ -0,0 +1,15 @@
+error[E0433]: failed to resolve: could not find `abort` in `process`
+ --> $DIR/issue-103112.rs:2:19
+ |
+LL | std::process::abort!();
+ | ^^^^^ could not find `abort` in `process`
+ |
+help: std::process::abort is not a macro, but a function, try to remove `!`
+ |
+LL - std::process::abort!();
+LL + std::process::abort();
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/src/test/ui/suggestions/issue-61963.stderr b/src/test/ui/suggestions/issue-61963.stderr
index a788cab6e..b99b1b0b9 100644
--- a/src/test/ui/suggestions/issue-61963.stderr
+++ b/src/test/ui/suggestions/issue-61963.stderr
@@ -4,13 +4,13 @@ error: trait objects without an explicit `dyn` are deprecated
LL | bar: Box<Bar>,
| ^^^
|
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
note: the lint level is defined here
--> $DIR/issue-61963.rs:3:9
|
LL | #![deny(bare_trait_objects)]
| ^^^^^^^^^^^^^^^^^^
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: use `dyn`
|
LL | bar: Box<dyn Bar>,
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
index e5d2ead6a..872263fd7 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
@@ -27,3 +27,4 @@ LL | fn func<'a, T: Test + 'a>(foo: &Foo, t: T) {
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0311`.
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
index ed1b91676..fa758bf05 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -18,7 +18,7 @@ LL | | *dest = g.get();
LL | | }
| |_____^
|
-help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound
+help: to declare that `impl FnOnce()` captures `'_`, you can add an explicit `'_` lifetime bound
|
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| ++++
@@ -164,5 +164,5 @@ LL | G: Get<T> + 'a,
error: aborting due to 8 previous errors
-Some errors have detailed explanations: E0261, E0309, E0621, E0700.
+Some errors have detailed explanations: E0261, E0309, E0311, E0621, E0700.
For more information about an error, try `rustc --explain E0261`.
diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr
index f49876bcd..c77ef79e7 100644
--- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr
+++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr
@@ -10,7 +10,7 @@ LL | | remaining: self.0.iter(),
LL | | }
| |_________^ returning this value requires that `'1` must outlive `'static`
|
-help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'_` lifetime bound
+help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'_` lifetime bound
|
LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
| ++++
@@ -65,7 +65,7 @@ LL | | remaining: self.0.iter(),
LL | | }
| |_________^ returning this value requires that `'a` must outlive `'static`
|
-help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'a` lifetime bound
+help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'a` lifetime bound
|
LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
| ++++
diff --git a/src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr b/src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr
index be6fc2615..00aa7d18a 100644
--- a/src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr
+++ b/src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr
@@ -7,7 +7,7 @@ LL | fn not_all_paths(a: &str) -> u32 {
| implicitly returns `()` as its body has no tail or `return` expression
...
LL | };
- | - help: remove this semicolon
+ | - help: remove this semicolon to return this value
error[E0308]: `match` arms have incompatible types
--> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:26:14
diff --git a/src/test/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr b/src/test/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr
index e0f405eed..9e6f0d9eb 100644
--- a/src/test/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr
+++ b/src/test/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr
@@ -1,11 +1,11 @@
error[E0204]: the trait `Copy` may not be implemented for this type
- --> $DIR/missing-bound-in-manual-copy-impl-2.rs:16:9
+ --> $DIR/missing-bound-in-manual-copy-impl-2.rs:16:18
|
LL | struct Wrapper<T>(T);
| - this field does not implement `Copy`
...
LL | impl<S> Copy for Wrapper<OnlyCopyIfDisplay<S>> {}
- | ^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the `Copy` impl for `OnlyCopyIfDisplay<S>` requires that `S: std::fmt::Display`
--> $DIR/missing-bound-in-manual-copy-impl-2.rs:4:19
diff --git a/src/test/ui/suggestions/missing-bound-in-manual-copy-impl.stderr b/src/test/ui/suggestions/missing-bound-in-manual-copy-impl.stderr
index 218988511..fe2d133c8 100644
--- a/src/test/ui/suggestions/missing-bound-in-manual-copy-impl.stderr
+++ b/src/test/ui/suggestions/missing-bound-in-manual-copy-impl.stderr
@@ -1,11 +1,11 @@
error[E0204]: the trait `Copy` may not be implemented for this type
- --> $DIR/missing-bound-in-manual-copy-impl.rs:6:9
+ --> $DIR/missing-bound-in-manual-copy-impl.rs:6:18
|
LL | struct Wrapper<T>(T);
| - this field does not implement `Copy`
LL |
LL | impl<S> Copy for Wrapper<S> {}
- | ^^^^
+ | ^^^^^^^^^^
|
help: consider restricting type parameter `S`
|
diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield-recursion-limit.rs b/src/test/ui/suggestions/non-existent-field-present-in-subfield-recursion-limit.rs
index 98b408daa..a7a3f9818 100644
--- a/src/test/ui/suggestions/non-existent-field-present-in-subfield-recursion-limit.rs
+++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield-recursion-limit.rs
@@ -1,4 +1,4 @@
-// In rustc_typeck::check::expr::no_such_field_err we recursively
+// In rustc_hir_analysis::check::expr::no_such_field_err we recursively
// look in subfields for the field. This recursive search is limited
// in depth for compile-time reasons and to avoid infinite recursion
// in case of cycles. This file tests that the limit in the recursion
diff --git a/src/test/ui/suggestions/return-closures.stderr b/src/test/ui/suggestions/return-closures.stderr
index e273793ea..8b856d8de 100644
--- a/src/test/ui/suggestions/return-closures.stderr
+++ b/src/test/ui/suggestions/return-closures.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/return-closures.rs:3:5
|
LL | fn foo() {
- | - help: try adding a return type: `-> impl for<'r> Fn(&'r i32) -> i32`
+ | - help: try adding a return type: `-> impl for<'a> Fn(&'a i32) -> i32`
LL |
LL | |x: &i32| 1i32
| ^^^^^^^^^^^^^^ expected `()`, found closure
diff --git a/src/test/ui/suggestions/struct-field-type-including-single-colon.stderr b/src/test/ui/suggestions/struct-field-type-including-single-colon.stderr
index 189759d64..4dd514480 100644
--- a/src/test/ui/suggestions/struct-field-type-including-single-colon.stderr
+++ b/src/test/ui/suggestions/struct-field-type-including-single-colon.stderr
@@ -12,6 +12,8 @@ LL | a: foo::A,
error: expected `,`, or `}`, found `:`
--> $DIR/struct-field-type-including-single-colon.rs:9:11
|
+LL | struct Foo {
+ | --- while parsing this struct
LL | a: foo:A,
| ^
@@ -29,6 +31,8 @@ LL | b: foo::bar::B,
error: expected `,`, or `}`, found `:`
--> $DIR/struct-field-type-including-single-colon.rs:15:16
|
+LL | struct Bar {
+ | --- while parsing this struct
LL | b: foo::bar:B,
| ^
diff --git a/src/test/ui/suggestions/sugg-else-for-closure.fixed b/src/test/ui/suggestions/sugg-else-for-closure.fixed
new file mode 100644
index 000000000..cf381d9da
--- /dev/null
+++ b/src/test/ui/suggestions/sugg-else-for-closure.fixed
@@ -0,0 +1,8 @@
+// run-rustfix
+
+fn main() {
+ let x = "com.example.app";
+ let y: Option<&str> = None;
+ let _s = y.unwrap_or_else(|| x.split('.').nth(1).unwrap());
+ //~^ ERROR: mismatched types [E0308]
+}
diff --git a/src/test/ui/suggestions/sugg-else-for-closure.rs b/src/test/ui/suggestions/sugg-else-for-closure.rs
new file mode 100644
index 000000000..540ced91f
--- /dev/null
+++ b/src/test/ui/suggestions/sugg-else-for-closure.rs
@@ -0,0 +1,8 @@
+// run-rustfix
+
+fn main() {
+ let x = "com.example.app";
+ let y: Option<&str> = None;
+ let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap());
+ //~^ ERROR: mismatched types [E0308]
+}
diff --git a/src/test/ui/suggestions/sugg-else-for-closure.stderr b/src/test/ui/suggestions/sugg-else-for-closure.stderr
new file mode 100644
index 000000000..55a0eee18
--- /dev/null
+++ b/src/test/ui/suggestions/sugg-else-for-closure.stderr
@@ -0,0 +1,23 @@
+error[E0308]: mismatched types
+ --> $DIR/sugg-else-for-closure.rs:6:26
+ |
+LL | let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap());
+ | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&str`, found closure
+ | |
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&str`
+ found closure `[closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28]`
+note: associated function defined here
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ |
+LL | pub const fn unwrap_or(self, default: T) -> T
+ | ^^^^^^^^^
+help: try calling `unwrap_or_else` instead
+ |
+LL | let _s = y.unwrap_or_else(|| x.split('.').nth(1).unwrap());
+ | +++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/suggest-let-for-assignment.fixed b/src/test/ui/suggestions/suggest-let-for-assignment.fixed
new file mode 100644
index 000000000..3a25e25ee
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-let-for-assignment.fixed
@@ -0,0 +1,17 @@
+// run-rustfix
+
+fn main() {
+ let demo = 1; //~ ERROR cannot find value `demo` in this scope
+ dbg!(demo); //~ ERROR cannot find value `demo` in this scope
+
+ let x = "x"; //~ ERROR cannot find value `x` in this scope
+ println!("x: {}", x); //~ ERROR cannot find value `x` in this scope
+
+ if x == "x" {
+ //~^ ERROR cannot find value `x` in this scope
+ println!("x is 1");
+ }
+
+ let y = 1 + 2; //~ ERROR cannot find value `y` in this scope
+ println!("y: {}", y); //~ ERROR cannot find value `y` in this scope
+}
diff --git a/src/test/ui/suggestions/suggest-let-for-assignment.rs b/src/test/ui/suggestions/suggest-let-for-assignment.rs
new file mode 100644
index 000000000..67705fe06
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-let-for-assignment.rs
@@ -0,0 +1,17 @@
+// run-rustfix
+
+fn main() {
+ demo = 1; //~ ERROR cannot find value `demo` in this scope
+ dbg!(demo); //~ ERROR cannot find value `demo` in this scope
+
+ x = "x"; //~ ERROR cannot find value `x` in this scope
+ println!("x: {}", x); //~ ERROR cannot find value `x` in this scope
+
+ if x == "x" {
+ //~^ ERROR cannot find value `x` in this scope
+ println!("x is 1");
+ }
+
+ y = 1 + 2; //~ ERROR cannot find value `y` in this scope
+ println!("y: {}", y); //~ ERROR cannot find value `y` in this scope
+}
diff --git a/src/test/ui/suggestions/suggest-let-for-assignment.stderr b/src/test/ui/suggestions/suggest-let-for-assignment.stderr
new file mode 100644
index 000000000..3f6a3da4b
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-let-for-assignment.stderr
@@ -0,0 +1,60 @@
+error[E0425]: cannot find value `demo` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:4:5
+ |
+LL | demo = 1;
+ | ^^^^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let demo = 1;
+ | +++
+
+error[E0425]: cannot find value `demo` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:5:10
+ |
+LL | dbg!(demo);
+ | ^^^^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:7:5
+ |
+LL | x = "x";
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = "x";
+ | +++
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:8:23
+ |
+LL | println!("x: {}", x);
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:10:8
+ |
+LL | if x == "x" {
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:15:5
+ |
+LL | y = 1 + 2;
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let y = 1 + 2;
+ | +++
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/suggest-let-for-assignment.rs:16:23
+ |
+LL | println!("y: {}", y);
+ | ^ not found in this scope
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr b/src/test/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr
index f716e6c17..ffd505fff 100644
--- a/src/test/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr
+++ b/src/test/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr
@@ -37,9 +37,9 @@ warning: trait objects without an explicit `dyn` are deprecated
LL | impl<'a, T> Struct<T> for Trait<'a, T> {}
| ^^^^^^^^^^^^
|
- = note: `#[warn(bare_trait_objects)]` on by default
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+ = note: `#[warn(bare_trait_objects)]` on by default
help: use `dyn`
|
LL | impl<'a, T> Struct<T> for dyn Trait<'a, T> {}