X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fcheck%2Fmethod%2Fsuggest.rs;h=e6560ca4d9b90e7827e30827220cb075ade931cc;hb=9b9f6771049ecd30f13138c32f23ba6562a613d5;hp=ecc2996593704a85e15cf76a3c163b32d9688a99;hpb=78fc931355e9449eae5a1370d3f078f4e780446c;p=rust.git diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index ecc29965937..e6560ca4d9b 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -1880,9 +1880,15 @@ fn suggest_traits_to_import( }; let sp = hir.span(id); let sp = if let Some(first_bound) = has_bounds { - // `sp` only covers `T`, change it so that it covers - // `T:` when appropriate sp.until(first_bound.span()) + } else if let Some(colon_sp) = + // If the generic param is declared with a colon but without bounds: + // fn foo(t: T) { ... } + param.colon_span_for_suggestions( + self.inh.tcx.sess.source_map(), + ) + { + sp.to(colon_sp) } else { sp };