From bc0d12cc6ccf5c6d8d9c44e67871a5b75f5a44cf Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 24 May 2022 09:57:14 +0200 Subject: [PATCH] use verbose suggestions --- .../src/infer/error_reporting/need_type_info.rs | 4 ++-- .../ui/inference/cannot-infer-partial-try-return.stderr | 9 ++++++--- .../ui/suggestions/suggest-closure-return-type-1.stderr | 9 ++++++--- .../ui/suggestions/suggest-closure-return-type-2.stderr | 7 ++++++- .../type-inference/or_else-multiple-type-params.stderr | 7 ++++++- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 779735ed444..b0b7fc6ad5a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -422,7 +422,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { (receiver.span.shrink_to_lo(), format!("{def_path}({adjustment}")), (receiver.span.shrink_to_hi().with_hi(successor.1), successor.0.to_string()), ]; - err.multipart_suggestion( + err.multipart_suggestion_verbose( "try using a fully qualified path to specify the expected types", suggestion, Applicability::HasPlaceholders, @@ -441,7 +441,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ], None => vec![(data.span(), format!("{}{}{}", arrow, ret, post))], }; - err.multipart_suggestion( + err.multipart_suggestion_verbose( "try giving this closure an explicit return type", suggestion, Applicability::HasPlaceholders, diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.stderr b/src/test/ui/inference/cannot-infer-partial-try-return.stderr index 3956b1a18de..220602c124c 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.stderr +++ b/src/test/ui/inference/cannot-infer-partial-try-return.stderr @@ -2,9 +2,12 @@ error[E0282]: type annotations needed for `Result<(), QualifiedError<_>>` --> $DIR/cannot-infer-partial-try-return.rs:18:13 | LL | let x = || -> Result<_, QualifiedError<_>> { - | ^^^^^^---------------------------- - | | - | help: try giving this closure an explicit return type: `Result<(), QualifiedError<_>>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try giving this closure an explicit return type + | +LL | let x = || -> Result<(), QualifiedError<_>> { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-closure-return-type-1.stderr b/src/test/ui/suggestions/suggest-closure-return-type-1.stderr index ba70bf104bf..3116211b52c 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-1.stderr +++ b/src/test/ui/suggestions/suggest-closure-return-type-1.stderr @@ -2,9 +2,12 @@ error[E0282]: type annotations needed for `[_; 0]` --> $DIR/suggest-closure-return-type-1.rs:4:18 | LL | unbound_drop(|| -> _ { [] }); - | ^^^^^^- - | | - | help: try giving this closure an explicit return type: `[_; 0]` + | ^^^^^^^ + | +help: try giving this closure an explicit return type + | +LL | unbound_drop(|| -> [_; 0] { [] }); + | ~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-closure-return-type-2.stderr b/src/test/ui/suggestions/suggest-closure-return-type-2.stderr index f2cb6d291b3..f368e7de467 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-2.stderr +++ b/src/test/ui/suggestions/suggest-closure-return-type-2.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed for `[_; 0]` --> $DIR/suggest-closure-return-type-2.rs:4:18 | LL | unbound_drop(|| { [] }) - | ^^ - help: try giving this closure an explicit return type: `-> [_; 0]` + | ^^ + | +help: try giving this closure an explicit return type + | +LL | unbound_drop(|| -> [_; 0] { [] }) + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/type-inference/or_else-multiple-type-params.stderr b/src/test/ui/type-inference/or_else-multiple-type-params.stderr index 222638068ad..6ac63a91ee9 100644 --- a/src/test/ui/type-inference/or_else-multiple-type-params.stderr +++ b/src/test/ui/type-inference/or_else-multiple-type-params.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed for `Result` --> $DIR/or_else-multiple-type-params.rs:7:18 | LL | .or_else(|err| { - | ^^^^^ - help: try giving this closure an explicit return type: `-> Result` + | ^^^^^ + | +help: try giving this closure an explicit return type + | +LL | .or_else(|err| -> Result { + | +++++++++++++++++++ error: aborting due to previous error