summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/suggestions')
-rw-r--r--tests/ui/suggestions/chain-method-call-mutation-in-place.stderr5
-rw-r--r--tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr2
-rw-r--r--tests/ui/suggestions/deref-path-method.stderr7
-rw-r--r--tests/ui/suggestions/dont-suggest-ref/simple.stderr8
-rw-r--r--tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr4
-rw-r--r--tests/ui/suggestions/impl-trait-missing-lifetime.stderr6
-rw-r--r--tests/ui/suggestions/issue-101623.stderr3
-rw-r--r--tests/ui/suggestions/issue-102972.fixed41
-rw-r--r--tests/ui/suggestions/issue-102972.rs25
-rw-r--r--tests/ui/suggestions/issue-102972.stderr56
-rw-r--r--tests/ui/suggestions/issue-104961.fixed4
-rw-r--r--tests/ui/suggestions/issue-104961.rs4
-rw-r--r--tests/ui/suggestions/issue-104961.stderr4
-rw-r--r--tests/ui/suggestions/issue-109291.stderr7
-rw-r--r--tests/ui/suggestions/issue-61963.stderr5
-rw-r--r--tests/ui/suggestions/issue-62843.stderr2
-rw-r--r--tests/ui/suggestions/issue-81839.stderr15
-rw-r--r--tests/ui/suggestions/issue-83892.stderr2
-rw-r--r--tests/ui/suggestions/issue-84973-blacklist.rs2
-rw-r--r--tests/ui/suggestions/issue-84973-blacklist.stderr4
-rw-r--r--tests/ui/suggestions/lifetimes/issue-105544.fixed14
-rw-r--r--tests/ui/suggestions/lifetimes/issue-105544.rs6
-rw-r--r--tests/ui/suggestions/lifetimes/issue-105544.stderr104
-rw-r--r--tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed7
-rw-r--r--tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs7
-rw-r--r--tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr23
-rw-r--r--tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr99
-rw-r--r--tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed47
-rw-r--r--tests/ui/suggestions/lifetimes/type-param-bound-scope.rs47
-rw-r--r--tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr71
-rw-r--r--tests/ui/suggestions/lifetimes/type-param-missing-lifetime.fixed52
-rw-r--r--tests/ui/suggestions/lifetimes/type-param-missing-lifetime.rs52
-rw-r--r--tests/ui/suggestions/lifetimes/type-param-missing-lifetime.stderr66
-rw-r--r--tests/ui/suggestions/missing-lifetime-specifier.stderr8
-rw-r--r--tests/ui/suggestions/path-display.stderr2
-rw-r--r--tests/ui/suggestions/restrict-existing-type-bounds.stderr4
-rw-r--r--tests/ui/suggestions/return-closures.stderr4
-rw-r--r--tests/ui/suggestions/silenced-binding-typo.fixed5
-rw-r--r--tests/ui/suggestions/silenced-binding-typo.rs5
-rw-r--r--tests/ui/suggestions/silenced-binding-typo.stderr14
-rw-r--r--tests/ui/suggestions/slice-issue-87994.stderr8
-rw-r--r--tests/ui/suggestions/suggest-dereferencing-index.stderr3
-rw-r--r--tests/ui/suggestions/suggest-impl-trait-lifetime.fixed3
-rw-r--r--tests/ui/suggestions/suggest-impl-trait-lifetime.rs3
-rw-r--r--tests/ui/suggestions/suggest-impl-trait-lifetime.stderr7
-rw-r--r--tests/ui/suggestions/suggest-ret-on-async-w-late.fixed14
-rw-r--r--tests/ui/suggestions/suggest-ret-on-async-w-late.rs3
-rw-r--r--tests/ui/suggestions/suggest-ret-on-async-w-late.stderr4
-rw-r--r--tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr2
-rw-r--r--tests/ui/suggestions/trait-hidden-method.stderr2
-rw-r--r--tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr2
-rw-r--r--tests/ui/suggestions/unnamable-types.rs2
-rw-r--r--tests/ui/suggestions/unnamable-types.stderr2
-rw-r--r--tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr2
54 files changed, 689 insertions, 211 deletions
diff --git a/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr b/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr
index 128160f10..2dd6fb6a3 100644
--- a/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr
+++ b/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr
@@ -18,7 +18,10 @@ error[E0599]: no method named `sort` found for unit type `()` in the current sco
--> $DIR/chain-method-call-mutation-in-place.rs:3:72
|
LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
- | ^^^^ method not found in `()`
+ | ------------- --------------------- ^^^^ method not found in `()`
+ | | |
+ | | method `sort` is available on `&mut [i32]`
+ | method `sort` is available on `Vec<i32>`
|
note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
--> $DIR/chain-method-call-mutation-in-place.rs:3:53
diff --git a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
index 0716005c6..8c973995c 100644
--- a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
+++ b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn wat<T>(t: &T) -> T {
| - - expected `T` because of return type
| |
- | this type parameter
+ | expected this type parameter
LL | t.clone()
| ^^^^^^^^^ expected type parameter `T`, found `&T`
|
diff --git a/tests/ui/suggestions/deref-path-method.stderr b/tests/ui/suggestions/deref-path-method.stderr
index 1cc37d611..0372a7e6c 100644
--- a/tests/ui/suggestions/deref-path-method.stderr
+++ b/tests/ui/suggestions/deref-path-method.stderr
@@ -4,6 +4,13 @@ error[E0599]: no function or associated item named `contains` found for struct `
LL | Vec::contains(&vec, &0);
| ^^^^^^^^ function or associated item not found in `Vec<_, _>`
|
+note: if you're trying to build a new `Vec<_, _>` consider using one of the following associated functions:
+ Vec::<T>::new
+ Vec::<T>::with_capacity
+ Vec::<T>::from_raw_parts
+ Vec::<T, A>::new_in
+ and 2 others
+ --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: the function `contains` is implemented on `[_]`
|
LL | <[_]>::contains(&vec, &0);
diff --git a/tests/ui/suggestions/dont-suggest-ref/simple.stderr b/tests/ui/suggestions/dont-suggest-ref/simple.stderr
index 526326524..7d902dbcc 100644
--- a/tests/ui/suggestions/dont-suggest-ref/simple.stderr
+++ b/tests/ui/suggestions/dont-suggest-ref/simple.stderr
@@ -43,7 +43,7 @@ LL - while let Either::One(_t) = *r { }
LL + while let Either::One(_t) = r { }
|
-error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:47:11
|
LL | match *r {
@@ -124,7 +124,7 @@ LL - while let Either::One(_t) = *rm { }
LL + while let Either::One(_t) = rm { }
|
-error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:70:11
|
LL | match *rm {
@@ -392,7 +392,7 @@ LL - while let &Either::One(_t) = r { }
LL + while let Either::One(_t) = r { }
|
-error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference
+error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:155:11
|
LL | match r {
@@ -491,7 +491,7 @@ LL - while let &mut Either::One(_t) = rm { }
LL + while let Either::One(_t) = rm { }
|
-error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference
+error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:187:11
|
LL | match rm {
diff --git a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
index 5093448d2..7c81825e5 100644
--- a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
+++ b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
|
LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
- | - this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
+ | - found this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
LL | // We could instead use an `async` block, but this way we have no std spans.
LL | x
| ^ expected `Pin<Box<...>>`, found type parameter `F`
@@ -30,7 +30,7 @@ error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
|
LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
- | - this type parameter
+ | - found this type parameter
LL | Pin::new(x)
| -------- ^ expected `Box<dyn Future<Output = ...> + Send>`, found type parameter `F`
| |
diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime.stderr
index b476d6101..2c29cfa0b 100644
--- a/tests/ui/suggestions/impl-trait-missing-lifetime.stderr
+++ b/tests/ui/suggestions/impl-trait-missing-lifetime.stderr
@@ -26,9 +26,9 @@ error: lifetime may not live long enough
--> $DIR/impl-trait-missing-lifetime.rs:16:69
|
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
- | -------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static`
- | |
- | return type `impl Future<Output = Option<&'static ()>>` contains a lifetime `'1`
+ | ----------------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static`
+ | |
+ | return type `impl Future<Output = Option<&'static ()>>` contains a lifetime `'1`
error: aborting due to 3 previous errors
diff --git a/tests/ui/suggestions/issue-101623.stderr b/tests/ui/suggestions/issue-101623.stderr
index 361483cc0..9f00de174 100644
--- a/tests/ui/suggestions/issue-101623.stderr
+++ b/tests/ui/suggestions/issue-101623.stderr
@@ -7,7 +7,8 @@ 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 `()`
+ = help: the trait `Trait<'_>` is implemented for `()`
+ = help: for that trait implementation, expected `()`, found `*mut ()`
error: aborting due to previous error
diff --git a/tests/ui/suggestions/issue-102972.fixed b/tests/ui/suggestions/issue-102972.fixed
new file mode 100644
index 000000000..ebd73b2dc
--- /dev/null
+++ b/tests/ui/suggestions/issue-102972.fixed
@@ -0,0 +1,41 @@
+// run-rustfix
+
+fn test1() {
+ let mut chars = "Hello".chars();
+ let iter = chars.by_ref();
+ while let Some(_c) = iter.next() {
+ iter.next(); //~ ERROR cannot borrow `chars` as mutable more than once at a time
+ }
+}
+
+fn test2() {
+ let v = vec![1, 2, 3];
+ let mut iter = v.iter();
+ while let Some(_i) = iter.next() {
+ iter.next(); //~ ERROR borrow of moved value: `iter`
+ }
+}
+
+fn test3() {
+ let v = vec![(), (), ()];
+ let mut i = v.iter();
+ let iter = i.by_ref();
+ while let Some(()) = iter.next() {
+ iter.next(); //~ ERROR cannot borrow `i`
+ }
+}
+
+fn test4() {
+ let v = vec![(), (), ()];
+ let mut iter = v.iter();
+ while let Some(()) = iter.next() {
+ iter.next(); //~ ERROR borrow of moved value: `iter`
+ }
+}
+
+fn main() {
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/tests/ui/suggestions/issue-102972.rs b/tests/ui/suggestions/issue-102972.rs
index 106288b05..1f8e97767 100644
--- a/tests/ui/suggestions/issue-102972.rs
+++ b/tests/ui/suggestions/issue-102972.rs
@@ -1,3 +1,5 @@
+// run-rustfix
+
fn test1() {
let mut chars = "Hello".chars();
for _c in chars.by_ref() {
@@ -13,4 +15,25 @@ fn test2() {
}
}
-fn main() { }
+fn test3() {
+ let v = vec![(), (), ()];
+ let mut i = v.iter();
+ for () in i.by_ref() {
+ i.next(); //~ ERROR cannot borrow `i`
+ }
+}
+
+fn test4() {
+ let v = vec![(), (), ()];
+ let mut iter = v.iter();
+ for () in iter {
+ iter.next(); //~ ERROR borrow of moved value: `iter`
+ }
+}
+
+fn main() {
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/tests/ui/suggestions/issue-102972.stderr b/tests/ui/suggestions/issue-102972.stderr
index 3303d6bbc..4b0d3b96f 100644
--- a/tests/ui/suggestions/issue-102972.stderr
+++ b/tests/ui/suggestions/issue-102972.stderr
@@ -1,5 +1,5 @@
error[E0499]: cannot borrow `chars` as mutable more than once at a time
- --> $DIR/issue-102972.rs:4:9
+ --> $DIR/issue-102972.rs:6:9
|
LL | for _c in chars.by_ref() {
| --------------
@@ -8,9 +8,17 @@ LL | for _c in chars.by_ref() {
| first borrow later used here
LL | chars.next();
| ^^^^^ second mutable borrow occurs here
+ |
+ = note: a for loop advances the iterator for you, the result is stored in `_c`
+help: if you want to call `next` on a iterator within the loop, consider using `while let`
+ |
+LL ~ let iter = chars.by_ref();
+LL ~ while let Some(_c) = iter.next() {
+LL ~ iter.next();
+ |
error[E0382]: borrow of moved value: `iter`
- --> $DIR/issue-102972.rs:12:9
+ --> $DIR/issue-102972.rs:14:9
|
LL | let mut iter = v.iter();
| -------- move occurs because `iter` has type `std::slice::Iter<'_, i32>`, which does not implement the `Copy` trait
@@ -19,10 +27,52 @@ LL | for _i in iter {
LL | iter.next();
| ^^^^ value borrowed here after move
|
+ = note: a for loop advances the iterator for you, the result is stored in `_i`
note: `into_iter` takes ownership of the receiver `self`, which moves `iter`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
+help: if you want to call `next` on a iterator within the loop, consider using `while let`
+ |
+LL | while let Some(_i) = iter.next() {
+ | ~~~~~~~~~~~~~~~ ~~~ +++++++
+
+error[E0499]: cannot borrow `i` as mutable more than once at a time
+ --> $DIR/issue-102972.rs:22:9
+ |
+LL | for () in i.by_ref() {
+ | ----------
+ | |
+ | first mutable borrow occurs here
+ | first borrow later used here
+LL | i.next();
+ | ^ second mutable borrow occurs here
+ |
+ = note: a for loop advances the iterator for you, the result is stored in its pattern
+help: if you want to call `next` on a iterator within the loop, consider using `while let`
+ |
+LL ~ let iter = i.by_ref();
+LL ~ while let Some(()) = iter.next() {
+LL ~ iter.next();
+ |
+
+error[E0382]: borrow of moved value: `iter`
+ --> $DIR/issue-102972.rs:30:9
+ |
+LL | let mut iter = v.iter();
+ | -------- move occurs because `iter` has type `std::slice::Iter<'_, ()>`, which does not implement the `Copy` trait
+LL | for () in iter {
+ | ---- `iter` moved due to this implicit call to `.into_iter()`
+LL | iter.next();
+ | ^^^^ value borrowed here after move
+ |
+ = note: a for loop advances the iterator for you, the result is stored in its pattern
+note: `into_iter` takes ownership of the receiver `self`, which moves `iter`
+ --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
+help: if you want to call `next` on a iterator within the loop, consider using `while let`
+ |
+LL | while let Some(()) = iter.next() {
+ | ~~~~~~~~~~~~~~~ ~~~ +++++++
-error: aborting due to 2 previous errors
+error: aborting due to 4 previous errors
Some errors have detailed explanations: E0382, E0499.
For more information about an error, try `rustc --explain E0382`.
diff --git a/tests/ui/suggestions/issue-104961.fixed b/tests/ui/suggestions/issue-104961.fixed
index 520d638b1..36917cf33 100644
--- a/tests/ui/suggestions/issue-104961.fixed
+++ b/tests/ui/suggestions/issue-104961.fixed
@@ -2,12 +2,12 @@
fn foo(x: &str) -> bool {
x.starts_with(&("hi".to_string() + " you"))
- //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+ //~^ ERROR expected a `FnMut(char)` closure, found `String`
}
fn foo2(x: &str) -> bool {
x.starts_with(&"hi".to_string())
- //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+ //~^ ERROR expected a `FnMut(char)` closure, found `String`
}
fn main() {
diff --git a/tests/ui/suggestions/issue-104961.rs b/tests/ui/suggestions/issue-104961.rs
index aeb787abb..25a8e0c45 100644
--- a/tests/ui/suggestions/issue-104961.rs
+++ b/tests/ui/suggestions/issue-104961.rs
@@ -2,12 +2,12 @@
fn foo(x: &str) -> bool {
x.starts_with("hi".to_string() + " you")
- //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+ //~^ ERROR expected a `FnMut(char)` closure, found `String`
}
fn foo2(x: &str) -> bool {
x.starts_with("hi".to_string())
- //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+ //~^ ERROR expected a `FnMut(char)` closure, found `String`
}
fn main() {
diff --git a/tests/ui/suggestions/issue-104961.stderr b/tests/ui/suggestions/issue-104961.stderr
index 8cec6a3f8..7e795a74c 100644
--- a/tests/ui/suggestions/issue-104961.stderr
+++ b/tests/ui/suggestions/issue-104961.stderr
@@ -1,4 +1,4 @@
-error[E0277]: expected a `FnMut<(char,)>` closure, found `String`
+error[E0277]: expected a `FnMut(char)` closure, found `String`
--> $DIR/issue-104961.rs:4:19
|
LL | x.starts_with("hi".to_string() + " you")
@@ -15,7 +15,7 @@ help: consider borrowing here
LL | x.starts_with(&("hi".to_string() + " you"))
| ++ +
-error[E0277]: expected a `FnMut<(char,)>` closure, found `String`
+error[E0277]: expected a `FnMut(char)` closure, found `String`
--> $DIR/issue-104961.rs:9:19
|
LL | x.starts_with("hi".to_string())
diff --git a/tests/ui/suggestions/issue-109291.stderr b/tests/ui/suggestions/issue-109291.stderr
index 4ef5948d9..644841fdf 100644
--- a/tests/ui/suggestions/issue-109291.stderr
+++ b/tests/ui/suggestions/issue-109291.stderr
@@ -6,6 +6,13 @@ LL | println!("Custom backtrace: {}", std::backtrace::Backtrace::forced_capt
| |
| function or associated item not found in `Backtrace`
| help: there is an associated function with a similar name: `force_capture`
+ |
+note: if you're trying to build a new `Backtrace` consider using one of the following associated functions:
+ Backtrace::capture
+ Backtrace::force_capture
+ Backtrace::disabled
+ Backtrace::create
+ --> $SRC_DIR/std/src/backtrace.rs:LL:COL
error: aborting due to previous error
diff --git a/tests/ui/suggestions/issue-61963.stderr b/tests/ui/suggestions/issue-61963.stderr
index b99b1b0b9..ec62153b0 100644
--- a/tests/ui/suggestions/issue-61963.stderr
+++ b/tests/ui/suggestions/issue-61963.stderr
@@ -37,6 +37,7 @@ 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: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use `dyn`
|
LL | bar: Box<dyn Bar>,
@@ -50,6 +51,7 @@ 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: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use `dyn`
|
LL | bar: Box<dyn Bar>,
@@ -63,6 +65,7 @@ LL | pub struct Foo {
|
= 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: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use `dyn`
|
LL | dyn pub struct Foo {
@@ -76,6 +79,7 @@ LL | pub struct Foo {
|
= 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: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use `dyn`
|
LL | dyn pub struct Foo {
@@ -89,6 +93,7 @@ LL | pub struct Foo {
|
= 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: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use `dyn`
|
LL | dyn pub struct Foo {
diff --git a/tests/ui/suggestions/issue-62843.stderr b/tests/ui/suggestions/issue-62843.stderr
index b6e271de8..ead8f1854 100644
--- a/tests/ui/suggestions/issue-62843.stderr
+++ b/tests/ui/suggestions/issue-62843.stderr
@@ -1,4 +1,4 @@
-error[E0277]: expected a `FnMut<(char,)>` closure, found `String`
+error[E0277]: expected a `FnMut(char)` closure, found `String`
--> $DIR/issue-62843.rs:4:32
|
LL | println!("{:?}", line.find(pattern));
diff --git a/tests/ui/suggestions/issue-81839.stderr b/tests/ui/suggestions/issue-81839.stderr
index 6d0a0c7b3..238ee637c 100644
--- a/tests/ui/suggestions/issue-81839.stderr
+++ b/tests/ui/suggestions/issue-81839.stderr
@@ -4,15 +4,22 @@ error[E0308]: `match` arms have incompatible types
LL | / match num {
LL | | 1 => {
LL | | cx.answer_str("hi");
- | | --------------------
- | | | |
- | | | help: consider removing this semicolon
- | | this is found to be of type `()`
+ | | -------------------- this is found to be of type `()`
LL | | }
LL | | _ => cx.answer_str("hi"),
| | ^^^^^^^^^^^^^^^^^^^ expected `()`, found future
LL | | }
| |_____- `match` arms have incompatible types
+ |
+help: consider removing this semicolon
+ |
+LL - cx.answer_str("hi");
+LL + cx.answer_str("hi")
+ |
+help: consider using a semicolon here, but this will discard any values in the match arms
+ |
+LL | };
+ | +
error: aborting due to previous error
diff --git a/tests/ui/suggestions/issue-83892.stderr b/tests/ui/suggestions/issue-83892.stderr
index baf6b1447..5e471819b 100644
--- a/tests/ui/suggestions/issue-83892.stderr
+++ b/tests/ui/suggestions/issue-83892.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-83892.rs:9:15
|
LL | fn main() {
- | - expected `()` because of default return type
+ | - expected `()` because of default return type
LL | match () {
LL | () => func()
| ^^^^^^ expected `()`, found `u8`
diff --git a/tests/ui/suggestions/issue-84973-blacklist.rs b/tests/ui/suggestions/issue-84973-blacklist.rs
index 6813b07a2..6a35d779c 100644
--- a/tests/ui/suggestions/issue-84973-blacklist.rs
+++ b/tests/ui/suggestions/issue-84973-blacklist.rs
@@ -1,7 +1,7 @@
// Checks that certain traits for which we don't want to suggest borrowing
// are blacklisted and don't cause the suggestion to be issued.
-#![feature(generators)]
+#![feature(coroutines)]
fn f_copy<T: Copy>(t: T) {}
fn f_clone<T: Clone>(t: T) {}
diff --git a/tests/ui/suggestions/issue-84973-blacklist.stderr b/tests/ui/suggestions/issue-84973-blacklist.stderr
index c8ce146ce..e0bdb6949 100644
--- a/tests/ui/suggestions/issue-84973-blacklist.stderr
+++ b/tests/ui/suggestions/issue-84973-blacklist.stderr
@@ -31,11 +31,11 @@ LL + #[derive(Clone)]
LL | struct S;
|
-error[E0277]: `{static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22}` cannot be unpinned
+error[E0277]: `{static coroutine@$DIR/issue-84973-blacklist.rs:17:13: 17:22}` cannot be unpinned
--> $DIR/issue-84973-blacklist.rs:17:13
|
LL | f_unpin(static || { yield; });
- | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22}`
+ | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/issue-84973-blacklist.rs:17:13: 17:22}`
| |
| required by a bound introduced by this call
|
diff --git a/tests/ui/suggestions/lifetimes/issue-105544.fixed b/tests/ui/suggestions/lifetimes/issue-105544.fixed
index 47087eb47..c92114e18 100644
--- a/tests/ui/suggestions/lifetimes/issue-105544.fixed
+++ b/tests/ui/suggestions/lifetimes/issue-105544.fixed
@@ -2,7 +2,7 @@
#![allow(warnings)]
-fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized` must be valid for the anonymous lifetime defined here...
+fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + 'a { //~ NOTE the parameter type `impl Sized` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
(d, p)
//~^ ERROR the parameter type `impl Sized` may not live long enough
@@ -10,19 +10,20 @@ fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ { //~ NOTE the
}
fn foo1<'b>(d: impl Sized + 'b, p: &'b mut ()) -> impl Sized + '_ {
-//~^ HELP consider adding an explicit lifetime bound...
+//~^ NOTE the parameter type `impl Sized` must be valid for the lifetime `'b` as defined here...
+//~| HELP consider adding an explicit lifetime bound
(d, p) //~ NOTE ...so that the type `impl Sized` will meet its required lifetime bounds
//~^ ERROR the parameter type `impl Sized` may not live long enough
}
-fn foo2<'b, 'a>(d: impl Sized + 'a + 'b, p: &'b mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here...
+fn foo2<'b, 'a>(d: impl Sized + 'a + 'b, p: &'b mut ()) -> impl Sized + 'b { //~ NOTE the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
(d, p)
//~^ ERROR the parameter type `impl Sized + 'a` may not live long enough
//~| NOTE ...so that the type `impl Sized + 'a` will meet its required lifetime bounds
}
-fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here...
+fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + 'a { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
(d, p)
//~^ ERROR the parameter type `T` may not live long enough
@@ -30,12 +31,13 @@ fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + '_ { //~ NOTE th
}
fn bar1<'b, T : Sized + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ {
-//~^ HELP consider adding an explicit lifetime bound...
+//~^ NOTE the parameter type `T` must be valid for the lifetime `'b` as defined here...
+//~| HELP consider adding an explicit lifetime bound
(d, p) //~ NOTE ...so that the type `T` will meet its required lifetime bounds
//~^ ERROR the parameter type `T` may not live long enough
}
-fn bar2<'b, 'a, T : Sized + 'a + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here...
+fn bar2<'b, 'a, T : Sized + 'a + 'b>(d: T, p: &'b mut ()) -> impl Sized + 'b { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
(d, p)
//~^ ERROR the parameter type `T` may not live long enough
diff --git a/tests/ui/suggestions/lifetimes/issue-105544.rs b/tests/ui/suggestions/lifetimes/issue-105544.rs
index bd3bc1ef9..bbd0f097f 100644
--- a/tests/ui/suggestions/lifetimes/issue-105544.rs
+++ b/tests/ui/suggestions/lifetimes/issue-105544.rs
@@ -10,7 +10,8 @@ fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter ty
}
fn foo1<'b>(d: impl Sized, p: &'b mut ()) -> impl Sized + '_ {
-//~^ HELP consider adding an explicit lifetime bound...
+//~^ NOTE the parameter type `impl Sized` must be valid for the lifetime `'b` as defined here...
+//~| HELP consider adding an explicit lifetime bound
(d, p) //~ NOTE ...so that the type `impl Sized` will meet its required lifetime bounds
//~^ ERROR the parameter type `impl Sized` may not live long enough
}
@@ -30,7 +31,8 @@ fn bar<T : Sized>(d: T, p: & mut ()) -> impl Sized + '_ { //~ NOTE the parameter
}
fn bar1<'b, T : Sized>(d: T, p: &'b mut ()) -> impl Sized + '_ {
-//~^ HELP consider adding an explicit lifetime bound...
+//~^ NOTE the parameter type `T` must be valid for the lifetime `'b` as defined here...
+//~| HELP consider adding an explicit lifetime bound
(d, p) //~ NOTE ...so that the type `T` will meet its required lifetime bounds
//~^ ERROR the parameter type `T` may not live long enough
}
diff --git a/tests/ui/suggestions/lifetimes/issue-105544.stderr b/tests/ui/suggestions/lifetimes/issue-105544.stderr
index 08fe21b11..553643c0c 100644
--- a/tests/ui/suggestions/lifetimes/issue-105544.stderr
+++ b/tests/ui/suggestions/lifetimes/issue-105544.stderr
@@ -1,108 +1,86 @@
error[E0311]: the parameter type `impl Sized` may not live long enough
--> $DIR/issue-105544.rs:7:5
|
-LL | (d, p)
- | ^^^^^^
- |
-note: the parameter type `impl Sized` must be valid for the anonymous lifetime defined here...
- --> $DIR/issue-105544.rs:5:26
- |
LL | fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ {
- | ^^^^^^^
-note: ...so that the type `impl Sized` will meet its required lifetime bounds
- --> $DIR/issue-105544.rs:7:5
- |
+ | ------- the parameter type `impl Sized` must be valid for the anonymous lifetime defined here...
+LL |
LL | (d, p)
- | ^^^^^^
-help: consider adding an explicit lifetime bound...
+ | ^^^^^^ ...so that the type `impl Sized` will meet its required lifetime bounds
|
-LL | fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ {
- | ++++ ++++ ++
+help: consider adding an explicit lifetime bound
+ |
+LL | fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + 'a {
+ | ++++ ++++ ++ ~~
error[E0309]: the parameter type `impl Sized` may not live long enough
- --> $DIR/issue-105544.rs:14:5
+ --> $DIR/issue-105544.rs:15:5
|
+LL | fn foo1<'b>(d: impl Sized, p: &'b mut ()) -> impl Sized + '_ {
+ | -- the parameter type `impl Sized` must be valid for the lifetime `'b` as defined here...
+...
LL | (d, p)
| ^^^^^^ ...so that the type `impl Sized` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn foo1<'b>(d: impl Sized + 'b, p: &'b mut ()) -> impl Sized + '_ {
| ++++
error[E0311]: the parameter type `impl Sized + 'a` may not live long enough
- --> $DIR/issue-105544.rs:20:5
- |
-LL | (d, p)
- | ^^^^^^
- |
-note: the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here...
- --> $DIR/issue-105544.rs:18:36
+ --> $DIR/issue-105544.rs:21:5
|
LL | fn foo2<'a>(d: impl Sized + 'a, p: &mut ()) -> impl Sized + '_ {
- | ^^^^^^^
-note: ...so that the type `impl Sized + 'a` will meet its required lifetime bounds
- --> $DIR/issue-105544.rs:20:5
- |
+ | ------- the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here...
+LL |
LL | (d, p)
- | ^^^^^^
-help: consider adding an explicit lifetime bound...
+ | ^^^^^^ ...so that the type `impl Sized + 'a` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
|
-LL | fn foo2<'b, 'a>(d: impl Sized + 'a + 'b, p: &'b mut ()) -> impl Sized + '_ {
- | +++ ++++ ++
+LL | fn foo2<'b, 'a>(d: impl Sized + 'a + 'b, p: &'b mut ()) -> impl Sized + 'b {
+ | +++ ++++ ++ ~~
error[E0311]: the parameter type `T` may not live long enough
- --> $DIR/issue-105544.rs:27:5
- |
-LL | (d, p)
- | ^^^^^^
- |
-note: the parameter type `T` must be valid for the anonymous lifetime defined here...
- --> $DIR/issue-105544.rs:25:28
+ --> $DIR/issue-105544.rs:28:5
|
LL | fn bar<T : Sized>(d: T, p: & mut ()) -> impl Sized + '_ {
- | ^^^^^^^^
-note: ...so that the type `T` will meet its required lifetime bounds
- --> $DIR/issue-105544.rs:27:5
- |
+ | -------- the parameter type `T` must be valid for the anonymous lifetime defined here...
+LL |
LL | (d, p)
- | ^^^^^^
-help: consider adding an explicit lifetime bound...
+ | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
|
-LL | fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + '_ {
- | +++ ++++ ++
+LL | fn bar<'a, T : Sized + 'a>(d: T, p: &'a mut ()) -> impl Sized + 'a {
+ | +++ ++++ ++ ~~
error[E0309]: the parameter type `T` may not live long enough
- --> $DIR/issue-105544.rs:34:5
+ --> $DIR/issue-105544.rs:36:5
|
+LL | fn bar1<'b, T : Sized>(d: T, p: &'b mut ()) -> impl Sized + '_ {
+ | -- the parameter type `T` must be valid for the lifetime `'b` as defined here...
+...
LL | (d, p)
| ^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn bar1<'b, T : Sized + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ {
| ++++
error[E0311]: the parameter type `T` may not live long enough
- --> $DIR/issue-105544.rs:40:5
- |
-LL | (d, p)
- | ^^^^^^
- |
-note: the parameter type `T` must be valid for the anonymous lifetime defined here...
- --> $DIR/issue-105544.rs:38:38
+ --> $DIR/issue-105544.rs:42:5
|
LL | fn bar2<'a, T : Sized + 'a>(d: T, p: &mut ()) -> impl Sized + '_ {
- | ^^^^^^^
-note: ...so that the type `T` will meet its required lifetime bounds
- --> $DIR/issue-105544.rs:40:5
- |
+ | ------- the parameter type `T` must be valid for the anonymous lifetime defined here...
+LL |
LL | (d, p)
- | ^^^^^^
-help: consider adding an explicit lifetime bound...
+ | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
|
-LL | fn bar2<'b, 'a, T : Sized + 'a + 'b>(d: T, p: &'b mut ()) -> impl Sized + '_ {
- | +++ ++++ ++
+LL | fn bar2<'b, 'a, T : Sized + 'a + 'b>(d: T, p: &'b mut ()) -> impl Sized + 'b {
+ | +++ ++++ ++ ~~
error: aborting due to 6 previous errors
diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed
index 4013d98c3..474986283 100644
--- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed
+++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.fixed
@@ -19,11 +19,16 @@ trait Test {
fn test(&self);
}
-fn func<'a, T: Test + 'a>(foo: &'a Foo<'a>, t: T) {
+fn func<'a, T: Test + 'a>(_dummy: &Foo, foo: &Foo<'a>, t: T) {
foo.bar(move |_| {
//~^ ERROR the parameter type `T` may not live long enough
t.test();
});
}
+// Test that the suggested fix does not overconstrain `func`. See #115375.
+fn test_func<'a, T: Test + 'a>(dummy: &Foo, foo: &Foo<'a>, t: T) {
+ func(dummy, foo, t);
+}
+
fn main() {}
diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs
index 4096d95e5..99c8e9626 100644
--- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs
+++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs
@@ -19,11 +19,16 @@ trait Test {
fn test(&self);
}
-fn func<T: Test>(foo: &Foo, t: T) {
+fn func<T: Test>(_dummy: &Foo, foo: &Foo, t: T) {
foo.bar(move |_| {
//~^ ERROR the parameter type `T` may not live long enough
t.test();
});
}
+// Test that the suggested fix does not overconstrain `func`. See #115375.
+fn test_func<'a, T: Test + 'a>(dummy: &Foo, foo: &Foo<'a>, t: T) {
+ func(dummy, foo, t);
+}
+
fn main() {}
diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
index 936d87f79..6c63e1ada 100644
--- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
+++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
@@ -1,29 +1,18 @@
error[E0311]: the parameter type `T` may not live long enough
--> $DIR/missing-lifetimes-in-signature-2.rs:23:5
|
+LL | fn func<T: Test>(_dummy: &Foo, foo: &Foo, t: T) {
+ | --- the parameter type `T` must be valid for the anonymous lifetime defined here...
LL | / foo.bar(move |_| {
LL | |
LL | | t.test();
LL | | });
- | |______^
+ | |______^ ...so that the type `T` will meet its required lifetime bounds
|
-note: the parameter type `T` must be valid for the anonymous lifetime defined here...
- --> $DIR/missing-lifetimes-in-signature-2.rs:22:24
+help: consider adding an explicit lifetime bound
|
-LL | fn func<T: Test>(foo: &Foo, t: T) {
- | ^^^
-note: ...so that the type `T` will meet its required lifetime bounds
- --> $DIR/missing-lifetimes-in-signature-2.rs:23:5
- |
-LL | / foo.bar(move |_| {
-LL | |
-LL | | t.test();
-LL | | });
- | |______^
-help: consider adding an explicit lifetime bound...
- |
-LL | fn func<'a, T: Test + 'a>(foo: &'a Foo<'a>, t: T) {
- | +++ ++++ ++ ++++
+LL | fn func<'a, T: Test + 'a>(_dummy: &Foo, foo: &Foo<'a>, t: T) {
+ | +++ ++++ ++++
error: aborting due to previous error
diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
index 318ea4083..64af17c83 100644
--- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -28,28 +28,18 @@ LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:30:5
|
+LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+ | ------ the parameter type `G` must be valid for the anonymous lifetime defined here...
+...
LL | / move || {
LL | |
LL | | *dest = g.get();
LL | | }
- | |_____^
- |
-note: the parameter type `G` must be valid for the anonymous lifetime defined here...
- --> $DIR/missing-lifetimes-in-signature.rs:26:26
- |
-LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
- | ^^^^^^
-note: ...so that the type `G` will meet its required lifetime bounds
- --> $DIR/missing-lifetimes-in-signature.rs:30:5
+ | |_____^ ...so that the type `G` will meet its required lifetime bounds
|
-LL | / move || {
-LL | |
-LL | | *dest = g.get();
-LL | | }
- | |_____^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
-LL ~ fn bar<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_
+LL ~ fn bar<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a
LL | where
LL ~ G: Get<T> + 'a,
|
@@ -57,85 +47,53 @@ LL ~ G: Get<T> + 'a,
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:52:5
|
+LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+ | ------ the parameter type `G` must be valid for the anonymous lifetime defined here...
+...
LL | / move || {
LL | |
LL | | *dest = g.get();
LL | | }
- | |_____^
- |
-note: the parameter type `G` must be valid for the anonymous lifetime defined here...
- --> $DIR/missing-lifetimes-in-signature.rs:48:34
- |
-LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
- | ^^^^^^
-note: ...so that the type `G` will meet its required lifetime bounds
- --> $DIR/missing-lifetimes-in-signature.rs:52:5
+ | |_____^ ...so that the type `G` will meet its required lifetime bounds
|
-LL | / move || {
-LL | |
-LL | | *dest = g.get();
-LL | | }
- | |_____^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
-LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &'b mut T) -> impl FnOnce() + '_
- | +++ ++++ ++
+LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &'b mut T) -> impl FnOnce() + 'b
+ | +++ ++++ ++ ~~
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:61:9
|
+LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
+ | ------ the parameter type `G` must be valid for the anonymous lifetime defined here...
LL | / move || {
LL | |
LL | | *dest = g.get();
LL | | }
- | |_________^
+ | |_________^ ...so that the type `G` will meet its required lifetime bounds
|
-note: the parameter type `G` must be valid for the anonymous lifetime defined here...
- --> $DIR/missing-lifetimes-in-signature.rs:60:47
+help: consider adding an explicit lifetime bound
|
-LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
- | ^^^^^^
-note: ...so that the type `G` will meet its required lifetime bounds
- --> $DIR/missing-lifetimes-in-signature.rs:61:9
- |
-LL | / move || {
-LL | |
-LL | | *dest = g.get();
-LL | | }
- | |_________^
-help: consider adding an explicit lifetime bound...
- |
-LL | fn qux<'c, 'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &'c mut T) -> impl FnOnce() + '_ {
- | +++ ++++ ++
+LL | fn qux<'c, 'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &'c mut T) -> impl FnOnce() + 'c {
+ | +++ ++++ ++ ~~
error[E0311]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:73:5
|
+LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
+ | ------ the parameter type `G` must be valid for the anonymous lifetime defined here...
+...
LL | / move || {
LL | |
LL | |
LL | | *dest = g.get();
LL | | }
- | |_____^
- |
-note: the parameter type `G` must be valid for the anonymous lifetime defined here...
- --> $DIR/missing-lifetimes-in-signature.rs:69:34
- |
-LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
- | ^^^^^^
-note: ...so that the type `G` will meet its required lifetime bounds
- --> $DIR/missing-lifetimes-in-signature.rs:73:5
+ | |_____^ ...so that the type `G` will meet its required lifetime bounds
|
-LL | / move || {
-LL | |
-LL | |
-LL | | *dest = g.get();
-LL | | }
- | |_____^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
-LL | fn bat<'b, 'a, G: 'a + 'b, T>(g: G, dest: &'b mut T) -> impl FnOnce() + '_ + 'a
- | +++ ++++ ++
+LL | fn bat<'b, 'a, G: 'a + 'b, T>(g: G, dest: &'b mut T) -> impl FnOnce() + 'b + 'a
+ | +++ ++++ ++ ~~
error[E0621]: explicit lifetime required in the type of `dest`
--> $DIR/missing-lifetimes-in-signature.rs:73:5
@@ -153,13 +111,16 @@ LL | | }
error[E0309]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:85:5
|
+LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a
+ | -- the parameter type `G` must be valid for the lifetime `'a` as defined here...
+...
LL | / move || {
LL | |
LL | | *dest = g.get();
LL | | }
| |_____^ ...so that the type `G` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | G: Get<T> + 'a,
| ++++
diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed b/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed
new file mode 100644
index 000000000..470cc67b9
--- /dev/null
+++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed
@@ -0,0 +1,47 @@
+// Make sure we suggest the bound `T: 'a` in the correct scope:
+// trait, impl or associated fn.
+// run-rustfix
+
+struct Inv<'a>(Option<*mut &'a u8>);
+
+fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {}
+
+trait Trait1<'a>: Sized where Self: 'a {
+ fn foo(self, lt: Inv<'a>) {
+ check_bound(self, lt)
+ //~^ ERROR parameter type `Self` may not live long enough
+ }
+}
+
+trait Trait2: Sized {
+ fn foo<'a>(self, lt: Inv<'a>) where Self: 'a {
+ check_bound(self, lt)
+ //~^ ERROR parameter type `Self` may not live long enough
+ }
+}
+
+trait Trait3<T> {
+ fn foo<'a>(arg: T, lt: Inv<'a>) where T: 'a {
+ check_bound(arg, lt)
+ //~^ ERROR parameter type `T` may not live long enough
+ }
+}
+
+trait Trait4<'a> {
+ fn foo<T: 'a>(arg: T, lt: Inv<'a>) {
+ check_bound(arg, lt)
+ //~^ ERROR parameter type `T` may not live long enough
+ }
+}
+
+trait Trait5<'a> {
+ fn foo(self, _: Inv<'a>);
+}
+impl<'a, T: 'a> Trait5<'a> for T {
+ fn foo(self, lt: Inv<'a>) {
+ check_bound(self, lt);
+ //~^ ERROR parameter type `T` may not live long enough
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs b/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs
new file mode 100644
index 000000000..874788e13
--- /dev/null
+++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs
@@ -0,0 +1,47 @@
+// Make sure we suggest the bound `T: 'a` in the correct scope:
+// trait, impl or associated fn.
+// run-rustfix
+
+struct Inv<'a>(Option<*mut &'a u8>);
+
+fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {}
+
+trait Trait1<'a>: Sized {
+ fn foo(self, lt: Inv<'a>) {
+ check_bound(self, lt)
+ //~^ ERROR parameter type `Self` may not live long enough
+ }
+}
+
+trait Trait2: Sized {
+ fn foo<'a>(self, lt: Inv<'a>) {
+ check_bound(self, lt)
+ //~^ ERROR parameter type `Self` may not live long enough
+ }
+}
+
+trait Trait3<T> {
+ fn foo<'a>(arg: T, lt: Inv<'a>) {
+ check_bound(arg, lt)
+ //~^ ERROR parameter type `T` may not live long enough
+ }
+}
+
+trait Trait4<'a> {
+ fn foo<T>(arg: T, lt: Inv<'a>) {
+ check_bound(arg, lt)
+ //~^ ERROR parameter type `T` may not live long enough
+ }
+}
+
+trait Trait5<'a> {
+ fn foo(self, _: Inv<'a>);
+}
+impl<'a, T> Trait5<'a> for T {
+ fn foo(self, lt: Inv<'a>) {
+ check_bound(self, lt);
+ //~^ ERROR parameter type `T` may not live long enough
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr b/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr
new file mode 100644
index 000000000..d3ca2cc11
--- /dev/null
+++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.stderr
@@ -0,0 +1,71 @@
+error[E0309]: the parameter type `Self` may not live long enough
+ --> $DIR/type-param-bound-scope.rs:11:9
+ |
+LL | trait Trait1<'a>: Sized {
+ | -- the parameter type `Self` must be valid for the lifetime `'a` as defined here...
+LL | fn foo(self, lt: Inv<'a>) {
+LL | check_bound(self, lt)
+ | ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `Self` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | trait Trait1<'a>: Sized where Self: 'a {
+ | ++++++++++++++
+
+error[E0309]: the parameter type `Self` may not live long enough
+ --> $DIR/type-param-bound-scope.rs:18:9
+ |
+LL | fn foo<'a>(self, lt: Inv<'a>) {
+ | -- the parameter type `Self` must be valid for the lifetime `'a` as defined here...
+LL | check_bound(self, lt)
+ | ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `Self` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | fn foo<'a>(self, lt: Inv<'a>) where Self: 'a {
+ | ++++++++++++++
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/type-param-bound-scope.rs:25:9
+ |
+LL | fn foo<'a>(arg: T, lt: Inv<'a>) {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
+LL | check_bound(arg, lt)
+ | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | fn foo<'a>(arg: T, lt: Inv<'a>) where T: 'a {
+ | +++++++++++
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/type-param-bound-scope.rs:32:9
+ |
+LL | trait Trait4<'a> {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
+LL | fn foo<T>(arg: T, lt: Inv<'a>) {
+LL | check_bound(arg, lt)
+ | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | fn foo<T: 'a>(arg: T, lt: Inv<'a>) {
+ | ++++
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/type-param-bound-scope.rs:42:9
+ |
+LL | impl<'a, T> Trait5<'a> for T {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
+LL | fn foo(self, lt: Inv<'a>) {
+LL | check_bound(self, lt);
+ | ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | impl<'a, T: 'a> Trait5<'a> for T {
+ | ++++
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0309`.
diff --git a/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.fixed b/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.fixed
new file mode 100644
index 000000000..e30c55645
--- /dev/null
+++ b/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.fixed
@@ -0,0 +1,52 @@
+// We want to suggest a bound `T: 'a` but `'a` is elided,
+// run-rustfix
+// edition: 2018
+#![allow(dead_code)]
+
+struct Inv<'a>(Option<*mut &'a u8>);
+
+fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {}
+
+struct Elided<'a, T = ()>(Inv<'a>, T);
+
+struct MyTy<X>(X);
+
+impl<'a, X> MyTy<Elided<'a, X>> {
+ async fn foo<A: 'a>(self, arg: A, _: &str) -> &str {
+ check_bound(arg, self.0 .0);
+ //~^ ERROR parameter type `A` may not live long enough
+ ""
+ }
+}
+
+// Make sure the new lifetime name doesn't conflict with
+// other early- or late-bound lifetimes in-scope.
+impl<'a, A> MyTy<(A, &'a ())> {
+ async fn foo2<'b>(
+ arg: A,
+ lt: Inv<'b>,
+ ) -> (
+ impl Into<&'b str> + Into<&'b str> + 'b,
+ impl Into<Option<Elided<'b>>> + 'b,
+ impl Into<Option<Elided<'b, ()>>>,
+ ) where A: 'b {
+ check_bound(arg, lt);
+ //~^ ERROR parameter type `A` may not live long enough
+ ("", None, None)
+ }
+
+ // same as above but there is a late-bound lifetime named `'b`.
+ async fn bar2<'c, 'b>(_dummy: &'a u8, arg: A, lt: Inv<'c>) where A: 'c {
+ check_bound(arg, lt);
+ //~^ ERROR parameter type `A` may not live long enough
+ }
+}
+
+impl<'a, A: 'a> MyTy<Elided<'a, A>> {
+ async fn foo3(self) {
+ check_bound(self.0 .1, self.0 .0);
+ //~^ ERROR parameter type `A` may not live long enough
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.rs b/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.rs
new file mode 100644
index 000000000..85f08808b
--- /dev/null
+++ b/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.rs
@@ -0,0 +1,52 @@
+// We want to suggest a bound `T: 'a` but `'a` is elided,
+// run-rustfix
+// edition: 2018
+#![allow(dead_code)]
+
+struct Inv<'a>(Option<*mut &'a u8>);
+
+fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {}
+
+struct Elided<'a, T = ()>(Inv<'a>, T);
+
+struct MyTy<X>(X);
+
+impl<X> MyTy<Elided<'_, X>> {
+ async fn foo<A>(self, arg: A, _: &str) -> &str {
+ check_bound(arg, self.0 .0);
+ //~^ ERROR parameter type `A` may not live long enough
+ ""
+ }
+}
+
+// Make sure the new lifetime name doesn't conflict with
+// other early- or late-bound lifetimes in-scope.
+impl<'a, A> MyTy<(A, &'a ())> {
+ async fn foo2(
+ arg: A,
+ lt: Inv<'_>,
+ ) -> (
+ impl Into<&str> + Into<&'_ str> + '_,
+ impl Into<Option<Elided>> + '_,
+ impl Into<Option<Elided<()>>>,
+ ) {
+ check_bound(arg, lt);
+ //~^ ERROR parameter type `A` may not live long enough
+ ("", None, None)
+ }
+
+ // same as above but there is a late-bound lifetime named `'b`.
+ async fn bar2<'b>(_dummy: &'a u8, arg: A, lt: Inv<'_>) {
+ check_bound(arg, lt);
+ //~^ ERROR parameter type `A` may not live long enough
+ }
+}
+
+impl<A> MyTy<Elided<'_, A>> {
+ async fn foo3(self) {
+ check_bound(self.0 .1, self.0 .0);
+ //~^ ERROR parameter type `A` may not live long enough
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.stderr b/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.stderr
new file mode 100644
index 000000000..2f74a006b
--- /dev/null
+++ b/tests/ui/suggestions/lifetimes/type-param-missing-lifetime.stderr
@@ -0,0 +1,66 @@
+error[E0311]: the parameter type `A` may not live long enough
+ --> $DIR/type-param-missing-lifetime.rs:16:9
+ |
+LL | impl<X> MyTy<Elided<'_, X>> {
+ | -- the parameter type `A` must be valid for the anonymous lifetime as defined here...
+LL | async fn foo<A>(self, arg: A, _: &str) -> &str {
+LL | check_bound(arg, self.0 .0);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL ~ impl<'a, X> MyTy<Elided<'a, X>> {
+LL ~ async fn foo<A: 'a>(self, arg: A, _: &str) -> &str {
+ |
+
+error[E0311]: the parameter type `A` may not live long enough
+ --> $DIR/type-param-missing-lifetime.rs:33:9
+ |
+LL | lt: Inv<'_>,
+ | ------- the parameter type `A` must be valid for the anonymous lifetime defined here...
+...
+LL | check_bound(arg, lt);
+ | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL ~ async fn foo2<'b>(
+LL | arg: A,
+LL ~ lt: Inv<'b>,
+LL | ) -> (
+LL ~ impl Into<&'b str> + Into<&'b str> + 'b,
+LL ~ impl Into<Option<Elided<'b>>> + 'b,
+LL ~ impl Into<Option<Elided<'b, ()>>>,
+LL ~ ) where A: 'b {
+ |
+
+error[E0311]: the parameter type `A` may not live long enough
+ --> $DIR/type-param-missing-lifetime.rs:40:9
+ |
+LL | async fn bar2<'b>(_dummy: &'a u8, arg: A, lt: Inv<'_>) {
+ | ------- the parameter type `A` must be valid for the anonymous lifetime defined here...
+LL | check_bound(arg, lt);
+ | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | async fn bar2<'c, 'b>(_dummy: &'a u8, arg: A, lt: Inv<'c>) where A: 'c {
+ | +++ ~~ +++++++++++
+
+error[E0311]: the parameter type `A` may not live long enough
+ --> $DIR/type-param-missing-lifetime.rs:47:9
+ |
+LL | impl<A> MyTy<Elided<'_, A>> {
+ | -- the parameter type `A` must be valid for the anonymous lifetime as defined here...
+LL | async fn foo3(self) {
+LL | check_bound(self.0 .1, self.0 .0);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
+ |
+LL | impl<'a, A: 'a> MyTy<Elided<'a, A>> {
+ | +++ ++++ ~~
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0311`.
diff --git a/tests/ui/suggestions/missing-lifetime-specifier.stderr b/tests/ui/suggestions/missing-lifetime-specifier.stderr
index 21d237838..fa4bc2fa7 100644
--- a/tests/ui/suggestions/missing-lifetime-specifier.stderr
+++ b/tests/ui/suggestions/missing-lifetime-specifier.stderr
@@ -164,6 +164,7 @@ note: union defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -182,6 +183,7 @@ note: union defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -200,6 +202,7 @@ note: union defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -218,6 +221,7 @@ note: union defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -254,6 +258,7 @@ note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -272,6 +277,7 @@ note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -290,6 +296,7 @@ note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -308,6 +315,7 @@ note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
|
LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
diff --git a/tests/ui/suggestions/path-display.stderr b/tests/ui/suggestions/path-display.stderr
index 8359b3658..46d0b3582 100644
--- a/tests/ui/suggestions/path-display.stderr
+++ b/tests/ui/suggestions/path-display.stderr
@@ -5,6 +5,7 @@ LL | println!("{}", path);
| ^^^^ `Path` cannot be formatted with the default formatter; call `.display()` on it
|
= help: the trait `std::fmt::Display` is not implemented for `Path`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
= note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -15,6 +16,7 @@ LL | println!("{}", path);
| ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it
|
= help: the trait `std::fmt::Display` is not implemented for `PathBuf`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
= note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/suggestions/restrict-existing-type-bounds.stderr b/tests/ui/suggestions/restrict-existing-type-bounds.stderr
index 14a244b79..fe8338c18 100644
--- a/tests/ui/suggestions/restrict-existing-type-bounds.stderr
+++ b/tests/ui/suggestions/restrict-existing-type-bounds.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/restrict-existing-type-bounds.rs:13:12
|
LL | impl<T: TryAdd> TryAdd for Option<T> {
- | - this type parameter
+ | - found this type parameter
...
LL | Ok(self)
| -- ^^^^ expected `Option<<T as TryAdd>::Output>`, found `Option<T>`
@@ -29,7 +29,7 @@ error[E0308]: mismatched types
--> $DIR/restrict-existing-type-bounds.rs:26:12
|
LL | impl<T: TryAdd<Error = X>> TryAdd for Other<T> {
- | - this type parameter
+ | - found this type parameter
...
LL | Ok(self)
| -- ^^^^ expected `Other<<T as TryAdd>::Output>`, found `Other<T>`
diff --git a/tests/ui/suggestions/return-closures.stderr b/tests/ui/suggestions/return-closures.stderr
index f0810bbb2..97c13200a 100644
--- a/tests/ui/suggestions/return-closures.stderr
+++ b/tests/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<'a> Fn(&'a i32) -> i32`
+ | - help: try adding a return type: `-> impl for<'a> Fn(&'a i32) -> i32`
LL |
LL | |x: &i32| 1i32
| ^^^^^^^^^^^^^^ expected `()`, found closure
@@ -14,7 +14,7 @@ error[E0308]: mismatched types
--> $DIR/return-closures.rs:9:5
|
LL | fn bar(i: impl Sized) {
- | - help: a return type might be missing here: `-> _`
+ | - help: a return type might be missing here: `-> _`
LL |
LL | || i
| ^^^^ expected `()`, found closure
diff --git a/tests/ui/suggestions/silenced-binding-typo.fixed b/tests/ui/suggestions/silenced-binding-typo.fixed
new file mode 100644
index 000000000..e0f9e31be
--- /dev/null
+++ b/tests/ui/suggestions/silenced-binding-typo.fixed
@@ -0,0 +1,5 @@
+// run-rustfix
+fn main() {
+ let x = 42; //~ HELP
+ let _y = x; //~ ERROR
+}
diff --git a/tests/ui/suggestions/silenced-binding-typo.rs b/tests/ui/suggestions/silenced-binding-typo.rs
new file mode 100644
index 000000000..6cadd5a93
--- /dev/null
+++ b/tests/ui/suggestions/silenced-binding-typo.rs
@@ -0,0 +1,5 @@
+// run-rustfix
+fn main() {
+ let _x = 42; //~ HELP
+ let _y = x; //~ ERROR
+}
diff --git a/tests/ui/suggestions/silenced-binding-typo.stderr b/tests/ui/suggestions/silenced-binding-typo.stderr
new file mode 100644
index 000000000..9c0e6e265
--- /dev/null
+++ b/tests/ui/suggestions/silenced-binding-typo.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/silenced-binding-typo.rs:4:14
+ |
+LL | let _y = x;
+ | ^
+ |
+help: a local variable with a similar name exists, consider changing it
+ |
+LL | let x = 42;
+ | ~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/suggestions/slice-issue-87994.stderr b/tests/ui/suggestions/slice-issue-87994.stderr
index 84ecd749b..656f71eb8 100644
--- a/tests/ui/suggestions/slice-issue-87994.stderr
+++ b/tests/ui/suggestions/slice-issue-87994.stderr
@@ -1,4 +1,4 @@
-error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
+error[E0277]: `[i32]` is not an iterator
--> $DIR/slice-issue-87994.rs:3:12
|
LL | for _ in v[1..] {
@@ -13,7 +13,7 @@ LL | for _ in &v[1..] {
LL | for _ in &mut v[1..] {
| ++++
-error[E0277]: `[i32]` is not an iterator
+error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/slice-issue-87994.rs:3:12
|
LL | for _ in v[1..] {
@@ -28,7 +28,7 @@ LL | for _ in &v[1..] {
LL | for _ in &mut v[1..] {
| ++++
-error[E0277]: the size for values of type `[K]` cannot be known at compilation time
+error[E0277]: `[K]` is not an iterator
--> $DIR/slice-issue-87994.rs:11:13
|
LL | for i2 in v2[1..] {
@@ -43,7 +43,7 @@ LL | for i2 in &v2[1..] {
LL | for i2 in &mut v2[1..] {
| ++++
-error[E0277]: `[K]` is not an iterator
+error[E0277]: the size for values of type `[K]` cannot be known at compilation time
--> $DIR/slice-issue-87994.rs:11:13
|
LL | for i2 in v2[1..] {
diff --git a/tests/ui/suggestions/suggest-dereferencing-index.stderr b/tests/ui/suggestions/suggest-dereferencing-index.stderr
index 147dc9234..adf013399 100644
--- a/tests/ui/suggestions/suggest-dereferencing-index.stderr
+++ b/tests/ui/suggestions/suggest-dereferencing-index.stderr
@@ -5,7 +5,8 @@ LL | let one_item_please: i32 = [1, 2, 3][i];
| ^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `SliceIndex<[{integer}]>` is not implemented for `&usize`
- = help: the trait `SliceIndex<[T]>` is implemented for `usize`
+ = help: the trait `SliceIndex<[{integer}]>` is implemented for `usize`
+ = help: for that trait implementation, expected `usize`, found `&usize`
= note: required for `[{integer}]` to implement `Index<&usize>`
help: dereference this index
|
diff --git a/tests/ui/suggestions/suggest-impl-trait-lifetime.fixed b/tests/ui/suggestions/suggest-impl-trait-lifetime.fixed
index 589ee1a47..4f2fd5ba6 100644
--- a/tests/ui/suggestions/suggest-impl-trait-lifetime.fixed
+++ b/tests/ui/suggestions/suggest-impl-trait-lifetime.fixed
@@ -3,9 +3,10 @@
use std::fmt::Debug;
fn foo(d: impl Debug + 'static) {
-//~^ HELP consider adding an explicit lifetime bound...
+//~^ HELP consider adding an explicit lifetime bound
bar(d);
//~^ ERROR the parameter type `impl Debug` may not live long enough
+//~| NOTE the parameter type `impl Debug` must be valid for the static lifetime...
//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds
}
diff --git a/tests/ui/suggestions/suggest-impl-trait-lifetime.rs b/tests/ui/suggestions/suggest-impl-trait-lifetime.rs
index 9a87129fb..a266e360e 100644
--- a/tests/ui/suggestions/suggest-impl-trait-lifetime.rs
+++ b/tests/ui/suggestions/suggest-impl-trait-lifetime.rs
@@ -3,9 +3,10 @@
use std::fmt::Debug;
fn foo(d: impl Debug) {
-//~^ HELP consider adding an explicit lifetime bound...
+//~^ HELP consider adding an explicit lifetime bound
bar(d);
//~^ ERROR the parameter type `impl Debug` may not live long enough
+//~| NOTE the parameter type `impl Debug` must be valid for the static lifetime...
//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds
}
diff --git a/tests/ui/suggestions/suggest-impl-trait-lifetime.stderr b/tests/ui/suggestions/suggest-impl-trait-lifetime.stderr
index cf912f4aa..1660db1aa 100644
--- a/tests/ui/suggestions/suggest-impl-trait-lifetime.stderr
+++ b/tests/ui/suggestions/suggest-impl-trait-lifetime.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `impl Debug` may not live long enough
--> $DIR/suggest-impl-trait-lifetime.rs:7:5
|
LL | bar(d);
- | ^^^^^^ ...so that the type `impl Debug` will meet its required lifetime bounds
+ | ^^^^^^
+ | |
+ | the parameter type `impl Debug` must be valid for the static lifetime...
+ | ...so that the type `impl Debug` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn foo(d: impl Debug + 'static) {
| +++++++++
diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.fixed b/tests/ui/suggestions/suggest-ret-on-async-w-late.fixed
new file mode 100644
index 000000000..0a0838331
--- /dev/null
+++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.fixed
@@ -0,0 +1,14 @@
+// edition: 2021
+// run-rustfix
+
+#![allow(unused)]
+
+// Make sure we don't ICE when suggesting a return type
+// for an async fn that has late-bound vars...
+
+async fn ice(_: &i32) -> bool {
+ true
+ //~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.rs b/tests/ui/suggestions/suggest-ret-on-async-w-late.rs
index 459b94f94..5c8f185bd 100644
--- a/tests/ui/suggestions/suggest-ret-on-async-w-late.rs
+++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.rs
@@ -1,4 +1,7 @@
// edition: 2021
+// run-rustfix
+
+#![allow(unused)]
// Make sure we don't ICE when suggesting a return type
// for an async fn that has late-bound vars...
diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr b/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr
index bff864b22..352f6da36 100644
--- a/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr
+++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
- --> $DIR/suggest-ret-on-async-w-late.rs:7:5
+ --> $DIR/suggest-ret-on-async-w-late.rs:10:5
|
LL | async fn ice(_: &i32) {
- | - help: try adding a return type: `-> bool`
+ | - help: try adding a return type: `-> bool`
LL | true
| ^^^^ expected `()`, found `bool`
diff --git a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr
index 0ca5b9b92..0d1eed67c 100644
--- a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr
+++ b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr
@@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38
|
LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {}
- | ^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'a S as IntoIterator>::Item`
+ | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'a S as IntoIterator>::Item`
error: aborting due to previous error
diff --git a/tests/ui/suggestions/trait-hidden-method.stderr b/tests/ui/suggestions/trait-hidden-method.stderr
index a5a65d193..5dec20718 100644
--- a/tests/ui/suggestions/trait-hidden-method.stderr
+++ b/tests/ui/suggestions/trait-hidden-method.stderr
@@ -1,4 +1,4 @@
-error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified
+error[E0191]: the value of the associated type `Item` in `Iterator` must be specified
--> $DIR/trait-hidden-method.rs:6:33
|
LL | Box::new(1..=10) as Box<dyn Iterator>
diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr
index 7deb9a434..980c2455c 100644
--- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr
+++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr
@@ -124,7 +124,7 @@ error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:31:9
|
LL | fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) {
- | - this type parameter
+ | - found this type parameter
LL | qux(x.func())
| --- ^^^^^^^^ expected `usize`, found type parameter `D`
| |
diff --git a/tests/ui/suggestions/unnamable-types.rs b/tests/ui/suggestions/unnamable-types.rs
index f2485041d..a4e32d7c8 100644
--- a/tests/ui/suggestions/unnamable-types.rs
+++ b/tests/ui/suggestions/unnamable-types.rs
@@ -1,7 +1,7 @@
// Test that we do not suggest to add type annotations for unnamable types.
#![crate_type="lib"]
-#![feature(generators)]
+#![feature(coroutines)]
const A = 5;
//~^ ERROR: missing type for `const` item
diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr
index 19e9af145..d003b9169 100644
--- a/tests/ui/suggestions/unnamable-types.stderr
+++ b/tests/ui/suggestions/unnamable-types.stderr
@@ -55,7 +55,7 @@ error: missing type for `const` item
LL | const G = || -> i32 { yield 0; return 1; };
| ^
|
-note: however, the inferred type `{generator@$DIR/unnamable-types.rs:37:11: 37:20}` cannot be named
+note: however, the inferred type `{coroutine@$DIR/unnamable-types.rs:37:11: 37:20}` cannot be named
--> $DIR/unnamable-types.rs:37:11
|
LL | const G = || -> i32 { yield 0; return 1; };
diff --git a/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr
index 175a5fbba..7c84dd4b8 100644
--- a/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr
+++ b/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr
@@ -14,7 +14,7 @@ help: replace the generic bounds with the associated types
LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>,
| +++ +++
-error[E0191]: the value of the associated types `A` (from trait `T`), `C` (from trait `T`) must be specified
+error[E0191]: the value of the associated types `C` and `A` in `T` must be specified
--> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16
|
LL | type A;