1
Fork 0

Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, r=cjgillot

Replace some `guess_head_span` with `def_span`

This patch fixes a part of #97417.
r? `@cjgillot`
This commit is contained in:
Guillaume Gomez 2022-07-06 20:43:24 +02:00 committed by GitHub
commit d712f67897
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 154 additions and 223 deletions

View file

@ -340,10 +340,7 @@ fn report_negative_positive_conflict(
positive_impl_def_id: DefId,
sg: &mut specialization_graph::Graph,
) {
let impl_span = tcx
.sess
.source_map()
.guess_head_span(tcx.span_of_impl(local_impl_def_id.to_def_id()).unwrap());
let impl_span = tcx.def_span(local_impl_def_id);
let mut err = struct_span_err!(
tcx.sess,
@ -356,10 +353,7 @@ fn report_negative_positive_conflict(
match tcx.span_of_impl(negative_impl_def_id) {
Ok(span) => {
err.span_label(
tcx.sess.source_map().guess_head_span(span),
"negative implementation here".to_string(),
);
err.span_label(span, "negative implementation here");
}
Err(cname) => {
err.note(&format!("negative implementation in crate `{}`", cname));
@ -368,10 +362,7 @@ fn report_negative_positive_conflict(
match tcx.span_of_impl(positive_impl_def_id) {
Ok(span) => {
err.span_label(
tcx.sess.source_map().guess_head_span(span),
"positive implementation here".to_string(),
);
err.span_label(span, "positive implementation here");
}
Err(cname) => {
err.note(&format!("positive implementation in crate `{}`", cname));
@ -388,8 +379,7 @@ fn report_conflicting_impls(
used_to_be_allowed: Option<FutureCompatOverlapErrorKind>,
sg: &mut specialization_graph::Graph,
) {
let impl_span =
tcx.sess.source_map().guess_head_span(tcx.span_of_impl(impl_def_id.to_def_id()).unwrap());
let impl_span = tcx.def_span(impl_def_id);
// Work to be done after we've built the DiagnosticBuilder. We have to define it
// now because the struct_lint methods don't return back the DiagnosticBuilder
@ -416,10 +406,7 @@ fn report_conflicting_impls(
let mut err = err.build(&msg);
match tcx.span_of_impl(overlap.with_impl) {
Ok(span) => {
err.span_label(
tcx.sess.source_map().guess_head_span(span),
"first implementation here".to_string(),
);
err.span_label(span, "first implementation here".to_string());
err.span_label(
impl_span,