use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
+ MultiSpan,
};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::ToPolyTraitRef;
use rustc_middle::ty::{self, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable};
use rustc_span::symbol::{kw, sym, Ident};
-use rustc_span::{lev_distance, source_map, ExpnKind, FileName, MacroKind, MultiSpan, Span};
+use rustc_span::{lev_distance, source_map, ExpnKind, FileName, MacroKind, Span};
use rustc_trait_selection::traits::error_reporting::on_unimplemented::InferCtxtExt as _;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_trait_selection::traits::{
};
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: T) { ... }
+ param.colon_span_for_suggestions(
+ self.inh.tcx.sess.source_map(),
+ )
+ {
+ sp.to(colon_sp)
} else {
sp
};