Move methods from Map
to TyCtxt
, part 2.
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
This commit is contained in:
parent
ce36a966c7
commit
fd7b4bf4e1
108 changed files with 314 additions and 346 deletions
|
@ -489,7 +489,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let mut local_visitor = FindInferSourceVisitor::new(self, typeck_results, arg);
|
||||
if let Some(body) = self.tcx.hir().maybe_body_owned_by(
|
||||
if let Some(body) = self.tcx.hir_maybe_body_owned_by(
|
||||
self.tcx.typeck_root_def_id(body_def_id.to_def_id()).expect_local(),
|
||||
) {
|
||||
let expr = body.value;
|
||||
|
|
|
@ -147,7 +147,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
| ObligationCauseCode::BlockTailExpression(hir_id, ..) = cause.code()
|
||||
{
|
||||
let parent_id = tcx.hir().get_parent_item(*hir_id);
|
||||
if let Some(fn_decl) = tcx.hir().fn_decl_by_hir_id(parent_id.into()) {
|
||||
if let Some(fn_decl) = tcx.hir_fn_decl_by_hir_id(parent_id.into()) {
|
||||
let mut span: MultiSpan = fn_decl.output.span().into();
|
||||
let mut spans = Vec::new();
|
||||
let mut add_label = true;
|
||||
|
@ -490,7 +490,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
// obligation comes from the `impl`. Find that `impl` so that we can point
|
||||
// at it in the suggestion.
|
||||
let trait_did = trait_id.to_def_id();
|
||||
tcx.hir().trait_impls(trait_did).iter().find_map(|&impl_did| {
|
||||
tcx.hir_trait_impls(trait_did).iter().find_map(|&impl_did| {
|
||||
if let Node::Item(Item {
|
||||
kind: ItemKind::Impl(hir::Impl { self_ty, .. }), ..
|
||||
}) = tcx.hir_node_by_def_id(impl_did)
|
||||
|
|
|
@ -99,11 +99,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
let mut visitor = TypeParamSpanVisitor { tcx: self.tcx(), types: vec![] };
|
||||
match assoc_item.kind {
|
||||
ty::AssocKind::Fn => {
|
||||
let hir = self.tcx().hir();
|
||||
if let Some(hir_id) =
|
||||
assoc_item.def_id.as_local().map(|id| self.tcx().local_def_id_to_hir_id(id))
|
||||
{
|
||||
if let Some(decl) = hir.fn_decl_by_hir_id(hir_id) {
|
||||
if let Some(decl) = self.tcx().hir_fn_decl_by_hir_id(hir_id) {
|
||||
visitor.visit_fn_decl(decl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ pub fn find_param_with_region<'tcx>(
|
|||
_ => {}
|
||||
}
|
||||
|
||||
let body = hir.maybe_body_owned_by(def_id)?;
|
||||
let body = tcx.hir_maybe_body_owned_by(def_id)?;
|
||||
|
||||
let owner_id = hir.body_owner(body.id());
|
||||
let fn_decl = hir.fn_decl_by_hir_id(owner_id)?;
|
||||
let owner_id = tcx.hir_body_owner(body.id());
|
||||
let fn_decl = tcx.hir_fn_decl_by_hir_id(owner_id)?;
|
||||
let poly_fn_sig = tcx.fn_sig(id).instantiate_identity();
|
||||
|
||||
let fn_sig = tcx.liberate_late_bound_regions(id, poly_fn_sig);
|
||||
|
|
|
@ -624,7 +624,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.hir().maybe_body_owned_by(cause.body_id).and_then(|body| {
|
||||
self.tcx.hir_maybe_body_owned_by(cause.body_id).and_then(|body| {
|
||||
IfVisitor { err_span: span, found_if: false }
|
||||
.visit_body(&body)
|
||||
.is_break()
|
||||
|
|
|
@ -316,7 +316,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
if let Some(ty::GenericArgKind::Type(_)) = arg.map(|arg| arg.unpack())
|
||||
&& let Some(body) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id)
|
||||
&& let Some(body) = self.tcx.hir_maybe_body_owned_by(obligation.cause.body_id)
|
||||
{
|
||||
let mut expr_finder = FindExprBySpan::new(span, self.tcx);
|
||||
expr_finder.visit_expr(&body.value);
|
||||
|
|
|
@ -367,7 +367,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
(span.shrink_to_lo(), format!("(")),
|
||||
(span.shrink_to_hi(), format!(" as {})", cand.self_ty())),
|
||||
]
|
||||
} else if let Some(body) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) {
|
||||
} else if let Some(body) = self.tcx.hir_maybe_body_owned_by(obligation.cause.body_id) {
|
||||
let mut expr_finder = FindExprBySpan::new(span, self.tcx);
|
||||
expr_finder.visit_expr(body.value);
|
||||
if let Some(expr) = expr_finder.result &&
|
||||
|
|
|
@ -876,7 +876,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
span.remove_mark();
|
||||
}
|
||||
let mut expr_finder = FindExprBySpan::new(span, self.tcx);
|
||||
let Some(body) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) else {
|
||||
let Some(body) = self.tcx.hir_maybe_body_owned_by(obligation.cause.body_id) else {
|
||||
return;
|
||||
};
|
||||
expr_finder.visit_expr(body.value);
|
||||
|
@ -1347,8 +1347,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
// Issue #104961, we need to add parentheses properly for compound expressions
|
||||
// for example, `x.starts_with("hi".to_string() + "you")`
|
||||
// should be `x.starts_with(&("hi".to_string() + "you"))`
|
||||
let Some(body) =
|
||||
self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id)
|
||||
let Some(body) = self.tcx.hir_maybe_body_owned_by(obligation.cause.body_id)
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
|
@ -1447,7 +1446,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
span.remove_mark();
|
||||
}
|
||||
let mut expr_finder = super::FindExprBySpan::new(span, self.tcx);
|
||||
let Some(body) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) else {
|
||||
let Some(body) = self.tcx.hir_maybe_body_owned_by(obligation.cause.body_id) else {
|
||||
return false;
|
||||
};
|
||||
expr_finder.visit_expr(body.value);
|
||||
|
@ -1766,7 +1765,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
err.children.clear();
|
||||
|
||||
let span = obligation.cause.span;
|
||||
let body = self.tcx.hir().body_owned_by(obligation.cause.body_id);
|
||||
let body = self.tcx.hir_body_owned_by(obligation.cause.body_id);
|
||||
|
||||
let mut visitor = ReturnsVisitor::default();
|
||||
visitor.visit_body(&body);
|
||||
|
@ -2300,7 +2299,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
let coroutine_body =
|
||||
coroutine_did.as_local().and_then(|def_id| hir.maybe_body_owned_by(def_id));
|
||||
coroutine_did.as_local().and_then(|def_id| self.tcx.hir_maybe_body_owned_by(def_id));
|
||||
let mut visitor = AwaitsVisitor::default();
|
||||
if let Some(body) = coroutine_body {
|
||||
visitor.visit_body(&body);
|
||||
|
@ -4130,7 +4129,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
};
|
||||
suggest_restriction(
|
||||
tcx,
|
||||
hir.body_owner_def_id(body_id),
|
||||
tcx.hir_body_owner_def_id(body_id),
|
||||
generics,
|
||||
&format!("type parameter `{ty}`"),
|
||||
err,
|
||||
|
@ -4352,7 +4351,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
term: ty.into(),
|
||||
}),
|
||||
));
|
||||
let body_def_id = self.tcx.hir().enclosing_body_owner(body_id);
|
||||
let body_def_id = self.tcx.hir_enclosing_body_owner(body_id);
|
||||
// Add `<ExprTy as Iterator>::Item = _` obligation.
|
||||
ocx.register_obligation(Obligation::misc(
|
||||
self.tcx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue