Move some Map
methods onto TyCtxt
.
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
This commit is contained in:
parent
cd1d84cdf7
commit
f86f7ad5f2
197 changed files with 465 additions and 476 deletions
|
@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncClosureUsage {
|
|||
return;
|
||||
};
|
||||
|
||||
let mut body = cx.tcx.hir().body(body).value;
|
||||
let mut body = cx.tcx.hir_body(body).value;
|
||||
|
||||
// Only peel blocks that have no expressions.
|
||||
while let hir::ExprKind::Block(&hir::Block { stmts: [], expr: Some(tail), .. }, None) =
|
||||
|
|
|
@ -1057,7 +1057,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
check_no_mangle_on_generic_fn(
|
||||
no_mangle_attr,
|
||||
Some(generics),
|
||||
cx.tcx.hir().get_generics(it.id.owner_id.def_id).unwrap(),
|
||||
cx.tcx.hir_get_generics(it.id.owner_id.def_id).unwrap(),
|
||||
it.span,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -928,7 +928,7 @@ impl<'tcx> LateContext<'tcx> {
|
|||
while let hir::ExprKind::Path(ref qpath) = expr.kind
|
||||
&& let Some(parent_node) = match self.qpath_res(qpath, expr.hir_id) {
|
||||
Res::Local(hir_id) => Some(self.tcx.parent_hir_node(hir_id)),
|
||||
Res::Def(_, def_id) => self.tcx.hir().get_if_local(def_id),
|
||||
Res::Def(_, def_id) => self.tcx.hir_get_if_local(def_id),
|
||||
_ => None,
|
||||
}
|
||||
&& let Some(init) = match parent_node {
|
||||
|
@ -936,7 +936,7 @@ impl<'tcx> LateContext<'tcx> {
|
|||
hir::Node::LetStmt(hir::LetStmt { init, .. }) => *init,
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Const(.., body_id) | hir::ItemKind::Static(.., body_id) => {
|
||||
Some(self.tcx.hir().body(body_id).value)
|
||||
Some(self.tcx.hir_body(body_id).value)
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
|
|
|
@ -76,10 +76,8 @@ impl<'tcx> LateLintPass<'tcx> for DefaultCouldBeDerived {
|
|||
|
||||
// We now know we have a manually written definition of a `<Type as Default>::default()`.
|
||||
|
||||
let hir = cx.tcx.hir();
|
||||
|
||||
let type_def_id = def.did();
|
||||
let body = hir.body(body_id);
|
||||
let body = cx.tcx.hir_body(body_id);
|
||||
|
||||
// FIXME: evaluate bodies with statements and evaluate bindings to see if they would be
|
||||
// derivable.
|
||||
|
@ -92,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultCouldBeDerived {
|
|||
// Keep a mapping of field name to `hir::FieldDef` for every field in the type. We'll use
|
||||
// these to check for things like checking whether it has a default or using its span for
|
||||
// suggestions.
|
||||
let orig_fields = match hir.get_if_local(type_def_id) {
|
||||
let orig_fields = match cx.tcx.hir_get_if_local(type_def_id) {
|
||||
Some(hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Struct(hir::VariantData::Struct { fields, recovered: _ }, _generics),
|
||||
|
@ -183,7 +181,7 @@ fn mk_lint(
|
|||
if removed_all_fields {
|
||||
let msg = "to avoid divergence in behavior between `Struct { .. }` and \
|
||||
`<Struct as Default>::default()`, derive the `Default`";
|
||||
if let Some(hir::Node::Item(impl_)) = tcx.hir().get_if_local(impl_def_id) {
|
||||
if let Some(hir::Node::Item(impl_)) = tcx.hir_get_if_local(impl_def_id) {
|
||||
diag.multipart_suggestion_verbose(
|
||||
msg,
|
||||
vec![
|
||||
|
|
|
@ -155,7 +155,7 @@ fn suggest_question_mark<'tcx>(
|
|||
// Check that the function/closure/constant we are in has a `Result` type.
|
||||
// Otherwise suggesting using `?` may not be a good idea.
|
||||
{
|
||||
let ty = cx.typeck_results().expr_ty(cx.tcx.hir().body(body_id).value);
|
||||
let ty = cx.typeck_results().expr_ty(cx.tcx.hir_body(body_id).value);
|
||||
let ty::Adt(ret_adt, ..) = ty.kind() else { return false };
|
||||
if !cx.tcx.is_diagnostic_item(sym::Result, ret_adt.did()) {
|
||||
return false;
|
||||
|
|
|
@ -99,7 +99,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
self.context.cached_typeck_results.set(None);
|
||||
}
|
||||
|
||||
let body = self.context.tcx.hir().body(body_id);
|
||||
let body = self.context.tcx.hir_body(body_id);
|
||||
self.visit_body(body);
|
||||
self.context.enclosing_body = old_enclosing_body;
|
||||
|
||||
|
@ -191,7 +191,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
// in order for `check_fn` to be able to use them.
|
||||
let old_enclosing_body = self.context.enclosing_body.replace(body_id);
|
||||
let old_cached_typeck_results = self.context.cached_typeck_results.take();
|
||||
let body = self.context.tcx.hir().body(body_id);
|
||||
let body = self.context.tcx.hir_body(body_id);
|
||||
lint_callback!(self, check_fn, fk, decl, body, span, id);
|
||||
hir_visit::walk_fn(self, fk, decl, body_id, id);
|
||||
self.context.enclosing_body = old_enclosing_body;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue