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:
commit
d712f67897
40 changed files with 154 additions and 223 deletions
|
@ -1112,18 +1112,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
})
|
||||
.collect::<Option<Vec<ArgKind>>>()?,
|
||||
),
|
||||
Node::Item(&hir::Item { span, kind: hir::ItemKind::Fn(ref sig, ..), .. })
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
span,
|
||||
kind: hir::ImplItemKind::Fn(ref sig, _),
|
||||
..
|
||||
})
|
||||
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref sig, ..), .. })
|
||||
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(ref sig, _), .. })
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
span,
|
||||
kind: hir::TraitItemKind::Fn(ref sig, _),
|
||||
..
|
||||
kind: hir::TraitItemKind::Fn(ref sig, _), ..
|
||||
}) => (
|
||||
sm.guess_head_span(span),
|
||||
sig.span,
|
||||
sig.decl
|
||||
.inputs
|
||||
.iter()
|
||||
|
@ -1138,7 +1132,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
),
|
||||
Node::Ctor(ref variant_data) => {
|
||||
let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| hir.span(id));
|
||||
let span = sm.guess_head_span(span);
|
||||
(span, vec![ArgKind::empty(); variant_data.fields().len()])
|
||||
}
|
||||
_ => panic!("non-FnLike node found: {:?}", node),
|
||||
|
@ -2185,7 +2178,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let mut post = vec![];
|
||||
for def_id in impls {
|
||||
match self.tcx.span_of_impl(*def_id) {
|
||||
Ok(span) => spans.push(self.tcx.sess.source_map().guess_head_span(span)),
|
||||
Ok(span) => spans.push(span),
|
||||
Err(name) => {
|
||||
crates.push(name);
|
||||
if let Some(header) = to_pretty_impl_header(self.tcx, *def_id) {
|
||||
|
@ -2532,8 +2525,7 @@ pub fn recursive_type_with_infinite_size_error<'tcx>(
|
|||
spans: Vec<(Span, Option<hir::HirId>)>,
|
||||
) {
|
||||
assert!(type_def_id.is_local());
|
||||
let span = tcx.hir().span_if_local(type_def_id).unwrap();
|
||||
let span = tcx.sess.source_map().guess_head_span(span);
|
||||
let span = tcx.def_span(type_def_id);
|
||||
let path = tcx.def_path_str(type_def_id);
|
||||
let mut err =
|
||||
struct_span_err!(tcx.sess, span, E0072, "recursive type `{}` has infinite size", path);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue