summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /src/test/ui/suggestions
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/suggestions')
-rw-r--r--src/test/ui/suggestions/assoc-const-as-fn.rs18
-rw-r--r--src/test/ui/suggestions/assoc-const-as-fn.stderr16
-rw-r--r--src/test/ui/suggestions/assoc_fn_without_self.stderr9
-rw-r--r--src/test/ui/suggestions/borrow-for-loop-head.stderr1
-rw-r--r--src/test/ui/suggestions/core-std-import-order-issue-83564.stderr2
-rw-r--r--src/test/ui/suggestions/crate-or-module-typo.stderr12
-rw-r--r--src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs4
-rw-r--r--src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr9
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr23
-rw-r--r--src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr28
-rw-r--r--src/test/ui/suggestions/if-let-typo.stderr15
-rw-r--r--src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs71
-rw-r--r--src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr162
-rw-r--r--src/test/ui/suggestions/inner_type2.rs2
-rw-r--r--src/test/ui/suggestions/inner_type2.stderr2
-rw-r--r--src/test/ui/suggestions/issue-102354.stderr13
-rw-r--r--src/test/ui/suggestions/issue-104086-suggest-let.rs30
-rw-r--r--src/test/ui/suggestions/issue-104086-suggest-let.stderr135
-rw-r--r--src/test/ui/suggestions/issue-104287.rs9
-rw-r--r--src/test/ui/suggestions/issue-104287.stderr36
-rw-r--r--src/test/ui/suggestions/issue-84700.stderr10
-rw-r--r--src/test/ui/suggestions/issue-99240-2.stderr6
-rw-r--r--src/test/ui/suggestions/missing-lifetime-specifier.stderr24
-rw-r--r--src/test/ui/suggestions/multibyte-escapes.rs12
-rw-r--r--src/test/ui/suggestions/multibyte-escapes.stderr12
-rw-r--r--src/test/ui/suggestions/option-to-bool.rs9
-rw-r--r--src/test/ui/suggestions/option-to-bool.stderr16
-rw-r--r--src/test/ui/suggestions/ref-pattern-binding.fixed19
-rw-r--r--src/test/ui/suggestions/ref-pattern-binding.rs19
-rw-r--r--src/test/ui/suggestions/ref-pattern-binding.stderr107
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed15
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs15
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr19
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs11
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr22
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr4
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed26
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs19
-rw-r--r--src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr88
-rw-r--r--src/test/ui/suggestions/suggest-remove-refs-3.stderr4
-rw-r--r--src/test/ui/suggestions/suggest-tryinto-edition-change.rs5
-rw-r--r--src/test/ui/suggestions/suggest-tryinto-edition-change.stderr11
-rw-r--r--src/test/ui/suggestions/suggest_print_over_printf.rs8
-rw-r--r--src/test/ui/suggestions/suggest_print_over_printf.stderr14
-rw-r--r--src/test/ui/suggestions/try-removing-the-field.rs15
-rw-r--r--src/test/ui/suggestions/try-removing-the-field.stderr16
-rw-r--r--src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs6
-rw-r--r--src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr59
48 files changed, 1047 insertions, 141 deletions
diff --git a/src/test/ui/suggestions/assoc-const-as-fn.rs b/src/test/ui/suggestions/assoc-const-as-fn.rs
new file mode 100644
index 000000000..4b4595dd5
--- /dev/null
+++ b/src/test/ui/suggestions/assoc-const-as-fn.rs
@@ -0,0 +1,18 @@
+unsafe fn pointer(v: usize, w: u32) {}
+
+pub trait UniformScalar {}
+impl UniformScalar for u32 {}
+
+pub trait GlUniformScalar: UniformScalar {
+ const FACTORY: unsafe fn(usize, Self) -> ();
+}
+impl GlUniformScalar for u32 {
+ const FACTORY: unsafe fn(usize, Self) -> () = pointer;
+}
+
+pub fn foo<T: UniformScalar>(value: T) {
+ <T as GlUniformScalar>::FACTORY(1, value);
+ //~^ ERROR the trait bound `T: GlUniformScalar` is not satisfied
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/assoc-const-as-fn.stderr b/src/test/ui/suggestions/assoc-const-as-fn.stderr
new file mode 100644
index 000000000..3b6e947c5
--- /dev/null
+++ b/src/test/ui/suggestions/assoc-const-as-fn.stderr
@@ -0,0 +1,16 @@
+error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied
+ --> $DIR/assoc-const-as-fn.rs:14:40
+ |
+LL | <T as GlUniformScalar>::FACTORY(1, value);
+ | ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T`
+ | |
+ | required by a bound introduced by this call
+ |
+help: consider further restricting this bound
+ |
+LL | pub fn foo<T: UniformScalar + GlUniformScalar>(value: T) {
+ | +++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/assoc_fn_without_self.stderr b/src/test/ui/suggestions/assoc_fn_without_self.stderr
index 88920b852..febdd6733 100644
--- a/src/test/ui/suggestions/assoc_fn_without_self.stderr
+++ b/src/test/ui/suggestions/assoc_fn_without_self.stderr
@@ -7,13 +7,18 @@ LL | foo();
help: consider using the associated function
|
LL | Self::foo();
- | ~~~~~~~~~
+ | ++++++
error[E0425]: cannot find function `bar` in this scope
--> $DIR/assoc_fn_without_self.rs:17:9
|
LL | bar();
| ^^^ not found in this scope
+ |
+help: consider using the associated function
+ |
+LL | self.bar();
+ | +++++
error[E0425]: cannot find function `baz` in this scope
--> $DIR/assoc_fn_without_self.rs:18:9
@@ -24,7 +29,7 @@ LL | baz(2, 3);
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
diff --git a/src/test/ui/suggestions/borrow-for-loop-head.stderr b/src/test/ui/suggestions/borrow-for-loop-head.stderr
index 1059e3d15..0cc8994fe 100644
--- a/src/test/ui/suggestions/borrow-for-loop-head.stderr
+++ b/src/test/ui/suggestions/borrow-for-loop-head.stderr
@@ -12,6 +12,7 @@ error[E0382]: use of moved value: `a`
LL | let a = vec![1, 2, 3];
| - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait
LL | for i in &a {
+ | ----------- inside of this loop
LL | for j in a {
| ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop
|
diff --git a/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr b/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr
index ce85d93b9..e4e1fc591 100644
--- a/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr
+++ b/src/test/ui/suggestions/core-std-import-order-issue-83564.stderr
@@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `NonZeroU32`
--> $DIR/core-std-import-order-issue-83564.rs:8:14
|
LL | let _x = NonZeroU32::new(5).unwrap();
- | ^^^^^^^^^^ not found in this scope
+ | ^^^^^^^^^^ use of undeclared type `NonZeroU32`
|
help: consider importing one of these items
|
diff --git a/src/test/ui/suggestions/crate-or-module-typo.stderr b/src/test/ui/suggestions/crate-or-module-typo.stderr
index e8250c9fa..98b88b4fb 100644
--- a/src/test/ui/suggestions/crate-or-module-typo.stderr
+++ b/src/test/ui/suggestions/crate-or-module-typo.stderr
@@ -20,12 +20,6 @@ help: there is a crate or module with a similar name
LL | use bar::bar;
| ~~~
-error[E0433]: failed to resolve: use of undeclared crate or module `bar`
- --> $DIR/crate-or-module-typo.rs:6:20
- |
-LL | pub fn bar() { bar::baz(); }
- | ^^^ use of undeclared crate or module `bar`
-
error[E0433]: failed to resolve: use of undeclared crate or module `st`
--> $DIR/crate-or-module-typo.rs:14:10
|
@@ -37,6 +31,12 @@ help: there is a crate or module with a similar name
LL | bar: std::cell::Cell<bool>
| ~~~
+error[E0433]: failed to resolve: use of undeclared crate or module `bar`
+ --> $DIR/crate-or-module-typo.rs:6:20
+ |
+LL | pub fn bar() { bar::baz(); }
+ | ^^^ use of undeclared crate or module `bar`
+
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0432, E0433.
diff --git a/src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs
new file mode 100644
index 000000000..06cf243f1
--- /dev/null
+++ b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.rs
@@ -0,0 +1,4 @@
+fn main() {
+ 1_u32.MAX();
+ //~^ ERROR no method named `MAX` found for type `u32` in the current scope
+}
diff --git a/src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr
new file mode 100644
index 000000000..0d9543e0b
--- /dev/null
+++ b/src/test/ui/suggestions/dont-suggest-ufcs-for-const.stderr
@@ -0,0 +1,9 @@
+error[E0599]: no method named `MAX` found for type `u32` in the current scope
+ --> $DIR/dont-suggest-ufcs-for-const.rs:2:11
+ |
+LL | 1_u32.MAX();
+ | ^^^ method not found in `u32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
index 77cef485f..34ff59a9b 100644
--- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
+++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -78,20 +78,21 @@ LL | impl<P: Deref<Target: Unpin>> Pin<P> {
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
|
-LL | fn zap() -> BoxFuture<'static, i32> {
- | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
LL | / async {
LL | | 42
LL | | }
- | |_____^ expected struct `Pin`, found opaque type
- |
- ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
- |
-LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
- | ------------------------------- the found opaque type
- |
- = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>`
- found opaque type `impl Future<Output = {integer}>`
+ | | ^
+ | | |
+ | |_____expected struct `Pin`, found `async` block
+ | arguments to this function are incorrect
+ |
+ = note: expected struct `Pin<Box<dyn Future<Output = i32> + Send>>`
+ found `async` block `[async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6]`
+note: function defined here
+ --> $SRC_DIR/core/src/future/mod.rs:LL:COL
+ |
+LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut {
+ | ^^^^^^^^^^^^^^^
help: you need to pin and box this expression
|
LL ~ Box::pin(async {
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 597dc61c3..d0ddb34d9 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
@@ -1,23 +1,3 @@
-error[E0423]: expected value, found struct variant `E::B`
- --> $DIR/fn-or-tuple-struct-without-args.rs:36:16
- |
-LL | A(usize),
- | -------- similarly named tuple variant `A` defined here
-LL | B { a: usize },
- | -------------- `E::B` defined here
-...
-LL | let _: E = E::B;
- | ^^^^
- |
-help: use struct literal syntax instead
- |
-LL | let _: E = E::B { a: val };
- | ~~~~~~~~~~~~~~~
-help: a tuple variant with a similar name exists
- |
-LL | let _: E = E::A;
- | ~
-
error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:29:20
|
@@ -144,6 +124,12 @@ help: use parentheses to construct this tuple variant
LL | let _: E = E::A(/* usize */);
| +++++++++++++
+error[E0533]: expected value, found struct variant `E::B`
+ --> $DIR/fn-or-tuple-struct-without-args.rs:36:16
+ |
+LL | let _: E = E::B;
+ | ^^^^ not a value
+
error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:37:20
|
@@ -293,5 +279,5 @@ LL | let _: usize = closure();
error: aborting due to 17 previous errors
-Some errors have detailed explanations: E0308, E0423, E0615.
+Some errors have detailed explanations: E0308, E0533, E0615.
For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/if-let-typo.stderr b/src/test/ui/suggestions/if-let-typo.stderr
index 3d9ac40ec..02148b7f7 100644
--- a/src/test/ui/suggestions/if-let-typo.stderr
+++ b/src/test/ui/suggestions/if-let-typo.stderr
@@ -25,12 +25,22 @@ error[E0308]: mismatched types
|
LL | if Some(x) = foo {}
| ^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: consider adding `let`
+ |
+LL | if let Some(x) = foo {}
+ | +++
error[E0308]: mismatched types
--> $DIR/if-let-typo.rs:6:8
|
LL | if Some(foo) = bar {}
| ^^^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: consider adding `let`
+ |
+LL | if let Some(foo) = bar {}
+ | +++
error[E0308]: mismatched types
--> $DIR/if-let-typo.rs:7:8
@@ -51,6 +61,11 @@ error[E0308]: mismatched types
|
LL | if Some(3) = foo {}
| ^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: consider adding `let`
+ |
+LL | if let Some(3) = foo {}
+ | +++
error: aborting due to 7 previous errors
diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs
index fe291e021..a1a51c481 100644
--- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs
+++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.rs
@@ -2,20 +2,67 @@
// gate-test-anonymous_lifetime_in_impl_trait
// Verify the behaviour of `feature(anonymous_lifetime_in_impl_trait)`.
-fn f(_: impl Iterator<Item = &'_ ()>) {}
-//~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+mod elided {
+ fn f(_: impl Iterator<Item = &()>) {}
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
-fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
-//~^ ERROR anonymous lifetimes in `impl Trait` are unstable
-//~| ERROR missing lifetime specifier
+ fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+ //~| ERROR missing lifetime specifier
-// Anonymous lifetimes in async fn are already allowed.
-// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
-async fn h(_: impl Iterator<Item = &'_ ()>) {}
+ // Anonymous lifetimes in async fn are already allowed.
+ // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
+ async fn h(_: impl Iterator<Item = &()>) {}
-// Anonymous lifetimes in async fn are already allowed.
-// But that lifetime does not participate in resolution.
-async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
-//~^ ERROR missing lifetime specifier
+ // Anonymous lifetimes in async fn are already allowed.
+ // But that lifetime does not participate in resolution.
+ async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
+ //~^ ERROR missing lifetime specifier
+}
+
+mod underscore {
+ fn f(_: impl Iterator<Item = &'_ ()>) {}
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+
+ fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+ //~| ERROR missing lifetime specifier
+
+ // Anonymous lifetimes in async fn are already allowed.
+ // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
+ async fn h(_: impl Iterator<Item = &'_ ()>) {}
+
+ // Anonymous lifetimes in async fn are already allowed.
+ // But that lifetime does not participate in resolution.
+ async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
+ //~^ ERROR missing lifetime specifier
+}
+
+mod alone_in_path {
+ trait Foo<'a> { fn next(&mut self) -> Option<&'a ()>; }
+
+ fn f(_: impl Foo) {}
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+
+ fn g(mut x: impl Foo) -> Option<&()> { x.next() }
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+ //~| ERROR missing lifetime specifier
+}
+
+mod in_path {
+ trait Foo<'a, T> { fn next(&mut self) -> Option<&'a T>; }
+
+ fn f(_: impl Foo<()>) {}
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+
+ fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
+ //~^ ERROR anonymous lifetimes in `impl Trait` are unstable
+ //~| ERROR missing lifetime specifier
+}
+
+// This must not err, as the `&` actually resolves to `'a`.
+fn resolved_anonymous<'a, T>(f: impl Fn(&'a str) -> &T) {
+ f("f")
+}
fn main() {}
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 9833da13f..50806a672 100644
--- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
+++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
@@ -1,52 +1,172 @@
error[E0106]: missing lifetime specifier
- --> $DIR/impl-trait-missing-lifetime-gated.rs:8:50
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:9:54
|
-LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
- | ^^ expected named lifetime parameter
+LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
+ | ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
|
-LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
- | ~~~~~~~
+LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() }
+ | +++++++
error[E0106]: missing lifetime specifier
- --> $DIR/impl-trait-missing-lifetime-gated.rs:18:56
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:19:60
|
-LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
- | ^^ expected named lifetime parameter
+LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
+ | ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
|
-LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
- | ~~~~~~~
+LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() }
+ | +++++++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:27:58
+ |
+LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
+ | ^^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
+help: consider using the `'static` lifetime
+ |
+LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
+ | ~~~~~~~
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:37:64
+ |
+LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
+ | ^^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
+help: consider using the `'static` lifetime
+ |
+LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
+ | ~~~~~~~
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:47:37
+ |
+LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() }
+ | ^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
+help: consider using the `'static` lifetime
+ |
+LL | fn g(mut x: impl Foo) -> Option<&'static ()> { x.next() }
+ | +++++++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:58:41
+ |
+LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
+ | ^ expected named lifetime parameter
+ |
+ = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
+help: consider using the `'static` lifetime
+ |
+LL | fn g(mut x: impl Foo<()>) -> Option<&'static ()> { x.next() }
+ | +++++++
+
+error[E0658]: anonymous lifetimes in `impl Trait` are unstable
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:6:35
+ |
+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:9:39
+ |
+LL | fn g(mut 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>(mut x: impl Iterator<Item = &'a ()>) -> Option<&()> { x.next() }
+ | ++++ ++
+
+error[E0658]: anonymous lifetimes in `impl Trait` are unstable
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:24:35
+ |
+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:27:39
+ |
+LL | fn g(mut 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>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'_ ()> { x.next() }
+ | ++++ ~~
+
+error[E0658]: anonymous lifetimes in `impl Trait` are unstable
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:44:18
+ |
+LL | fn f(_: impl Foo) {}
+ | ^^^ 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 Foo<'a>) {}
+ | ++++ ++++
+
+error[E0658]: anonymous lifetimes in `impl Trait` are unstable
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:47:22
+ |
+LL | fn g(mut x: impl Foo) -> 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>(mut x: impl Foo<'a>) -> Option<&()> { x.next() }
+ | ++++ ++++
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
- --> $DIR/impl-trait-missing-lifetime-gated.rs:5:31
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:55:22
|
-LL | fn f(_: impl Iterator<Item = &'_ ()>) {}
- | ^^ expected named lifetime parameter
+LL | fn f(_: impl Foo<()>) {}
+ | ^ 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 ()>) {}
- | ++++ ++
+LL | fn f<'a>(_: impl Foo<'a, ()>) {}
+ | ++++ +++
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
- --> $DIR/impl-trait-missing-lifetime-gated.rs:8:31
+ --> $DIR/impl-trait-missing-lifetime-gated.rs:58:26
|
-LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
- | ^^ expected named lifetime parameter
+LL | fn g(mut x: impl Foo<()>) -> 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() }
- | ++++ ++
+LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() }
+ | ++++ +++
-error: aborting due to 4 previous errors
+error: aborting due to 14 previous errors
Some errors have detailed explanations: E0106, E0658.
For more information about an error, try `rustc --explain E0106`.
diff --git a/src/test/ui/suggestions/inner_type2.rs b/src/test/ui/suggestions/inner_type2.rs
index c56ea7c03..fac68c053 100644
--- a/src/test/ui/suggestions/inner_type2.rs
+++ b/src/test/ui/suggestions/inner_type2.rs
@@ -22,5 +22,5 @@ fn main() {
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
+ //~| 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
index eddfd9d63..984366123 100644
--- a/src/test/ui/suggestions/inner_type2.stderr
+++ b/src/test/ui/suggestions/inner_type2.stderr
@@ -17,7 +17,7 @@ error[E0599]: no method named `method` found for union `MaybeUninit` in the curr
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
+ = 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
|
diff --git a/src/test/ui/suggestions/issue-102354.stderr b/src/test/ui/suggestions/issue-102354.stderr
index 4f76c5f2e..08d4b9955 100644
--- a/src/test/ui/suggestions/issue-102354.stderr
+++ b/src/test/ui/suggestions/issue-102354.stderr
@@ -2,7 +2,10 @@ 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
+ | --^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `i32::func()`
|
= 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`
@@ -10,14 +13,6 @@ note: the candidate is defined in the trait `Trait`
|
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
diff --git a/src/test/ui/suggestions/issue-104086-suggest-let.rs b/src/test/ui/suggestions/issue-104086-suggest-let.rs
new file mode 100644
index 000000000..d22ad27d0
--- /dev/null
+++ b/src/test/ui/suggestions/issue-104086-suggest-let.rs
@@ -0,0 +1,30 @@
+fn main() {
+ x = x = x;
+ //~^ ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `x` in this scope
+
+ x = y = y = y;
+ //~^ ERROR cannot find value `y` in this scope
+ //~| ERROR cannot find value `y` in this scope
+ //~| ERROR cannot find value `y` in this scope
+ //~| ERROR cannot find value `x` in this scope
+
+ x = y = y;
+ //~^ ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `y` in this scope
+ //~| ERROR cannot find value `y` in this scope
+
+ x = x = y;
+ //~^ ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `y` in this scope
+
+ x = x; // will suggest add `let`
+ //~^ ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `x` in this scope
+
+ x = y // will suggest add `let`
+ //~^ ERROR cannot find value `x` in this scope
+ //~| ERROR cannot find value `y` in this scope
+}
diff --git a/src/test/ui/suggestions/issue-104086-suggest-let.stderr b/src/test/ui/suggestions/issue-104086-suggest-let.stderr
new file mode 100644
index 000000000..fb4ea3121
--- /dev/null
+++ b/src/test/ui/suggestions/issue-104086-suggest-let.stderr
@@ -0,0 +1,135 @@
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:2:5
+ |
+LL | x = x = x;
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = x = x;
+ | +++
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:2:9
+ |
+LL | x = x = x;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:2:13
+ |
+LL | x = x = x;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:7:5
+ |
+LL | x = y = y = y;
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = y = y = y;
+ | +++
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:7:9
+ |
+LL | x = y = y = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:7:13
+ |
+LL | x = y = y = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:7:17
+ |
+LL | x = y = y = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:13:5
+ |
+LL | x = y = y;
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = y = y;
+ | +++
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:13:9
+ |
+LL | x = y = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:13:13
+ |
+LL | x = y = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:18:5
+ |
+LL | x = x = y;
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = x = y;
+ | +++
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:18:9
+ |
+LL | x = x = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:18:13
+ |
+LL | x = x = y;
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:23:5
+ |
+LL | x = x; // will suggest add `let`
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = x; // will suggest add `let`
+ | +++
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:23:9
+ |
+LL | x = x; // will suggest add `let`
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:27:5
+ |
+LL | x = y // will suggest add `let`
+ | ^
+ |
+help: you might have meant to introduce a new binding
+ |
+LL | let x = y // will suggest add `let`
+ | +++
+
+error[E0425]: cannot find value `y` in this scope
+ --> $DIR/issue-104086-suggest-let.rs:27:9
+ |
+LL | x = y // will suggest add `let`
+ | ^ not found in this scope
+
+error: aborting due to 17 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/suggestions/issue-104287.rs b/src/test/ui/suggestions/issue-104287.rs
new file mode 100644
index 000000000..b7601a548
--- /dev/null
+++ b/src/test/ui/suggestions/issue-104287.rs
@@ -0,0 +1,9 @@
+// The purpose of this test is not to validate the output of the compiler.
+// Instead, it ensures the suggestion is generated without performing an arithmetic overflow.
+
+fn main() {
+ let x = not_found; //~ ERROR cannot find value `not_found` in this scope
+ simd_gt::<()>(x);
+ //~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied
+ //~| ERROR cannot find function `simd_gt` in this scope
+}
diff --git a/src/test/ui/suggestions/issue-104287.stderr b/src/test/ui/suggestions/issue-104287.stderr
new file mode 100644
index 000000000..4b302dd65
--- /dev/null
+++ b/src/test/ui/suggestions/issue-104287.stderr
@@ -0,0 +1,36 @@
+error[E0425]: cannot find value `not_found` in this scope
+ --> $DIR/issue-104287.rs:5:13
+ |
+LL | let x = not_found;
+ | ^^^^^^^^^ not found in this scope
+
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/issue-104287.rs:6:5
+ |
+LL | simd_gt::<()>(x);
+ | ^^^^^^^------ help: remove these generics
+ | |
+ | expected 0 generic arguments
+ |
+note: associated function defined here, with 0 generic parameters
+ --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/ord.rs:LL:COL
+ |
+LL | fn simd_gt(self, other: Self) -> Self::Mask;
+ | ^^^^^^^
+
+error[E0425]: cannot find function `simd_gt` in this scope
+ --> $DIR/issue-104287.rs:6:5
+ |
+LL | simd_gt::<()>(x);
+ | ^^^^^^^ not found in this scope
+ |
+help: use the `.` operator to call the method `SimdPartialOrd::simd_gt` on `[type error]`
+ |
+LL - simd_gt::<()>(x);
+LL + x.simd_gt();
+ |
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0107, E0425.
+For more information about an error, try `rustc --explain E0107`.
diff --git a/src/test/ui/suggestions/issue-84700.stderr b/src/test/ui/suggestions/issue-84700.stderr
index b36d8aba3..ac9f5ab0b 100644
--- a/src/test/ui/suggestions/issue-84700.stderr
+++ b/src/test/ui/suggestions/issue-84700.stderr
@@ -7,15 +7,13 @@ LL | Cow,
LL | FarmAnimal::Cow(_) => "moo".to_string(),
| ^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FarmAnimal::Cow`
-error[E0532]: expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken`
+error[E0164]: expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken`
--> $DIR/issue-84700.rs:17:9
|
-LL | Chicken { num_eggs: usize },
- | --------------------------- `FarmAnimal::Chicken` defined here
-...
LL | FarmAnimal::Chicken(_) => "cluck, cluck!".to_string(),
- | ^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FarmAnimal::Chicken { num_eggs }`
+ | ^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0532`.
+Some errors have detailed explanations: E0164, E0532.
+For more information about an error, try `rustc --explain E0164`.
diff --git a/src/test/ui/suggestions/issue-99240-2.stderr b/src/test/ui/suggestions/issue-99240-2.stderr
index 2af60f597..260df8565 100644
--- a/src/test/ui/suggestions/issue-99240-2.stderr
+++ b/src/test/ui/suggestions/issue-99240-2.stderr
@@ -5,12 +5,12 @@ LL | Unit,
| ---- enum variant `Alias::Unit` defined here
...
LL | Alias::
- | _____^
- | |_____|
+ | ______^
+ | | _____|
| ||
LL | || Unit();
| ||________^_- call expression requires function
- | |_________|
+ | |________|
|
|
help: `Alias::Unit` is a unit enum variant, and does not take parentheses to be constructed
diff --git a/src/test/ui/suggestions/missing-lifetime-specifier.stderr b/src/test/ui/suggestions/missing-lifetime-specifier.stderr
index 10fb28c18..997bbb5e9 100644
--- a/src/test/ui/suggestions/missing-lifetime-specifier.stderr
+++ b/src/test/ui/suggestions/missing-lifetime-specifier.stderr
@@ -166,8 +166,8 @@ LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
- | ++++
+LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++++
error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing-lifetime-specifier.rs:39:44
@@ -184,8 +184,8 @@ LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
- | ++++
+LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++++
error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing-lifetime-specifier.rs:39:44
@@ -202,8 +202,8 @@ LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
- | ++++
+LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++++
error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing-lifetime-specifier.rs:39:44
@@ -256,8 +256,8 @@ LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
- | ++++
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++++
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing-lifetime-specifier.rs:47:45
@@ -274,8 +274,8 @@ LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
- | ++++
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++++
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing-lifetime-specifier.rs:47:45
@@ -292,8 +292,8 @@ LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
- | ++++
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++++
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing-lifetime-specifier.rs:47:45
diff --git a/src/test/ui/suggestions/multibyte-escapes.rs b/src/test/ui/suggestions/multibyte-escapes.rs
index fd5d46a4e..c41051862 100644
--- a/src/test/ui/suggestions/multibyte-escapes.rs
+++ b/src/test/ui/suggestions/multibyte-escapes.rs
@@ -2,17 +2,17 @@
fn main() {
b'µ';
- //~^ ERROR: non-ASCII character in byte constant
+ //~^ ERROR: non-ASCII character in byte literal
//~| HELP: if you meant to use the unicode code point for 'µ', use a \xHH escape
- //~| NOTE: byte constant must be ASCII
+ //~| NOTE: must be ASCII
b'字';
- //~^ ERROR: non-ASCII character in byte constant
+ //~^ ERROR: non-ASCII character in byte literal
//~| NOTE: this multibyte character does not fit into a single byte
- //~| NOTE: byte constant must be ASCII
+ //~| NOTE: must be ASCII
b"字";
- //~^ ERROR: non-ASCII character in byte constant
+ //~^ ERROR: non-ASCII character in byte string literal
//~| HELP: if you meant to use the UTF-8 encoding of '字', use \xHH escapes
- //~| NOTE: byte constant must be ASCII
+ //~| NOTE: must be ASCII
}
diff --git a/src/test/ui/suggestions/multibyte-escapes.stderr b/src/test/ui/suggestions/multibyte-escapes.stderr
index 6e26bc1f0..1e7c43e65 100644
--- a/src/test/ui/suggestions/multibyte-escapes.stderr
+++ b/src/test/ui/suggestions/multibyte-escapes.stderr
@@ -1,28 +1,28 @@
-error: non-ASCII character in byte constant
+error: non-ASCII character in byte literal
--> $DIR/multibyte-escapes.rs:4:7
|
LL | b'µ';
- | ^ byte constant must be ASCII
+ | ^ must be ASCII
|
help: if you meant to use the unicode code point for 'µ', use a \xHH escape
|
LL | b'\xB5';
| ~~~~
-error: non-ASCII character in byte constant
+error: non-ASCII character in byte literal
--> $DIR/multibyte-escapes.rs:9:7
|
LL | b'字';
| ^^
| |
- | byte constant must be ASCII
+ | must be ASCII
| this multibyte character does not fit into a single byte
-error: non-ASCII character in byte constant
+error: non-ASCII character in byte string literal
--> $DIR/multibyte-escapes.rs:14:7
|
LL | b"字";
- | ^^ byte constant must be ASCII
+ | ^^ must be ASCII
|
help: if you meant to use the UTF-8 encoding of '字', use \xHH escapes
|
diff --git a/src/test/ui/suggestions/option-to-bool.rs b/src/test/ui/suggestions/option-to-bool.rs
new file mode 100644
index 000000000..2a1823b15
--- /dev/null
+++ b/src/test/ui/suggestions/option-to-bool.rs
@@ -0,0 +1,9 @@
+#![cfg_attr(let_chains, feature(let_chains))]
+
+fn foo(x: Option<i32>) {
+ if true && x {}
+ //~^ ERROR mismatched types
+ //~| HELP use `Option::is_some` to test if the `Option` has a value
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/option-to-bool.stderr b/src/test/ui/suggestions/option-to-bool.stderr
new file mode 100644
index 000000000..57a934b83
--- /dev/null
+++ b/src/test/ui/suggestions/option-to-bool.stderr
@@ -0,0 +1,16 @@
+error[E0308]: mismatched types
+ --> $DIR/option-to-bool.rs:4:16
+ |
+LL | if true && x {}
+ | ^ expected `bool`, found enum `Option`
+ |
+ = note: expected type `bool`
+ found enum `Option<i32>`
+help: use `Option::is_some` to test if the `Option` has a value
+ |
+LL | if true && x.is_some() {}
+ | ++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/ref-pattern-binding.fixed b/src/test/ui/suggestions/ref-pattern-binding.fixed
new file mode 100644
index 000000000..c36040eec
--- /dev/null
+++ b/src/test/ui/suggestions/ref-pattern-binding.fixed
@@ -0,0 +1,19 @@
+// run-rustfix
+#![allow(unused)]
+
+struct S {
+ f: String,
+}
+
+fn main() {
+ let ref _moved @ ref _from = String::from("foo"); //~ ERROR
+ let ref _moved @ ref _from = String::from("foo"); //~ ERROR
+ let ref _moved @ ref _from = String::from("foo"); //~ ERROR
+ //~^ ERROR
+ let ref _moved @ ref _from = String::from("foo"); // ok
+ let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
+ let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
+ //~^ ERROR
+ let ref _moved @ S { ref f } = S { f: String::from("foo") }; // ok
+ let ref _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
+}
diff --git a/src/test/ui/suggestions/ref-pattern-binding.rs b/src/test/ui/suggestions/ref-pattern-binding.rs
new file mode 100644
index 000000000..c0d4feb03
--- /dev/null
+++ b/src/test/ui/suggestions/ref-pattern-binding.rs
@@ -0,0 +1,19 @@
+// run-rustfix
+#![allow(unused)]
+
+struct S {
+ f: String,
+}
+
+fn main() {
+ let _moved @ _from = String::from("foo"); //~ ERROR
+ let _moved @ ref _from = String::from("foo"); //~ ERROR
+ let ref _moved @ _from = String::from("foo"); //~ ERROR
+ //~^ ERROR
+ let ref _moved @ ref _from = String::from("foo"); // ok
+ let _moved @ S { f } = S { f: String::from("foo") }; //~ ERROR
+ let ref _moved @ S { f } = S { f: String::from("foo") }; //~ ERROR
+ //~^ ERROR
+ let ref _moved @ S { ref f } = S { f: String::from("foo") }; // ok
+ let _moved @ S { ref f } = S { f: String::from("foo") }; //~ ERROR
+}
diff --git a/src/test/ui/suggestions/ref-pattern-binding.stderr b/src/test/ui/suggestions/ref-pattern-binding.stderr
new file mode 100644
index 000000000..10447ba70
--- /dev/null
+++ b/src/test/ui/suggestions/ref-pattern-binding.stderr
@@ -0,0 +1,107 @@
+error: borrow of moved value
+ --> $DIR/ref-pattern-binding.rs:10:9
+ |
+LL | let _moved @ ref _from = String::from("foo");
+ | ------^^^---------
+ | | |
+ | | value borrowed here after move
+ | value moved into `_moved` here
+ | move occurs because `_moved` has type `String` which does not implement the `Copy` trait
+ |
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | let ref _moved @ ref _from = String::from("foo");
+ | +++
+
+error: cannot move out of value because it is borrowed
+ --> $DIR/ref-pattern-binding.rs:11:9
+ |
+LL | let ref _moved @ _from = String::from("foo");
+ | ----------^^^-----
+ | | |
+ | | value moved into `_from` here
+ | value borrowed, by `_moved`, here
+
+error: cannot move out of value because it is borrowed
+ --> $DIR/ref-pattern-binding.rs:15:9
+ |
+LL | let ref _moved @ S { f } = S { f: String::from("foo") };
+ | ----------^^^^^^^-^^
+ | | |
+ | | value moved into `f` here
+ | value borrowed, by `_moved`, here
+
+error: borrow of moved value
+ --> $DIR/ref-pattern-binding.rs:18:9
+ |
+LL | let _moved @ S { ref f } = S { f: String::from("foo") };
+ | ------^^^^^^^-----^^
+ | | |
+ | | value borrowed here after move
+ | value moved into `_moved` here
+ | move occurs because `_moved` has type `S` which does not implement the `Copy` trait
+ |
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | let ref _moved @ S { ref f } = S { f: String::from("foo") };
+ | +++
+
+error[E0382]: use of moved value
+ --> $DIR/ref-pattern-binding.rs:9:9
+ |
+LL | let _moved @ _from = String::from("foo");
+ | ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait
+ | | |
+ | | value moved here
+ | value used here after move
+ |
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | let ref _moved @ ref _from = String::from("foo");
+ | +++ +++
+
+error[E0382]: borrow of moved value
+ --> $DIR/ref-pattern-binding.rs:11:9
+ |
+LL | let ref _moved @ _from = String::from("foo");
+ | ^^^^^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait
+ | | |
+ | | value moved here
+ | value borrowed here after move
+ |
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | let ref _moved @ ref _from = String::from("foo");
+ | +++
+
+error[E0382]: use of partially moved value
+ --> $DIR/ref-pattern-binding.rs:14:9
+ |
+LL | let _moved @ S { f } = S { f: String::from("foo") };
+ | ^^^^^^ - value partially moved here
+ | |
+ | value used here after partial move
+ |
+ = note: partial move occurs because value has type `String`, which does not implement the `Copy` trait
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | let ref _moved @ S { ref f } = S { f: String::from("foo") };
+ | +++ +++
+
+error[E0382]: borrow of partially moved value
+ --> $DIR/ref-pattern-binding.rs:15:9
+ |
+LL | let ref _moved @ S { f } = S { f: String::from("foo") };
+ | ^^^^^^^^^^ - value partially moved here
+ | |
+ | value borrowed here after partial move
+ |
+ = note: partial move occurs because value has type `String`, which does not implement the `Copy` trait
+help: borrow this binding in the pattern to avoid moving the value
+ |
+LL | let ref _moved @ S { ref f } = S { f: String::from("foo") };
+ | +++
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0382`.
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed
new file mode 100644
index 000000000..8d96cf590
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.fixed
@@ -0,0 +1,15 @@
+// run-rustfix
+
+#![allow(unused)]
+
+struct Foo<T>(T);
+
+impl<T> Foo<T> {
+ fn test() -> i32 { 1 }
+}
+
+fn main() {
+ let x = Box::new(Foo(1i32));
+ Foo::<i32>::test();
+ //~^ ERROR no method named `test` found for struct `Box<Foo<i32>>` in the current scope
+}
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs
new file mode 100644
index 000000000..186901f75
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.rs
@@ -0,0 +1,15 @@
+// run-rustfix
+
+#![allow(unused)]
+
+struct Foo<T>(T);
+
+impl<T> Foo<T> {
+ fn test() -> i32 { 1 }
+}
+
+fn main() {
+ let x = Box::new(Foo(1i32));
+ x.test();
+ //~^ ERROR no method named `test` found for struct `Box<Foo<i32>>` in the current scope
+}
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr
new file mode 100644
index 000000000..00fb96f03
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr
@@ -0,0 +1,19 @@
+error[E0599]: no method named `test` found for struct `Box<Foo<i32>>` in the current scope
+ --> $DIR/suggest-assoc-fn-call-deref.rs:13:7
+ |
+LL | x.test();
+ | --^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `Foo::<i32>::test()`
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `Foo<T>`
+ --> $DIR/suggest-assoc-fn-call-deref.rs:8:5
+ |
+LL | fn test() -> i32 { 1 }
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs
new file mode 100644
index 000000000..a39b8711d
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs
@@ -0,0 +1,11 @@
+struct GenericAssocMethod<T>(T);
+
+impl<T> GenericAssocMethod<T> {
+ fn default_hello() {}
+}
+
+fn main() {
+ let x = GenericAssocMethod(33);
+ x.default_hello();
+ //~^ ERROR no method named `default_hello` found
+}
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr
new file mode 100644
index 000000000..c247e73b3
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr
@@ -0,0 +1,22 @@
+error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
+ --> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:9:7
+ |
+LL | struct GenericAssocMethod<T>(T);
+ | ---------------------------- method `default_hello` not found for this struct
+...
+LL | x.default_hello();
+ | --^^^^^^^^^^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `GenericAssocMethod::<_>::default_hello()`
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
+ --> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:4:5
+ |
+LL | fn default_hello() {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr
index 996d57731..7c9f0b6c2 100644
--- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.stderr
@@ -2,10 +2,10 @@ error[E0599]: no method named `hello` found for struct `RefMut<'_, HasAssocMetho
--> $DIR/suggest-assoc-fn-call-with-turbofish-through-deref.rs:11:11
|
LL | state.hello();
- | ------^^^^^
+ | ------^^^^^--
| | |
| | this is an associated function, not a method
- | help: use associated function syntax instead: `HasAssocMethod::hello`
+ | help: use associated function syntax instead: `HasAssocMethod::hello()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `HasAssocMethod`
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed
new file mode 100644
index 000000000..02dd0715c
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed
@@ -0,0 +1,26 @@
+// run-rustfix
+
+struct GenericAssocMethod<T>(T);
+
+impl<T> GenericAssocMethod<T> {
+ fn default_hello() {}
+ fn self_ty_hello(_: Self) {}
+ fn self_ty_ref_hello(_: &Self) {}
+}
+
+fn main() {
+ // Test for inferred types
+ let x = GenericAssocMethod(33);
+ GenericAssocMethod::<_>::self_ty_ref_hello(&x);
+ //~^ ERROR no method named `self_ty_ref_hello` found
+ GenericAssocMethod::<_>::self_ty_hello(x);
+ //~^ ERROR no method named `self_ty_hello` found
+ // Test for known types
+ let y = GenericAssocMethod(33i32);
+ GenericAssocMethod::<i32>::default_hello();
+ //~^ ERROR no method named `default_hello` found
+ GenericAssocMethod::<i32>::self_ty_ref_hello(&y);
+ //~^ ERROR no method named `self_ty_ref_hello` found
+ GenericAssocMethod::<i32>::self_ty_hello(y);
+ //~^ ERROR no method named `self_ty_hello` found
+}
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs
index 2a829db53..1d0ca8e78 100644
--- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs
@@ -1,11 +1,26 @@
+// run-rustfix
+
struct GenericAssocMethod<T>(T);
impl<T> GenericAssocMethod<T> {
fn default_hello() {}
+ fn self_ty_hello(_: Self) {}
+ fn self_ty_ref_hello(_: &Self) {}
}
fn main() {
- let x = GenericAssocMethod(33i32);
- x.default_hello();
+ // Test for inferred types
+ let x = GenericAssocMethod(33);
+ x.self_ty_ref_hello();
+ //~^ ERROR no method named `self_ty_ref_hello` found
+ x.self_ty_hello();
+ //~^ ERROR no method named `self_ty_hello` found
+ // Test for known types
+ let y = GenericAssocMethod(33i32);
+ y.default_hello();
//~^ ERROR no method named `default_hello` found
+ y.self_ty_ref_hello();
+ //~^ ERROR no method named `self_ty_ref_hello` found
+ y.self_ty_hello();
+ //~^ ERROR no method named `self_ty_hello` found
}
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr
index 3fb418b1c..92b03fc77 100644
--- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr
+++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr
@@ -1,22 +1,98 @@
+error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:14:7
+ |
+LL | struct GenericAssocMethod<T>(T);
+ | ---------------------------- method `self_ty_ref_hello` not found for this struct
+...
+LL | x.self_ty_ref_hello();
+ | --^^^^^^^^^^^^^^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `GenericAssocMethod::<_>::self_ty_ref_hello(&x)`
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:8:5
+ |
+LL | fn self_ty_ref_hello(_: &Self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:16:7
+ |
+LL | struct GenericAssocMethod<T>(T);
+ | ---------------------------- method `self_ty_hello` not found for this struct
+...
+LL | x.self_ty_hello();
+ | --^^^^^^^^^^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `GenericAssocMethod::<_>::self_ty_hello(x)`
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:7:5
+ |
+LL | fn self_ty_hello(_: Self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<i32>` in the current scope
- --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:9:7
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:20:7
|
LL | struct GenericAssocMethod<T>(T);
| ---------------------------- method `default_hello` not found for this struct
...
-LL | x.default_hello();
- | --^^^^^^^^^^^^^
+LL | y.default_hello();
+ | --^^^^^^^^^^^^^--
| | |
| | this is an associated function, not a method
- | help: use associated function syntax instead: `GenericAssocMethod::<i32>::default_hello`
+ | help: use associated function syntax instead: `GenericAssocMethod::<i32>::default_hello()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
- --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:4:5
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:6:5
|
LL | fn default_hello() {}
| ^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<i32>` in the current scope
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:22:7
+ |
+LL | struct GenericAssocMethod<T>(T);
+ | ---------------------------- method `self_ty_ref_hello` not found for this struct
+...
+LL | y.self_ty_ref_hello();
+ | --^^^^^^^^^^^^^^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `GenericAssocMethod::<i32>::self_ty_ref_hello(&y)`
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:8:5
+ |
+LL | fn self_ty_ref_hello(_: &Self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<i32>` in the current scope
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:24:7
+ |
+LL | struct GenericAssocMethod<T>(T);
+ | ---------------------------- method `self_ty_hello` not found for this struct
+...
+LL | y.self_ty_hello();
+ | --^^^^^^^^^^^^^--
+ | | |
+ | | this is an associated function, not a method
+ | help: use associated function syntax instead: `GenericAssocMethod::<i32>::self_ty_hello(y)`
+ |
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
+ --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:7:5
+ |
+LL | fn self_ty_hello(_: Self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/suggest-remove-refs-3.stderr b/src/test/ui/suggestions/suggest-remove-refs-3.stderr
index 4d0732427..31cca323d 100644
--- a/src/test/ui/suggestions/suggest-remove-refs-3.stderr
+++ b/src/test/ui/suggestions/suggest-remove-refs-3.stderr
@@ -2,8 +2,8 @@ error[E0277]: `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterat
--> $DIR/suggest-remove-refs-3.rs:6:19
|
LL | for (i, _) in & & &
- | ___________________^
- | |___________________|
+ | ____________________^
+ | | ___________________|
| ||
LL | || & &v
| ||___________- help: consider removing 5 leading `&`-references
diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs
index f03b42bbe..70c4b210d 100644
--- a/src/test/ui/suggestions/suggest-tryinto-edition-change.rs
+++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.rs
@@ -10,18 +10,19 @@ fn test() {
let _i: i16 = TryFrom::try_from(0_i32).unwrap();
//~^ ERROR failed to resolve: use of undeclared type
- //~| NOTE not found in this scope
+ //~| NOTE use of undeclared type
//~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
//~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
let _i: i16 = TryInto::try_into(0_i32).unwrap();
//~^ ERROR failed to resolve: use of undeclared type
- //~| NOTE not found in this scope
+ //~| NOTE use of undeclared type
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
//~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021
let _v: Vec<_> = FromIterator::from_iter(&[1]);
//~^ ERROR failed to resolve: use of undeclared type
+ //~| NOTE use of undeclared type
//~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
//~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
}
diff --git a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr
index 86f48716b..3d1f24923 100644
--- a/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr
+++ b/src/test/ui/suggestions/suggest-tryinto-edition-change.stderr
@@ -2,7 +2,7 @@ error[E0433]: failed to resolve: use of undeclared type `TryFrom`
--> $DIR/suggest-tryinto-edition-change.rs:11:19
|
LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap();
- | ^^^^^^^ not found in this scope
+ | ^^^^^^^ use of undeclared type `TryFrom`
|
= note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
= note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
@@ -17,7 +17,7 @@ error[E0433]: failed to resolve: use of undeclared type `TryInto`
--> $DIR/suggest-tryinto-edition-change.rs:17:19
|
LL | let _i: i16 = TryInto::try_into(0_i32).unwrap();
- | ^^^^^^^ not found in this scope
+ | ^^^^^^^ use of undeclared type `TryInto`
|
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
= note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021
@@ -32,12 +32,7 @@ error[E0433]: failed to resolve: use of undeclared type `FromIterator`
--> $DIR/suggest-tryinto-edition-change.rs:23:22
|
LL | let _v: Vec<_> = FromIterator::from_iter(&[1]);
- | ^^^^^^^^^^^^
- |
- ::: $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | pub trait IntoIterator {
- | ---------------------- similarly named trait `IntoIterator` defined here
+ | ^^^^^^^^^^^^ use of undeclared type `FromIterator`
|
= note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
= note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
diff --git a/src/test/ui/suggestions/suggest_print_over_printf.rs b/src/test/ui/suggestions/suggest_print_over_printf.rs
new file mode 100644
index 000000000..124ddec50
--- /dev/null
+++ b/src/test/ui/suggestions/suggest_print_over_printf.rs
@@ -0,0 +1,8 @@
+// Suggest print macro when user erroneously uses printf
+
+fn main() {
+ let x = 4;
+ printf("%d", x);
+ //~^ ERROR cannot find function `printf` in this scope
+ //~| HELP you may have meant to use the `print` macro
+}
diff --git a/src/test/ui/suggestions/suggest_print_over_printf.stderr b/src/test/ui/suggestions/suggest_print_over_printf.stderr
new file mode 100644
index 000000000..1214bec16
--- /dev/null
+++ b/src/test/ui/suggestions/suggest_print_over_printf.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find function `printf` in this scope
+ --> $DIR/suggest_print_over_printf.rs:5:5
+ |
+LL | printf("%d", x);
+ | ^^^^^^ not found in this scope
+ |
+help: you may have meant to use the `print` macro
+ |
+LL | print!("%d", x);
+ | ~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/suggestions/try-removing-the-field.rs b/src/test/ui/suggestions/try-removing-the-field.rs
index 9d0573ca2..1b7289b22 100644
--- a/src/test/ui/suggestions/try-removing-the-field.rs
+++ b/src/test/ui/suggestions/try-removing-the-field.rs
@@ -14,4 +14,19 @@ fn use_foo(x: Foo) -> i32 {
return foo;
}
+// issue #105028, suggest removing the field only for shorthand
+fn use_match(x: Foo) {
+ match x {
+ Foo { foo: unused, .. } => { //~ WARNING unused variable
+ //~| help: if this is intentional, prefix it with an underscore
+ }
+ }
+
+ match x {
+ Foo { foo, .. } => { //~ WARNING unused variable
+ //~| help: try removing the field
+ }
+ }
+}
+
fn main() {}
diff --git a/src/test/ui/suggestions/try-removing-the-field.stderr b/src/test/ui/suggestions/try-removing-the-field.stderr
index 448a2c3d2..7a6013d4a 100644
--- a/src/test/ui/suggestions/try-removing-the-field.stderr
+++ b/src/test/ui/suggestions/try-removing-the-field.stderr
@@ -8,5 +8,19 @@ LL | let Foo { foo, bar, .. } = x;
|
= note: `#[warn(unused_variables)]` on by default
-warning: 1 warning emitted
+warning: unused variable: `unused`
+ --> $DIR/try-removing-the-field.rs:20:20
+ |
+LL | Foo { foo: unused, .. } => {
+ | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
+
+warning: unused variable: `foo`
+ --> $DIR/try-removing-the-field.rs:26:15
+ |
+LL | Foo { foo, .. } => {
+ | ^^^-
+ | |
+ | help: try removing the field
+
+warning: 3 warnings emitted
diff --git a/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs
new file mode 100644
index 000000000..c1a944562
--- /dev/null
+++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.rs
@@ -0,0 +1,6 @@
+fn main() {
+ let _: f64 = 0..10; //~ ERROR mismatched types
+ let _: f64 = 1..; //~ ERROR mismatched types
+ let _: f64 = ..10; //~ ERROR mismatched types
+ let _: f64 = std::ops::Range { start: 0, end: 1 }; //~ ERROR mismatched types
+}
diff --git a/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr
new file mode 100644
index 000000000..773f1392a
--- /dev/null
+++ b/src/test/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr
@@ -0,0 +1,59 @@
+error[E0308]: mismatched types
+ --> $DIR/unnecessary_dot_for_floating_point_literal.rs:2:18
+ |
+LL | let _: f64 = 0..10;
+ | --- ^^^^^ expected `f64`, found struct `std::ops::Range`
+ | |
+ | expected due to this
+ |
+ = note: expected type `f64`
+ found struct `std::ops::Range<{integer}>`
+help: remove the unnecessary `.` operator for a floating point literal
+ |
+LL | let _: f64 = 0.10;
+ | ~
+
+error[E0308]: mismatched types
+ --> $DIR/unnecessary_dot_for_floating_point_literal.rs:3:18
+ |
+LL | let _: f64 = 1..;
+ | --- ^^^ expected `f64`, found struct `RangeFrom`
+ | |
+ | expected due to this
+ |
+ = note: expected type `f64`
+ found struct `RangeFrom<{integer}>`
+help: remove the unnecessary `.` operator for a floating point literal
+ |
+LL | let _: f64 = 1.;
+ | ~
+
+error[E0308]: mismatched types
+ --> $DIR/unnecessary_dot_for_floating_point_literal.rs:4:18
+ |
+LL | let _: f64 = ..10;
+ | --- ^^^^ expected `f64`, found struct `RangeTo`
+ | |
+ | expected due to this
+ |
+ = note: expected type `f64`
+ found struct `RangeTo<{integer}>`
+help: remove the unnecessary `.` operator and add an integer part for a floating point literal
+ |
+LL | let _: f64 = 0.10;
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/unnecessary_dot_for_floating_point_literal.rs:5:18
+ |
+LL | let _: f64 = std::ops::Range { start: 0, end: 1 };
+ | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `f64`, found struct `std::ops::Range`
+ | |
+ | expected due to this
+ |
+ = note: expected type `f64`
+ found struct `std::ops::Range<{integer}>`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.