Skip to content

Commit 89c6c61

Browse files
committed
Move methods from Map to TyCtxt, part 4.
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
1 parent 7ae6688 commit 89c6c61

File tree

114 files changed

+267
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+267
-318
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
505505
let var_id =
506506
self.infcx.tcx.closure_captures(def_id)[field.index()].get_root_variable();
507507

508-
Some(self.infcx.tcx.hir().name(var_id).to_string())
508+
Some(self.infcx.tcx.hir_name(var_id).to_string())
509509
}
510510
_ => {
511511
// Might need a revision when the fields in trait RFC is implemented
@@ -1124,7 +1124,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11241124
def_id, target_place, places
11251125
);
11261126
let hir_id = self.infcx.tcx.local_def_id_to_hir_id(def_id);
1127-
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
1127+
let expr = &self.infcx.tcx.hir_expect_expr(hir_id).kind;
11281128
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
11291129
if let &hir::ExprKind::Closure(&hir::Closure { kind, fn_decl_span, .. }) = expr {
11301130
for (captured_place, place) in

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
698698
if !matches!(k, hir::AssocItemKind::Fn { .. }) {
699699
continue;
700700
}
701-
if self.infcx.tcx.hir().name(hi) != self.infcx.tcx.hir().name(my_hir) {
701+
if self.infcx.tcx.hir_name(hi) != self.infcx.tcx.hir_name(my_hir) {
702702
continue;
703703
}
704704
f_in_trait_opt = Some(hi);

compiler/rustc_borrowck/src/diagnostics/opaque_suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
105105

106106
if let Some(opaque_def_id) = opaque_def_id.as_local()
107107
&& let hir::OpaqueTyOrigin::FnReturn { parent, .. } =
108-
tcx.hir().expect_opaque_ty(opaque_def_id).origin
108+
tcx.hir_expect_opaque_ty(opaque_def_id).origin
109109
{
110110
if let Some(sugg) = impl_trait_overcapture_suggestion(
111111
tcx,

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
343343
}
344344
};
345345
let hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }) =
346-
tcx.hir().expect_expr(self.mir_hir_id()).kind
346+
tcx.hir_expect_expr(self.mir_hir_id()).kind
347347
else {
348348
bug!("Closure is not defined by a closure expr");
349349
};

compiler/rustc_borrowck/src/diagnostics/var_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
6969
let upvar_hir_id = upvars[upvar_index].get_root_variable();
7070
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={upvar_hir_id:?}");
7171

72-
let upvar_name = tcx.hir().name(upvar_hir_id);
72+
let upvar_name = tcx.hir_name(upvar_hir_id);
7373
let upvar_span = tcx.hir().span(upvar_hir_id);
7474
debug!(
7575
"get_upvar_name_and_span_for_region: upvar_name={upvar_name:?} upvar_span={upvar_span:?}",

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTr
6363
},
6464
};
6565

66-
for attr in tcx.hir().attrs(rustc_hir::CRATE_HIR_ID) {
66+
for attr in tcx.hir_attrs(rustc_hir::CRATE_HIR_ID) {
6767
ams.check_attr(attr);
6868
}
6969

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
473473
) -> OngoingCodegen<B> {
474474
let (coordinator_send, coordinator_receive) = channel();
475475

476-
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
476+
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
477477
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
478478

479479
let crate_info = CrateInfo::new(tcx, target_cpu);

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ impl CrateInfo {
876876
let linked_symbols =
877877
crate_types.iter().map(|&c| (c, crate::back::linker::linked_symbols(tcx, c))).collect();
878878
let local_crate_name = tcx.crate_name(LOCAL_CRATE);
879-
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
879+
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
880880
let subsystem =
881881
ast::attr::first_attr_value_str_by_name(crate_attrs, sym::windows_subsystem);
882882
let windows_subsystem = subsystem.map(|subsystem| {

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
6464
);
6565
}
6666

67-
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(did));
67+
let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(did));
6868
let mut codegen_fn_attrs = CodegenFnAttrs::new();
6969
if tcx.should_inherit_track_caller(did) {
7070
codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER;
@@ -79,7 +79,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
7979

8080
// When `no_builtins` is applied at the crate level, we should add the
8181
// `no-builtins` attribute to each function to ensure it takes effect in LTO.
82-
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
82+
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
8383
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
8484
if no_builtins {
8585
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_BUILTINS;

compiler/rustc_const_eval/src/check_consts/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn rustc_allow_const_fn_unstable(
8181
def_id: LocalDefId,
8282
feature_gate: Symbol,
8383
) -> bool {
84-
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
84+
let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(def_id));
8585

8686
find_attr!(attrs, AttributeKind::AllowConstFnUnstable(syms) if syms.contains(&feature_gate))
8787
}

0 commit comments

Comments
 (0)