Rollup merge of #139232 - nnethercote:remove-Map-5, r=Zalathar
Move methods from `Map` to `TyCtxt`, part 5. This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR. A follow-up to #137504. r? `@Zalathar`
This commit is contained in:
@@ -578,10 +578,8 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.hir().span(hir_id),
|
||||
"parameter should have been resolved",
|
||||
);
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(tcx.hir_span(hir_id), "parameter should have been resolved");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1049,7 +1047,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
leaf_def.as_ref().is_some_and(|node_item| !node_item.defining_node.is_from_trait());
|
||||
|
||||
if !is_implemented_here {
|
||||
let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id));
|
||||
let full_impl_span = tcx.hir_span_with_body(tcx.local_def_id_to_hir_id(impl_id));
|
||||
match tcx.eval_default_body_stability(trait_item_id, full_impl_span) {
|
||||
EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable(
|
||||
tcx,
|
||||
@@ -1105,7 +1103,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
}
|
||||
|
||||
if !missing_items.is_empty() {
|
||||
let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id));
|
||||
let full_impl_span = tcx.hir_span_with_body(tcx.local_def_id_to_hir_id(impl_id));
|
||||
missing_items_err(tcx, impl_id, &missing_items, full_impl_span);
|
||||
}
|
||||
|
||||
@@ -1321,7 +1319,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
||||
let typing_env = ty::TypingEnv::non_body_analysis(tcx, field.did);
|
||||
let layout = tcx.layout_of(typing_env.as_query_input(ty));
|
||||
// We are currently checking the type this field came from, so it must be local
|
||||
let span = tcx.hir().span_if_local(field.did).unwrap();
|
||||
let span = tcx.hir_span_if_local(field.did).unwrap();
|
||||
let trivial = layout.is_ok_and(|layout| layout.is_1zst());
|
||||
if !trivial {
|
||||
return (span, trivial, None);
|
||||
|
||||
@@ -1208,7 +1208,7 @@ fn extract_spans_for_error_reporting<'tcx>(
|
||||
TypeError::ArgumentMutability(i) | TypeError::ArgumentSorts(ExpectedFound { .. }, i) => {
|
||||
(impl_args.nth(i).unwrap(), trait_args.and_then(|mut args| args.nth(i)))
|
||||
}
|
||||
_ => (cause.span, tcx.hir().span_if_local(trait_m.def_id)),
|
||||
_ => (cause.span, tcx.hir_span_if_local(trait_m.def_id)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1261,7 +1261,7 @@ fn compare_self_type<'tcx>(
|
||||
self_descr
|
||||
);
|
||||
err.span_label(impl_m_span, format!("`{self_descr}` used in impl"));
|
||||
if let Some(span) = tcx.hir().span_if_local(trait_m.def_id) {
|
||||
if let Some(span) = tcx.hir_span_if_local(trait_m.def_id) {
|
||||
err.span_label(span, format!("trait method declared without `{self_descr}`"));
|
||||
} else {
|
||||
err.note_trait_signature(trait_m.name, trait_m.signature(tcx));
|
||||
@@ -1281,7 +1281,7 @@ fn compare_self_type<'tcx>(
|
||||
self_descr
|
||||
);
|
||||
err.span_label(impl_m_span, format!("expected `{self_descr}` in impl"));
|
||||
if let Some(span) = tcx.hir().span_if_local(trait_m.def_id) {
|
||||
if let Some(span) = tcx.hir_span_if_local(trait_m.def_id) {
|
||||
err.span_label(span, format!("`{self_descr}` used in trait"));
|
||||
} else {
|
||||
err.note_trait_signature(trait_m.name, trait_m.signature(tcx));
|
||||
@@ -1389,7 +1389,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
.collect();
|
||||
(Some(arg_spans), impl_trait_spans)
|
||||
} else {
|
||||
let trait_span = tcx.hir().span_if_local(trait_.def_id);
|
||||
let trait_span = tcx.hir_span_if_local(trait_.def_id);
|
||||
(trait_span.map(|s| vec![s]), vec![])
|
||||
};
|
||||
|
||||
@@ -1481,7 +1481,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
}
|
||||
})
|
||||
})
|
||||
.or_else(|| tcx.hir().span_if_local(trait_m.def_id));
|
||||
.or_else(|| tcx.hir_span_if_local(trait_m.def_id));
|
||||
|
||||
let (impl_m_sig, _) = &tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
|
||||
let pos = impl_number_args.saturating_sub(1);
|
||||
@@ -2366,7 +2366,7 @@ fn try_report_async_mismatch<'tcx>(
|
||||
return Err(tcx.sess.dcx().emit_err(MethodShouldReturnFuture {
|
||||
span: tcx.def_span(impl_m.def_id),
|
||||
method_name: tcx.item_ident(impl_m.def_id),
|
||||
trait_item_span: tcx.hir().span_if_local(trait_m.def_id),
|
||||
trait_item_span: tcx.hir_span_if_local(trait_m.def_id),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ fn missing_items_err(
|
||||
tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity(),
|
||||
));
|
||||
let code = format!("{padding}{snippet}\n{padding}");
|
||||
if let Some(span) = tcx.hir().span_if_local(trait_item.def_id) {
|
||||
if let Some(span) = tcx.hir_span_if_local(trait_item.def_id) {
|
||||
missing_trait_item_label
|
||||
.push(errors::MissingTraitItemLabel { span, item: trait_item.name });
|
||||
missing_trait_item.push(errors::MissingTraitItemSuggestion {
|
||||
@@ -534,7 +534,7 @@ fn bad_variant_count<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>, sp: Span, d
|
||||
let variant_spans: Vec<_> = adt
|
||||
.variants()
|
||||
.iter()
|
||||
.map(|variant| tcx.hir().span_if_local(variant.def_id).unwrap())
|
||||
.map(|variant| tcx.hir_span_if_local(variant.def_id).unwrap())
|
||||
.collect();
|
||||
let (mut spans, mut many) = (Vec::new(), None);
|
||||
if let [start @ .., end] = &*variant_spans {
|
||||
|
||||
Reference in New Issue
Block a user