From 9d46641477300983162466d5a985981e9a893eb0 Mon Sep 17 00:00:00 2001 From: Thalia Nero Date: Sat, 19 Nov 2022 20:57:50 -0600 Subject: [PATCH 1/3] Add a note when suggesting to use impl Trait --- compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index b5aa8cd6e7c5b..028a0abb2545b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -878,6 +878,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!("impl {}", all_bounds_str), Applicability::MaybeIncorrect, ); + err.span_note(fn_return.span(), "generic type variables are chosen by the caller"); } pub(in super::super) fn suggest_missing_break_or_return_expr( From 7092b1ca0f22c06b2706cc7c22624fc3f8bd4c6b Mon Sep 17 00:00:00 2001 From: Thalia Nero Date: Tue, 22 Nov 2022 19:33:30 -0600 Subject: [PATCH 2/3] Change to non-spanned note --- compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 028a0abb2545b..4c0bfb26af69b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -878,7 +878,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!("impl {}", all_bounds_str), Applicability::MaybeIncorrect, ); - err.span_note(fn_return.span(), "generic type variables are chosen by the caller"); + err.note("generic type variables are chosen by the caller"); } pub(in super::super) fn suggest_missing_break_or_return_expr( From 5628d90e1be11fc1239af9ede0f73cd751492d19 Mon Sep 17 00:00:00 2001 From: Thalia Nero Date: Tue, 22 Nov 2022 19:41:51 -0600 Subject: [PATCH 3/3] Amend wording --- compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 4c0bfb26af69b..5cfcfe98faae3 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -878,7 +878,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!("impl {}", all_bounds_str), Applicability::MaybeIncorrect, ); - err.note("generic type variables are chosen by the caller"); + err.note("the caller chooses the value of a type parameter"); } pub(in super::super) fn suggest_missing_break_or_return_expr(