Rollup merge of #100643 - TaKO8Ki:point-at-type-parameter-shadowing-another-type, r=estebank
Point at a type parameter shadowing another type This patch fixes a part of #97459.
This commit is contained in:
commit
b295639f14
7 changed files with 54 additions and 3 deletions
|
@ -161,6 +161,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
msg: String,
|
||||
fallback_label: String,
|
||||
span: Span,
|
||||
span_label: Option<(Span, &'a str)>,
|
||||
could_be_expr: bool,
|
||||
suggestion: Option<(Span, &'a str, String)>,
|
||||
}
|
||||
|
@ -172,6 +173,12 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
msg: format!("expected {}, found {} `{}`", expected, res.descr(), path_str),
|
||||
fallback_label: format!("not a {expected}"),
|
||||
span,
|
||||
span_label: match res {
|
||||
Res::Def(kind, def_id) if kind == DefKind::TyParam => {
|
||||
self.def_span(def_id).map(|span| (span, "found this type pararmeter"))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
could_be_expr: match res {
|
||||
Res::Def(DefKind::Fn, _) => {
|
||||
// Verify whether this is a fn call or an Fn used as a type.
|
||||
|
@ -251,6 +258,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
format!("not found in {mod_str}")
|
||||
},
|
||||
span: item_span,
|
||||
span_label: None,
|
||||
could_be_expr: false,
|
||||
suggestion,
|
||||
}
|
||||
|
@ -262,6 +270,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
|
||||
self.suggest_swapping_misplaced_self_ty_and_trait(&mut err, source, res, base_error.span);
|
||||
|
||||
if let Some((span, label)) = base_error.span_label {
|
||||
err.span_label(span, label);
|
||||
}
|
||||
|
||||
if let Some(sugg) = base_error.suggestion {
|
||||
err.span_suggestion_verbose(sugg.0, sugg.1, sugg.2, Applicability::MaybeIncorrect);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue