Remove some more usages of guess_head_span
This commit is contained in:
parent
4b890f3474
commit
fcfb3e92a0
@ -823,10 +823,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
let found_kind = self.closure_kind(closure_substs).unwrap();
|
||||
let closure_span =
|
||||
self.tcx.sess.source_map().guess_head_span(
|
||||
self.tcx.hir().span_if_local(closure_def_id).unwrap(),
|
||||
);
|
||||
let closure_span = self.tcx.def_span(closure_def_id);
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
closure_span,
|
||||
@ -951,9 +948,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let found_span = found_did
|
||||
.and_then(|did| self.tcx.hir().span_if_local(did))
|
||||
.map(|sp| self.tcx.sess.source_map().guess_head_span(sp)); // the sp could be a closure
|
||||
let found_span = found_did.and_then(|did| self.tcx.hir().span_if_local(did));
|
||||
|
||||
if self.reported_closure_mismatch.borrow().contains(&(span, found_span)) {
|
||||
// We check closures twice, with obligations flowing in different directions,
|
||||
|
@ -1543,7 +1543,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
ty::Generator(..) => "generator",
|
||||
_ => "function",
|
||||
};
|
||||
let span = self.tcx.sess.source_map().guess_head_span(span);
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
span,
|
||||
|
@ -171,14 +171,7 @@ fn compare_predicate_entailment<'tcx>(
|
||||
let trait_m_predicates = tcx.predicates_of(trait_m.def_id);
|
||||
|
||||
// Check region bounds.
|
||||
check_region_bounds_on_impl_item(
|
||||
tcx,
|
||||
impl_m_span,
|
||||
impl_m,
|
||||
trait_m,
|
||||
&trait_m_generics,
|
||||
&impl_m_generics,
|
||||
)?;
|
||||
check_region_bounds_on_impl_item(tcx, impl_m, trait_m, &trait_m_generics, &impl_m_generics)?;
|
||||
|
||||
// Create obligations for each predicate declared by the impl
|
||||
// definition in the context of the trait's parameter
|
||||
@ -410,7 +403,6 @@ fn compare_predicate_entailment<'tcx>(
|
||||
|
||||
fn check_region_bounds_on_impl_item<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
impl_m: &ty::AssocItem,
|
||||
trait_m: &ty::AssocItem,
|
||||
trait_generics: &ty::Generics,
|
||||
@ -436,23 +428,25 @@ fn check_region_bounds_on_impl_item<'tcx>(
|
||||
// are zero. Since I don't quite know how to phrase things at
|
||||
// the moment, give a kind of vague error message.
|
||||
if trait_params != impl_params {
|
||||
let item_kind = assoc_item_kind_str(impl_m);
|
||||
let span = impl_m
|
||||
.def_id
|
||||
.as_local()
|
||||
.and_then(|did| tcx.hir().get_generics(did))
|
||||
.map_or(span, |g| g.span);
|
||||
let generics_span = tcx.hir().span_if_local(trait_m.def_id).map(|sp| {
|
||||
trait_m
|
||||
.def_id
|
||||
.as_local()
|
||||
.and_then(|did| tcx.hir().get_generics(did))
|
||||
.map_or(sp, |g| g.span)
|
||||
});
|
||||
let span = tcx
|
||||
.hir()
|
||||
.get_generics(impl_m.def_id.expect_local())
|
||||
.expect("expected impl item to have generics or else we can't compare them")
|
||||
.span;
|
||||
let generics_span = if let Some(local_def_id) = trait_m.def_id.as_local() {
|
||||
Some(
|
||||
tcx.hir()
|
||||
.get_generics(local_def_id)
|
||||
.expect("expected trait item to have generics or else we can't compare them")
|
||||
.span,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let reported = tcx.sess.emit_err(LifetimesOrBoundsMismatchOnTrait {
|
||||
span,
|
||||
item_kind,
|
||||
item_kind: assoc_item_kind_str(impl_m),
|
||||
ident: impl_m.ident(tcx),
|
||||
generics_span,
|
||||
});
|
||||
@ -1201,7 +1195,6 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||
|
||||
check_region_bounds_on_impl_item(
|
||||
tcx,
|
||||
impl_ty_span,
|
||||
impl_ty,
|
||||
trait_ty,
|
||||
&trait_ty_generics,
|
||||
|
Loading…
x
Reference in New Issue
Block a user