diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-02-03 10:45:49 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-02-17 13:21:02 +1100 |
| commit | f86f7ad5f2d3eb6631e5fab57630a4fee9a50d01 (patch) | |
| tree | e63bccd3bd1aebd7514838377a653ca2aa35868b /compiler/rustc_lint/src | |
| parent | cd1d84cdf76e86f2647eb7fd157047b73e76bdf5 (diff) | |
| download | rust-f86f7ad5f2d3eb6631e5fab57630a4fee9a50d01.tar.gz rust-f86f7ad5f2d3eb6631e5fab57630a4fee9a50d01.zip | |
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`.
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/async_closures.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/default_could_be_derived.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/for_loops_over_fallibles.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/late.rs | 4 |
6 files changed, 10 insertions, 12 deletions
diff --git a/compiler/rustc_lint/src/async_closures.rs b/compiler/rustc_lint/src/async_closures.rs index 5d40b8ab2ee..02fb22bf782 100644 --- a/compiler/rustc_lint/src/async_closures.rs +++ b/compiler/rustc_lint/src/async_closures.rs @@ -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) = diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index ecd40a52e75..e449f110613 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -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, ); } diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index a67b404e6e1..c74158102c7 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -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, }, diff --git a/compiler/rustc_lint/src/default_could_be_derived.rs b/compiler/rustc_lint/src/default_could_be_derived.rs index bae9defa687..59e38a882dd 100644 --- a/compiler/rustc_lint/src/default_could_be_derived.rs +++ b/compiler/rustc_lint/src/default_could_be_derived.rs @@ -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