From 93ef6b300a629c47e38d36f7191976a8a1ee59f2 Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Fri, 4 Jun 2021 07:49:49 -0700 Subject: [PATCH 1/6] slight improvement to error message - indicates that a future was expected Signed-off-by: Nell Shamrell --- .../src/infer/error_reporting/mod.rs | 40 +++++++++---------- .../dont-suggest-missing-await.stderr | 2 +- src/test/ui/async-await/generator-desc.stderr | 4 +- src/test/ui/async-await/issue-61076.rs | 2 +- src/test/ui/async-await/issue-61076.stderr | 2 +- .../suggest-missing-await-closure.stderr | 2 +- .../async-await/suggest-missing-await.stderr | 4 +- .../ui/parser/fn-header-semantic-fail.stderr | 4 +- ...0736-async-fn-no-body-def-collector.stderr | 2 +- src/test/ui/suggestions/issue-81839.stderr | 2 +- .../match-prev-arm-needing-semi.rs | 6 +-- .../match-prev-arm-needing-semi.stderr | 6 +-- 12 files changed, 37 insertions(+), 39 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index e3a79fe265330..f2bdd7df4cc94 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1486,25 +1486,24 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let kind = key.descr(); let mut returned_async_output_error = false; for sp in values { - err.span_label( - *sp, - format!( - "{}{}{} {}{}", - if sp.is_desugaring(DesugaringKind::Async) - && !returned_async_output_error - { - "checked the `Output` of this `async fn`, " - } else if count == 1 { - "the " - } else { - "" - }, - if count > 1 { "one of the " } else { "" }, - target, - kind, - pluralize!(count), - ), - ); + if sp.is_desugaring(DesugaringKind::Async) && !returned_async_output_error { + err.span_label( + *sp, + format!("{}", "calling an async function returns a future"), + ); + } else { + err.span_label( + *sp, + format!( + "{}{}{} {}{}", + if count == 1 { "the " } else { "" }, + if count > 1 { "one of the " } else { "" }, + target, + kind, + pluralize!(count), + ), + ); + } if sp.is_desugaring(DesugaringKind::Async) && returned_async_output_error == false { @@ -1768,7 +1767,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { if let ObligationCauseCode::CompareImplMethodObligation { .. } = &cause.code { return; } - match ( self.get_impl_future_output_ty(exp_found.expected), self.get_impl_future_output_ty(exp_found.found), @@ -2525,7 +2523,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> { /// This is a bare signal of what kind of type we're dealing with. `ty::TyKind` tracks /// extra information about each type, but we only care about the category. -#[derive(Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub enum TyCategory { Closure, Opaque, diff --git a/src/test/ui/async-await/dont-suggest-missing-await.stderr b/src/test/ui/async-await/dont-suggest-missing-await.stderr index 654a3bcc92dd8..020bd4d2a23ef 100644 --- a/src/test/ui/async-await/dont-suggest-missing-await.stderr +++ b/src/test/ui/async-await/dont-suggest-missing-await.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-missing-await.rs:14:18 | LL | async fn make_u32() -> u32 { - | --- checked the `Output` of this `async fn`, found opaque type + | --- calling an async function returns a future ... LL | take_u32(x) | ^ expected `u32`, found opaque type diff --git a/src/test/ui/async-await/generator-desc.stderr b/src/test/ui/async-await/generator-desc.stderr index 04f191cc5e8cb..1924d8bfe880b 100644 --- a/src/test/ui/async-await/generator-desc.stderr +++ b/src/test/ui/async-await/generator-desc.stderr @@ -13,9 +13,9 @@ error[E0308]: mismatched types --> $DIR/generator-desc.rs:12:16 | LL | async fn one() {} - | - checked the `Output` of this `async fn`, expected opaque type + | - calling an async function returns a future LL | async fn two() {} - | - checked the `Output` of this `async fn`, found opaque type + | - calling an async function returns a future ... LL | fun(one(), two()); | ^^^^^ expected opaque type, found a different opaque type diff --git a/src/test/ui/async-await/issue-61076.rs b/src/test/ui/async-await/issue-61076.rs index 9fe3313ee6cc6..3b72a842df1f5 100644 --- a/src/test/ui/async-await/issue-61076.rs +++ b/src/test/ui/async-await/issue-61076.rs @@ -56,7 +56,7 @@ async fn struct_() -> Struct { } async fn tuple() -> Tuple { - //~^ NOTE checked the `Output` of this `async fn`, expected opaque type + //~^ NOTE calling an async function returns a future Tuple(1i32) } diff --git a/src/test/ui/async-await/issue-61076.stderr b/src/test/ui/async-await/issue-61076.stderr index ad661fb2833fa..ee34692c32250 100644 --- a/src/test/ui/async-await/issue-61076.stderr +++ b/src/test/ui/async-await/issue-61076.stderr @@ -61,7 +61,7 @@ error[E0308]: mismatched types --> $DIR/issue-61076.rs:92:9 | LL | async fn tuple() -> Tuple { - | ----- checked the `Output` of this `async fn`, expected opaque type + | ----- calling an async function returns a future ... LL | Tuple(_) => {} | ^^^^^^^^ expected opaque type, found struct `Tuple` diff --git a/src/test/ui/async-await/suggest-missing-await-closure.stderr b/src/test/ui/async-await/suggest-missing-await-closure.stderr index 483e52536a1b4..07f955e46a9bc 100644 --- a/src/test/ui/async-await/suggest-missing-await-closure.stderr +++ b/src/test/ui/async-await/suggest-missing-await-closure.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await-closure.rs:16:18 | LL | async fn make_u32() -> u32 { - | --- checked the `Output` of this `async fn`, found opaque type + | --- calling an async function returns a future ... LL | take_u32(x) | ^ expected `u32`, found opaque type diff --git a/src/test/ui/async-await/suggest-missing-await.stderr b/src/test/ui/async-await/suggest-missing-await.stderr index 14b5ee95ee8ba..3da3c95a0c183 100644 --- a/src/test/ui/async-await/suggest-missing-await.stderr +++ b/src/test/ui/async-await/suggest-missing-await.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await.rs:12:14 | LL | async fn make_u32() -> u32 { - | --- checked the `Output` of this `async fn`, found opaque type + | --- calling an async function returns a future ... LL | take_u32(x) | ^ expected `u32`, found opaque type @@ -19,7 +19,7 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await.rs:22:5 | LL | async fn dummy() {} - | - checked the `Output` of this `async fn`, found opaque type + | - calling an async function returns a future ... LL | dummy() | ^^^^^^^ expected `()`, found opaque type diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr index b3f60b13b0f74..e25a0b37112b7 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.stderr +++ b/src/test/ui/parser/fn-header-semantic-fail.stderr @@ -189,7 +189,7 @@ LL | async fn ft1(); LL | async fn ft1() {} | ^ | | - | checked the `Output` of this `async fn`, found opaque type + | calling an async function returns a future | expected `()`, found opaque type | = note: while checking the return type of the `async fn` @@ -205,7 +205,7 @@ LL | const async unsafe extern "C" fn ft5(); LL | const async unsafe extern "C" fn ft5() {} | ^ | | - | checked the `Output` of this `async fn`, found opaque type + | calling an async function returns a future | expected `()`, found opaque type | = note: while checking the return type of the `async fn` diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr index 4025b5030dc0f..de53b65339e56 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -53,7 +53,7 @@ LL | async fn associated(); LL | async fn associated(); | ^ | | - | checked the `Output` of this `async fn`, found opaque type + | calling an async function returns a future | expected `()`, found opaque type | = note: while checking the return type of the `async fn` diff --git a/src/test/ui/suggestions/issue-81839.stderr b/src/test/ui/suggestions/issue-81839.stderr index f907658708730..f7482079f25a3 100644 --- a/src/test/ui/suggestions/issue-81839.stderr +++ b/src/test/ui/suggestions/issue-81839.stderr @@ -17,7 +17,7 @@ LL | | } ::: $DIR/auxiliary/issue-81839.rs:6:49 | LL | pub async fn answer_str(&self, _s: &str) -> Test { - | ---- checked the `Output` of this `async fn`, found opaque type + | ---- calling an async function returns a future | = note: while checking the return type of the `async fn` = note: expected type `()` diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs index 3b2cff3140d63..5511cfece327a 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs @@ -13,9 +13,9 @@ fn extra_semicolon() { }; } -async fn async_dummy() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type -async fn async_dummy2() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type -//~| NOTE checked the `Output` of this `async fn`, found opaque type +async fn async_dummy() {} //~ NOTE calling an async function returns a future +async fn async_dummy2() {} //~ NOTE calling an async function returns a future +//~| NOTE calling an async function returns a future async fn async_extra_semicolon_same() { let _ = match true { //~ NOTE `match` arms have incompatible types diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr index e31ea9679b51d..47e2032ecc9d4 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr @@ -2,7 +2,7 @@ error[E0308]: `match` arms have incompatible types --> $DIR/match-prev-arm-needing-semi.rs:26:18 | LL | async fn async_dummy() {} - | - checked the `Output` of this `async fn`, found opaque type + | - calling an async function returns a future ... LL | let _ = match true { | _____________- @@ -34,7 +34,7 @@ error[E0308]: `match` arms have incompatible types --> $DIR/match-prev-arm-needing-semi.rs:40:18 | LL | async fn async_dummy2() {} - | - checked the `Output` of this `async fn`, found opaque type + | - calling an async function returns a future ... LL | let _ = match true { | _____________- @@ -69,7 +69,7 @@ error[E0308]: `match` arms have incompatible types --> $DIR/match-prev-arm-needing-semi.rs:52:18 | LL | async fn async_dummy2() {} - | - checked the `Output` of this `async fn`, found opaque type + | - calling an async function returns a future ... LL | let _ = match true { | _____________- From 0ec98dfd650caa74e9c43811843bd56317b0984f Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Mon, 28 Jun 2021 15:24:58 -0700 Subject: [PATCH 2/6] removes unnecessary trait Signed-off-by: Nell Shamrell --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index f2bdd7df4cc94..5d070270e7314 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2523,7 +2523,7 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> { /// This is a bare signal of what kind of type we're dealing with. `ty::TyKind` tracks /// extra information about each type, but we only care about the category. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum TyCategory { Closure, Opaque, From 686eaf4a5c6440bbc3d09d7be8b314856e2ba9d2 Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Fri, 23 Jul 2021 13:04:46 -0700 Subject: [PATCH 3/6] slight modification to error message Signed-off-by: Nell Shamrell --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 2 +- src/test/ui/async-await/dont-suggest-missing-await.stderr | 2 +- src/test/ui/async-await/generator-desc.stderr | 4 ++-- src/test/ui/async-await/issue-61076.rs | 2 +- src/test/ui/async-await/issue-61076.stderr | 2 +- .../ui/async-await/suggest-missing-await-closure.stderr | 2 +- src/test/ui/async-await/suggest-missing-await.stderr | 4 ++-- src/test/ui/parser/fn-header-semantic-fail.stderr | 4 ++-- .../issue-70736-async-fn-no-body-def-collector.stderr | 2 +- src/test/ui/suggestions/issue-81839.stderr | 2 +- src/test/ui/suggestions/match-prev-arm-needing-semi.rs | 6 +++--- src/test/ui/suggestions/match-prev-arm-needing-semi.stderr | 6 +++--- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 5d070270e7314..17739a754ca61 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1489,7 +1489,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { if sp.is_desugaring(DesugaringKind::Async) && !returned_async_output_error { err.span_label( *sp, - format!("{}", "calling an async function returns a future"), + format!("{}", "async functions return futures"), ); } else { err.span_label( diff --git a/src/test/ui/async-await/dont-suggest-missing-await.stderr b/src/test/ui/async-await/dont-suggest-missing-await.stderr index 020bd4d2a23ef..6506035a1ed3b 100644 --- a/src/test/ui/async-await/dont-suggest-missing-await.stderr +++ b/src/test/ui/async-await/dont-suggest-missing-await.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-missing-await.rs:14:18 | LL | async fn make_u32() -> u32 { - | --- calling an async function returns a future + | --- async functions return futures ... LL | take_u32(x) | ^ expected `u32`, found opaque type diff --git a/src/test/ui/async-await/generator-desc.stderr b/src/test/ui/async-await/generator-desc.stderr index 1924d8bfe880b..68c1dcefbe4b3 100644 --- a/src/test/ui/async-await/generator-desc.stderr +++ b/src/test/ui/async-await/generator-desc.stderr @@ -13,9 +13,9 @@ error[E0308]: mismatched types --> $DIR/generator-desc.rs:12:16 | LL | async fn one() {} - | - calling an async function returns a future + | - async functions return futures LL | async fn two() {} - | - calling an async function returns a future + | - async functions return futures ... LL | fun(one(), two()); | ^^^^^ expected opaque type, found a different opaque type diff --git a/src/test/ui/async-await/issue-61076.rs b/src/test/ui/async-await/issue-61076.rs index 3b72a842df1f5..a17b77bd9637e 100644 --- a/src/test/ui/async-await/issue-61076.rs +++ b/src/test/ui/async-await/issue-61076.rs @@ -56,7 +56,7 @@ async fn struct_() -> Struct { } async fn tuple() -> Tuple { - //~^ NOTE calling an async function returns a future + //~^ NOTE async functions return futures Tuple(1i32) } diff --git a/src/test/ui/async-await/issue-61076.stderr b/src/test/ui/async-await/issue-61076.stderr index ee34692c32250..6006f97de3791 100644 --- a/src/test/ui/async-await/issue-61076.stderr +++ b/src/test/ui/async-await/issue-61076.stderr @@ -61,7 +61,7 @@ error[E0308]: mismatched types --> $DIR/issue-61076.rs:92:9 | LL | async fn tuple() -> Tuple { - | ----- calling an async function returns a future + | ----- async functions return futures ... LL | Tuple(_) => {} | ^^^^^^^^ expected opaque type, found struct `Tuple` diff --git a/src/test/ui/async-await/suggest-missing-await-closure.stderr b/src/test/ui/async-await/suggest-missing-await-closure.stderr index 07f955e46a9bc..223bc1e038964 100644 --- a/src/test/ui/async-await/suggest-missing-await-closure.stderr +++ b/src/test/ui/async-await/suggest-missing-await-closure.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await-closure.rs:16:18 | LL | async fn make_u32() -> u32 { - | --- calling an async function returns a future + | --- async functions return futures ... LL | take_u32(x) | ^ expected `u32`, found opaque type diff --git a/src/test/ui/async-await/suggest-missing-await.stderr b/src/test/ui/async-await/suggest-missing-await.stderr index 3da3c95a0c183..2c99902d6f214 100644 --- a/src/test/ui/async-await/suggest-missing-await.stderr +++ b/src/test/ui/async-await/suggest-missing-await.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await.rs:12:14 | LL | async fn make_u32() -> u32 { - | --- calling an async function returns a future + | --- async functions return futures ... LL | take_u32(x) | ^ expected `u32`, found opaque type @@ -19,7 +19,7 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await.rs:22:5 | LL | async fn dummy() {} - | - calling an async function returns a future + | - async functions return futures ... LL | dummy() | ^^^^^^^ expected `()`, found opaque type diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr index e25a0b37112b7..a7947585803aa 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.stderr +++ b/src/test/ui/parser/fn-header-semantic-fail.stderr @@ -189,7 +189,7 @@ LL | async fn ft1(); LL | async fn ft1() {} | ^ | | - | calling an async function returns a future + | async functions return futures | expected `()`, found opaque type | = note: while checking the return type of the `async fn` @@ -205,7 +205,7 @@ LL | const async unsafe extern "C" fn ft5(); LL | const async unsafe extern "C" fn ft5() {} | ^ | | - | calling an async function returns a future + | async functions return futures | expected `()`, found opaque type | = note: while checking the return type of the `async fn` diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr index de53b65339e56..5c26fa8417059 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -53,7 +53,7 @@ LL | async fn associated(); LL | async fn associated(); | ^ | | - | calling an async function returns a future + | async functions return futures | expected `()`, found opaque type | = note: while checking the return type of the `async fn` diff --git a/src/test/ui/suggestions/issue-81839.stderr b/src/test/ui/suggestions/issue-81839.stderr index f7482079f25a3..994a222d9f6d3 100644 --- a/src/test/ui/suggestions/issue-81839.stderr +++ b/src/test/ui/suggestions/issue-81839.stderr @@ -17,7 +17,7 @@ LL | | } ::: $DIR/auxiliary/issue-81839.rs:6:49 | LL | pub async fn answer_str(&self, _s: &str) -> Test { - | ---- calling an async function returns a future + | ---- async functions return futures | = note: while checking the return type of the `async fn` = note: expected type `()` diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs index 5511cfece327a..a91e77e3f42d9 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs @@ -13,9 +13,9 @@ fn extra_semicolon() { }; } -async fn async_dummy() {} //~ NOTE calling an async function returns a future -async fn async_dummy2() {} //~ NOTE calling an async function returns a future -//~| NOTE calling an async function returns a future +async fn async_dummy() {} //~ NOTE async functions return futures +async fn async_dummy2() {} //~ NOTE async functions return futures +//~| NOTE async functions return futures async fn async_extra_semicolon_same() { let _ = match true { //~ NOTE `match` arms have incompatible types diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr index 47e2032ecc9d4..037a7bc23c436 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr @@ -2,7 +2,7 @@ error[E0308]: `match` arms have incompatible types --> $DIR/match-prev-arm-needing-semi.rs:26:18 | LL | async fn async_dummy() {} - | - calling an async function returns a future + | - async functions return futures ... LL | let _ = match true { | _____________- @@ -34,7 +34,7 @@ error[E0308]: `match` arms have incompatible types --> $DIR/match-prev-arm-needing-semi.rs:40:18 | LL | async fn async_dummy2() {} - | - calling an async function returns a future + | - async functions return futures ... LL | let _ = match true { | _____________- @@ -69,7 +69,7 @@ error[E0308]: `match` arms have incompatible types --> $DIR/match-prev-arm-needing-semi.rs:52:18 | LL | async fn async_dummy2() {} - | - calling an async function returns a future + | - async functions return futures ... LL | let _ = match true { | _____________- From 0f0553887fda87a627a1cbb77fdb436ac918a609 Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Fri, 23 Jul 2021 15:18:18 -0700 Subject: [PATCH 4/6] fixes formatting error Signed-off-by: Nell Shamrell --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 17739a754ca61..799d0fb238ae0 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1487,10 +1487,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let mut returned_async_output_error = false; for sp in values { if sp.is_desugaring(DesugaringKind::Async) && !returned_async_output_error { - err.span_label( - *sp, - format!("{}", "async functions return futures"), - ); + err.span_label(*sp, format!("{}", "async functions return futures")); } else { err.span_label( *sp, From 4eddf2794ee42d30e6a21e00d44cdd21dc668c13 Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Sun, 1 Aug 2021 15:58:53 -0700 Subject: [PATCH 5/6] combines if else statements Signed-off-by: Nell Shamrell --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 799d0fb238ae0..ac07cac2899e3 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1488,6 +1488,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { for sp in values { if sp.is_desugaring(DesugaringKind::Async) && !returned_async_output_error { err.span_label(*sp, format!("{}", "async functions return futures")); + err.note("while checking the return type of the `async fn`"); + returned_async_output_error = true; } else { err.span_label( *sp, @@ -1501,12 +1503,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ), ); } - if sp.is_desugaring(DesugaringKind::Async) - && returned_async_output_error == false - { - err.note("while checking the return type of the `async fn`"); - returned_async_output_error = true; - } } } } From 11dccad97859344dee73d10c2904e9d242a3d8f2 Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Sun, 1 Aug 2021 16:13:33 -0700 Subject: [PATCH 6/6] renames variables to be more descriptive Signed-off-by: Nell Shamrell --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index ac07cac2899e3..3041fb7ae2e5a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1481,11 +1481,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { target: &str, types: &FxHashMap>, ) { - for (key, values) in types.iter() { - let count = values.len(); - let kind = key.descr(); + for (ty_category, spans) in types.iter() { + let count = spans.len(); + let kind = ty_category.descr(); let mut returned_async_output_error = false; - for sp in values { + for sp in spans { if sp.is_desugaring(DesugaringKind::Async) && !returned_async_output_error { err.span_label(*sp, format!("{}", "async functions return futures")); err.note("while checking the return type of the `async fn`");