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:
commit
bda2ea4d01
75 changed files with 175 additions and 208 deletions
|
@ -1051,7 +1051,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
None?
|
||||
}
|
||||
let args = self.node_args_opt(expr.hir_id)?;
|
||||
let span = tcx.hir().span(segment.hir_id);
|
||||
let span = tcx.hir_span(segment.hir_id);
|
||||
let insert_span = segment.ident.span.shrink_to_hi().with_hi(span.hi());
|
||||
InsertableGenericArgs {
|
||||
insert_span,
|
||||
|
@ -1110,7 +1110,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
if generics.has_impl_trait() {
|
||||
return None;
|
||||
}
|
||||
let span = tcx.hir().span(segment.hir_id);
|
||||
let span = tcx.hir_span(segment.hir_id);
|
||||
let insert_span = segment.ident.span.shrink_to_hi().with_hi(span.hi());
|
||||
Some(InsertableGenericArgs {
|
||||
insert_span,
|
||||
|
@ -1144,7 +1144,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
if !segment.infer_args || generics.has_impl_trait() {
|
||||
do yeet ();
|
||||
}
|
||||
let span = tcx.hir().span(segment.hir_id);
|
||||
let span = tcx.hir_span(segment.hir_id);
|
||||
let insert_span = segment.ident.span.shrink_to_hi().with_hi(span.hi());
|
||||
InsertableGenericArgs {
|
||||
insert_span,
|
||||
|
|
|
@ -51,7 +51,6 @@ pub fn find_param_with_region<'tcx>(
|
|||
_ => return None, // not a free region
|
||||
};
|
||||
|
||||
let hir = &tcx.hir();
|
||||
let def_id = id.as_local()?;
|
||||
|
||||
// FIXME: use def_kind
|
||||
|
@ -93,7 +92,7 @@ pub fn find_param_with_region<'tcx>(
|
|||
});
|
||||
found_anon_region.then(|| {
|
||||
let ty_hir_id = fn_decl.inputs[index].hir_id;
|
||||
let param_ty_span = hir.span(ty_hir_id);
|
||||
let param_ty_span = tcx.hir_span(ty_hir_id);
|
||||
let is_first = index == 0;
|
||||
AnonymousParamInfo { param, param_ty: new_param_ty, param_ty_span, kind, is_first }
|
||||
})
|
||||
|
|
|
@ -1236,7 +1236,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
);
|
||||
// Only suggest derive if this isn't a derived obligation,
|
||||
// and the struct is local.
|
||||
if let Some(span) = self.tcx.hir().span_if_local(def.did())
|
||||
if let Some(span) = self.tcx.hir_span_if_local(def.did())
|
||||
&& obligation.cause.code().parent().is_none()
|
||||
{
|
||||
if ty.is_structural_eq_shallow(self.tcx) {
|
||||
|
@ -2943,7 +2943,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let found_node = found_did.and_then(|did| self.tcx.hir_get_if_local(did));
|
||||
let found_span = found_did.and_then(|did| self.tcx.hir().span_if_local(did));
|
||||
let found_span = found_did.and_then(|did| self.tcx.hir_span_if_local(did));
|
||||
|
||||
if !self.reported_signature_mismatch.borrow_mut().insert((span, found_span)) {
|
||||
// We check closures twice, with obligations flowing in different directions,
|
||||
|
@ -3030,7 +3030,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
node: Node<'_>,
|
||||
) -> Option<(Span, Option<Span>, Vec<ArgKind>)> {
|
||||
let sm = self.tcx.sess.source_map();
|
||||
let hir = self.tcx.hir();
|
||||
Some(match node {
|
||||
Node::Expr(&hir::Expr {
|
||||
kind: hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, fn_arg_span, .. }),
|
||||
|
@ -3086,7 +3085,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
.collect::<Vec<ArgKind>>(),
|
||||
),
|
||||
Node::Ctor(variant_data) => {
|
||||
let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| hir.span(id));
|
||||
let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| self.tcx.hir_span(id));
|
||||
(span, None, vec![ArgKind::empty(); variant_data.fields().len()])
|
||||
}
|
||||
_ => panic!("non-FnLike node found: {node:?}"),
|
||||
|
|
|
@ -398,7 +398,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
if !self.tcx.is_impl_trait_in_trait(trait_item_def_id) {
|
||||
if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) {
|
||||
if let Some(span) = self.tcx.hir_span_if_local(trait_item_def_id) {
|
||||
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
|
||||
err.span_label(span, format!("definition of `{item_name}` from trait"));
|
||||
}
|
||||
|
|
|
@ -1193,7 +1193,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
// FIXME(compiler-errors): This is kind of a mess, but required for obligations
|
||||
// that come from a path expr to affect the *call* expr.
|
||||
c @ ObligationCauseCode::WhereClauseInExpr(_, _, hir_id, _)
|
||||
if self.tcx.hir().span(*hir_id).lo() == span.lo() =>
|
||||
if self.tcx.hir_span(*hir_id).lo() == span.lo() =>
|
||||
{
|
||||
c
|
||||
}
|
||||
|
@ -4481,7 +4481,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
Obligation::new(self.tcx, obligation.cause.clone(), obligation.param_env, trait_ref);
|
||||
|
||||
if self.predicate_must_hold_modulo_regions(&obligation) {
|
||||
let arg_span = self.tcx.hir().span(*arg_hir_id);
|
||||
let arg_span = self.tcx.hir_span(*arg_hir_id);
|
||||
err.multipart_suggestion_verbose(
|
||||
format!("use a unary tuple instead"),
|
||||
vec![(arg_span.shrink_to_lo(), "(".into()), (arg_span.shrink_to_hi(), ",)".into())],
|
||||
|
@ -4521,7 +4521,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
parent_code: _,
|
||||
} = cause.code()
|
||||
{
|
||||
let arg_span = self.tcx.hir().span(*arg_hir_id);
|
||||
let arg_span = self.tcx.hir_span(*arg_hir_id);
|
||||
let mut sp: MultiSpan = arg_span.into();
|
||||
|
||||
sp.push_span_label(
|
||||
|
@ -4530,7 +4530,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
generic types that should be inferred from this argument",
|
||||
);
|
||||
sp.push_span_label(
|
||||
self.tcx.hir().span(*call_hir_id),
|
||||
self.tcx.hir_span(*call_hir_id),
|
||||
"add turbofish arguments to this call to \
|
||||
specify the types manually, even if it's redundant",
|
||||
);
|
||||
|
@ -4939,7 +4939,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
.type_implements_trait(pred.def_id(), [rhs_ty, lhs_ty], param_env)
|
||||
.must_apply_modulo_regions()
|
||||
{
|
||||
let lhs_span = tcx.hir().span(lhs_hir_id);
|
||||
let lhs_span = tcx.hir_span(lhs_hir_id);
|
||||
let sm = tcx.sess.source_map();
|
||||
if let Ok(rhs_snippet) = sm.span_to_snippet(rhs_span)
|
||||
&& let Ok(lhs_snippet) = sm.span_to_snippet(lhs_span)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue