diff options
Diffstat (limited to 'tests')
14 files changed, 80 insertions, 43 deletions
diff --git a/tests/ui/generic-associated-types/bugs/issue-88382.stderr b/tests/ui/generic-associated-types/bugs/issue-88382.stderr index 624fe2799e0..9b061528e3b 100644 --- a/tests/ui/generic-associated-types/bugs/issue-88382.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-88382.stderr @@ -16,6 +16,10 @@ note: required by a bound in `do_something` | LL | fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `do_something` +help: consider wrapping the function in a closure + | +LL | do_something(SomeImplementation(), |arg0: &mut std::iter::Empty<usize>| test(/* &mut <_ as Iterable>::Iterator<'_> */)); + | ++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/intrinsics/const-eval-select-bad.stderr b/tests/ui/intrinsics/const-eval-select-bad.stderr index e6ff9d5a0df..bf91dc72cc1 100644 --- a/tests/ui/intrinsics/const-eval-select-bad.stderr +++ b/tests/ui/intrinsics/const-eval-select-bad.stderr @@ -86,6 +86,10 @@ LL | const_eval_select((true,), foo, baz); found function signature `fn(i32) -> _` note: required by a bound in `const_eval_select` --> $SRC_DIR/core/src/intrinsics.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | const_eval_select((true,), |arg0: bool| foo(/* i32 */), baz); + | ++++++++++++ +++++++++++ error: this argument must be a `const fn` --> $DIR/const-eval-select-bad.rs:42:29 diff --git a/tests/ui/mismatched_types/E0631.stderr b/tests/ui/mismatched_types/E0631.stderr index 410ea4b0b34..9ba8f5035c5 100644 --- a/tests/ui/mismatched_types/E0631.stderr +++ b/tests/ui/mismatched_types/E0631.stderr @@ -48,6 +48,10 @@ note: required by a bound in `foo` | LL | fn foo<F: Fn(usize)>(_: F) {} | ^^^^^^^^^ required by this bound in `foo` +help: consider wrapping the function in a closure + | +LL | foo(|arg0: usize| f(/* u64 */)); + | +++++++++++++ +++++++++++ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:10:9 @@ -67,6 +71,10 @@ note: required by a bound in `bar` | LL | fn bar<F: Fn<(usize,)>>(_: F) {} | ^^^^^^^^^^^^ required by this bound in `bar` +help: consider wrapping the function in a closure + | +LL | bar(|arg0: usize| f(/* u64 */)); + | +++++++++++++ +++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/mismatched_types/closure-ref-114180.stderr b/tests/ui/mismatched_types/closure-ref-114180.stderr index 798c4e00aa7..27649822e69 100644 --- a/tests/ui/mismatched_types/closure-ref-114180.stderr +++ b/tests/ui/mismatched_types/closure-ref-114180.stderr @@ -12,6 +12,10 @@ LL | v.sort_by(compare); found closure signature `fn((_,), (_,)) -> _` note: required by a bound in `slice::<impl [T]>::sort_by` --> $SRC_DIR/alloc/src/slice.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | v.sort_by(|arg0, arg1| compare(*arg0, *arg1)); + | ++++++++++++ ++++++++++++++ help: consider adjusting the signature so it borrows its arguments | LL | let compare = |&(a,), &(e,)| todo!(); diff --git a/tests/ui/mismatched_types/fn-variance-1.stderr b/tests/ui/mismatched_types/fn-variance-1.stderr index 5794e606eeb..fdb2e6f0097 100644 --- a/tests/ui/mismatched_types/fn-variance-1.stderr +++ b/tests/ui/mismatched_types/fn-variance-1.stderr @@ -16,6 +16,10 @@ note: required by a bound in `apply` | LL | fn apply<T, F>(t: T, f: F) where F: FnOnce(T) { | ^^^^^^^^^ required by this bound in `apply` +help: consider wrapping the function in a closure + | +LL | apply(&3, |x| takes_mut(&mut *x)); + | +++ +++++++++ error[E0631]: type mismatch in function arguments --> $DIR/fn-variance-1.rs:15:19 @@ -35,6 +39,10 @@ note: required by a bound in `apply` | LL | fn apply<T, F>(t: T, f: F) where F: FnOnce(T) { | ^^^^^^^^^ required by this bound in `apply` +help: consider wrapping the function in a closure + | +LL | apply(&mut 3, |x| takes_imm(&*x)); + | +++ +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr index 3db9803d58f..0ed57466e9c 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr +++ b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr @@ -13,6 +13,10 @@ LL | let _has_inference_vars: Option<i32> = Some(0).map(deref_int); found function signature `for<'a> fn(&'a i32) -> _` note: required by a bound in `Option::<T>::map` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _has_inference_vars: Option<i32> = Some(0).map(|a| deref_int(&a)); + | +++ ++++ help: consider adjusting the signature so it does not borrow its argument | LL - fn deref_int(a: &i32) -> i32 { diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr index 3175a258906..1ac057a5f38 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr @@ -13,6 +13,10 @@ LL | let _ = produces_string().and_then(takes_str_but_too_many_refs); found function signature `for<'a, 'b> fn(&'a &'b str) -> _` note: required by a bound in `Option::<T>::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _ = produces_string().and_then(|arg0: String| takes_str_but_too_many_refs(/* &&str */)); + | ++++++++++++++ +++++++++++++ error[E0277]: expected a `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` --> $DIR/suggest-option-asderef-unfixable.rs:26:40 @@ -68,6 +72,10 @@ LL | let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); found function signature `for<'a, 'b> fn(&'a &'b str) -> _` note: required by a bound in `Option::<T>::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _ = Some(TypeWithoutDeref).and_then(|arg0: TypeWithoutDeref| takes_str_but_too_many_refs(/* &&str */)); + | ++++++++++++++++++++++++ +++++++++++++ error: aborting due to 5 previous errors diff --git a/tests/ui/mismatched_types/suggest-option-asderef.fixed b/tests/ui/mismatched_types/suggest-option-asderef.fixed deleted file mode 100644 index fc488b790b3..00000000000 --- a/tests/ui/mismatched_types/suggest-option-asderef.fixed +++ /dev/null @@ -1,39 +0,0 @@ -// run-rustfix - -fn produces_string() -> Option<String> { - Some("my cool string".to_owned()) -} - -fn takes_str(_: &str) -> Option<()> { - Some(()) -} - -fn takes_str_mut(_: &mut str) -> Option<()> { - Some(()) -} - -fn generic<T>(_: T) -> Option<()> { - Some(()) -} - -fn generic_ref<T>(_: T) -> Option<()> { - //~^ HELP consider adjusting the signature so it does not borrow its argument - Some(()) -} - -fn main() { - let _: Option<()> = produces_string().as_deref().and_then(takes_str); - //~^ ERROR type mismatch in function arguments - //~| HELP call `Option::as_deref()` first - let _: Option<Option<()>> = produces_string().as_deref().map(takes_str); - //~^ ERROR type mismatch in function arguments - //~| HELP call `Option::as_deref()` first - let _: Option<Option<()>> = produces_string().as_deref_mut().map(takes_str_mut); - //~^ ERROR type mismatch in function arguments - //~| HELP call `Option::as_deref_mut()` first - let _ = produces_string().and_then(generic); - - let _ = produces_string().as_deref().and_then(generic_ref); - //~^ ERROR type mismatch in function arguments - //~| HELP call `Option::as_deref()` first -} diff --git a/tests/ui/mismatched_types/suggest-option-asderef.rs b/tests/ui/mismatched_types/suggest-option-asderef.rs index 28f46808a39..5f5617e1741 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef.rs +++ b/tests/ui/mismatched_types/suggest-option-asderef.rs @@ -1,4 +1,4 @@ -// run-rustfix +// this isn't auto-fixable now because we produce two similar suggestions fn produces_string() -> Option<String> { Some("my cool string".to_owned()) @@ -25,15 +25,19 @@ fn main() { let _: Option<()> = produces_string().and_then(takes_str); //~^ ERROR type mismatch in function arguments //~| HELP call `Option::as_deref()` first + //~| HELP consider wrapping the function in a closure let _: Option<Option<()>> = produces_string().map(takes_str); //~^ ERROR type mismatch in function arguments //~| HELP call `Option::as_deref()` first + //~| HELP consider wrapping the function in a closure let _: Option<Option<()>> = produces_string().map(takes_str_mut); //~^ ERROR type mismatch in function arguments //~| HELP call `Option::as_deref_mut()` first + //~| HELP consider wrapping the function in a closure let _ = produces_string().and_then(generic); let _ = produces_string().and_then(generic_ref); //~^ ERROR type mismatch in function arguments //~| HELP call `Option::as_deref()` first + //~| HELP consider wrapping the function in a closure } diff --git a/tests/ui/mismatched_types/suggest-option-asderef.stderr b/tests/ui/mismatched_types/suggest-option-asderef.stderr index bfea0867350..1702a7f1dec 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef.stderr +++ b/tests/ui/mismatched_types/suggest-option-asderef.stderr @@ -13,13 +13,17 @@ LL | let _: Option<()> = produces_string().and_then(takes_str); found function signature `for<'a> fn(&'a str) -> _` note: required by a bound in `Option::<T>::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _: Option<()> = produces_string().and_then(|arg0: String| takes_str(/* &str */)); + | ++++++++++++++ ++++++++++++ help: call `Option::as_deref()` first | LL | let _: Option<()> = produces_string().as_deref().and_then(takes_str); | +++++++++++ error[E0631]: type mismatch in function arguments - --> $DIR/suggest-option-asderef.rs:28:55 + --> $DIR/suggest-option-asderef.rs:29:55 | LL | fn takes_str(_: &str) -> Option<()> { | ----------------------------------- found signature defined here @@ -33,13 +37,17 @@ LL | let _: Option<Option<()>> = produces_string().map(takes_str); found function signature `for<'a> fn(&'a str) -> _` note: required by a bound in `Option::<T>::map` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _: Option<Option<()>> = produces_string().map(|arg0: String| takes_str(/* &str */)); + | ++++++++++++++ ++++++++++++ help: call `Option::as_deref()` first | LL | let _: Option<Option<()>> = produces_string().as_deref().map(takes_str); | +++++++++++ error[E0631]: type mismatch in function arguments - --> $DIR/suggest-option-asderef.rs:31:55 + --> $DIR/suggest-option-asderef.rs:33:55 | LL | fn takes_str_mut(_: &mut str) -> Option<()> { | ------------------------------------------- found signature defined here @@ -53,13 +61,17 @@ LL | let _: Option<Option<()>> = produces_string().map(takes_str_mut); found function signature `for<'a> fn(&'a mut str) -> _` note: required by a bound in `Option::<T>::map` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _: Option<Option<()>> = produces_string().map(|arg0: String| takes_str_mut(/* &mut str */)); + | ++++++++++++++ ++++++++++++++++ help: call `Option::as_deref_mut()` first | LL | let _: Option<Option<()>> = produces_string().as_deref_mut().map(takes_str_mut); | +++++++++++++++ error[E0631]: type mismatch in function arguments - --> $DIR/suggest-option-asderef.rs:36:40 + --> $DIR/suggest-option-asderef.rs:39:40 | LL | fn generic_ref<T>(_: &T) -> Option<()> { | -------------------------------------- found signature defined here @@ -73,6 +85,10 @@ LL | let _ = produces_string().and_then(generic_ref); found function signature `for<'a> fn(&'a _) -> _` note: required by a bound in `Option::<T>::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | let _ = produces_string().and_then(|arg0: String| generic_ref(&arg0)); + | ++++++++++++++ +++++++ help: consider adjusting the signature so it does not borrow its argument | LL - fn generic_ref<T>(_: &T) -> Option<()> { diff --git a/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index a900a49c710..d92d5dbd16f 100644 --- a/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/tests/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -16,6 +16,10 @@ note: required by a bound in `call_it` | LL | fn call_it<F: FnMut(isize, isize) -> isize>(y: isize, mut f: F) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it` +help: consider wrapping the function in a closure + | +LL | let z = call_it(3, |arg0: isize, arg1: isize| f(/* usize */, arg1)); + | ++++++++++++++++++++++++++ +++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/enum-variant-arg-mismatch.stderr b/tests/ui/suggestions/enum-variant-arg-mismatch.stderr index 6d72dabf70e..16f03d16d8c 100644 --- a/tests/ui/suggestions/enum-variant-arg-mismatch.stderr +++ b/tests/ui/suggestions/enum-variant-arg-mismatch.stderr @@ -16,6 +16,10 @@ note: required by a bound in `map` | LL | fn map<'a, F: Fn(String) -> Sexpr<'a>>(f: F) {} | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` +help: consider wrapping the function in a closure + | +LL | map(|arg0: String| Sexpr::Ident(/* &str */)); + | ++++++++++++++ ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr index d78de6a460c..ee924522564 100644 --- a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr +++ b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr @@ -16,6 +16,10 @@ note: required by a bound in `Trader::<'a>::set_closure` | LL | pub fn set_closure(&mut self, function: impl Fn(&mut Trader) + 'a) { | ^^^^^^^^^^^^^^^ required by this bound in `Trader::<'a>::set_closure` +help: consider wrapping the function in a closure + | +LL | trader.set_closure(|arg0: &mut Trader<'_>| closure(*arg0)); + | +++++++++++++++++++++++ +++++++ help: consider adjusting the signature so it borrows its argument | LL | let closure = |trader : &mut Trader| { diff --git a/tests/ui/typeck/mismatched-map-under-self.stderr b/tests/ui/typeck/mismatched-map-under-self.stderr index 51491407c49..41391720a28 100644 --- a/tests/ui/typeck/mismatched-map-under-self.stderr +++ b/tests/ui/typeck/mismatched-map-under-self.stderr @@ -30,6 +30,10 @@ LL | self.map(Insertable::values).unwrap_or_default() found function signature `for<'a> fn(&'a _) -> _` note: required by a bound in `Option::<T>::map` --> $SRC_DIR/core/src/option.rs:LL:COL +help: consider wrapping the function in a closure + | +LL | self.map(|arg0: T| Insertable::values(&arg0)).unwrap_or_default() + | +++++++++ +++++++ error: aborting due to 2 previous errors |
