Skip to content

Commit 33ddf0c

Browse files
authored
Rollup merge of rust-lang#137504 - nnethercote:remove-Map-4, r=Zalathar
Move methods from Map to TyCtxt, part 4. A follow-up to rust-lang#137350. r? ``@Zalathar``
2 parents 9b185bc + 256c27e commit 33ddf0c

File tree

124 files changed

+390
-441
lines changed

Some content is hidden

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

124 files changed

+390
-441
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
475475
) -> OngoingCodegen<B> {
476476
let (coordinator_send, coordinator_receive) = channel();
477477

478-
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
478+
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
479479
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
480480

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

compiler/rustc_codegen_ssa/src/base.rs

+1-1
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
6060
);
6161
}
6262

63-
let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(did));
63+
let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(did));
6464
let mut codegen_fn_attrs = CodegenFnAttrs::new();
6565
if tcx.should_inherit_track_caller(did) {
6666
codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER;
@@ -75,7 +75,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
7575

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

compiler/rustc_const_eval/src/check_consts/mod.rs

+1-1
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
}

compiler/rustc_driver_impl/src/pretty.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
268268
let tcx = ex.tcx();
269269
let f = |annotation: &dyn pprust_hir::PpAnn| {
270270
let sm = sess.source_map();
271-
let hir_map = tcx.hir();
272-
let attrs = |id| hir_map.attrs(id);
271+
let attrs = |id| tcx.hir_attrs(id);
273272
pprust_hir::print_crate(
274273
sm,
275274
tcx.hir_root_module(),

compiler/rustc_hir_analysis/src/check/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
185185
/// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo`
186186
/// projections that would result in "inheriting lifetimes".
187187
fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) {
188-
let hir::OpaqueTy { origin, .. } = *tcx.hir().expect_opaque_ty(def_id);
188+
let hir::OpaqueTy { origin, .. } = *tcx.hir_expect_opaque_ty(def_id);
189189

190190
// HACK(jynelson): trying to infer the type of `impl trait` breaks documenting
191191
// `async-std` (and `pub async fn` in general).
@@ -785,7 +785,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
785785
check_type_alias_type_params_are_used(tcx, def_id);
786786
}
787787
DefKind::ForeignMod => {
788-
let it = tcx.hir().expect_item(def_id);
788+
let it = tcx.hir_expect_item(def_id);
789789
let hir::ItemKind::ForeignMod { abi, items } = it.kind else {
790790
return;
791791
};

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ fn report_trait_method_mismatch<'tcx>(
10311031
// When the `impl` receiver is an arbitrary self type, like `self: Box<Self>`, the
10321032
// span points only at the type `Box<Self`>, but we want to cover the whole
10331033
// argument pattern and type.
1034-
let (sig, body) = tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
1034+
let (sig, body) = tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
10351035
let span = tcx
10361036
.hir_body_param_names(body)
10371037
.zip(sig.decl.inputs.iter())
@@ -1051,7 +1051,7 @@ fn report_trait_method_mismatch<'tcx>(
10511051
// Suggestion to change output type. We do not suggest in `async` functions
10521052
// to avoid complex logic or incorrect output.
10531053
if let ImplItemKind::Fn(sig, _) =
1054-
&tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).kind
1054+
&tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).kind
10551055
&& !sig.header.asyncness.is_async()
10561056
{
10571057
let msg = "change the output type to match the trait";
@@ -1190,12 +1190,12 @@ fn extract_spans_for_error_reporting<'tcx>(
11901190
) -> (Span, Option<Span>) {
11911191
let tcx = infcx.tcx;
11921192
let mut impl_args = {
1193-
let (sig, _) = tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
1193+
let (sig, _) = tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
11941194
sig.decl.inputs.iter().map(|t| t.span).chain(iter::once(sig.decl.output.span()))
11951195
};
11961196

11971197
let trait_args = trait_m.def_id.as_local().map(|def_id| {
1198-
let (sig, _) = tcx.hir().expect_trait_item(def_id).expect_fn();
1198+
let (sig, _) = tcx.hir_expect_trait_item(def_id).expect_fn();
11991199
sig.decl.inputs.iter().map(|t| t.span).chain(iter::once(sig.decl.output.span()))
12001200
});
12011201

@@ -1371,7 +1371,7 @@ fn compare_number_of_generics<'tcx>(
13711371
spans
13721372
};
13731373
let (trait_spans, impl_trait_spans) = if let Some(def_id) = trait_.def_id.as_local() {
1374-
let trait_item = tcx.hir().expect_trait_item(def_id);
1374+
let trait_item = tcx.hir_expect_trait_item(def_id);
13751375
let arg_spans: Vec<Span> = arg_spans(trait_.kind, trait_item.generics);
13761376
let impl_trait_spans: Vec<Span> = trait_item
13771377
.generics
@@ -1388,7 +1388,7 @@ fn compare_number_of_generics<'tcx>(
13881388
(trait_span.map(|s| vec![s]), vec![])
13891389
};
13901390

1391-
let impl_item = tcx.hir().expect_impl_item(impl_.def_id.expect_local());
1391+
let impl_item = tcx.hir_expect_impl_item(impl_.def_id.expect_local());
13921392
let impl_item_impl_trait_spans: Vec<Span> = impl_item
13931393
.generics
13941394
.params
@@ -1466,7 +1466,7 @@ fn compare_number_of_method_arguments<'tcx>(
14661466
.def_id
14671467
.as_local()
14681468
.and_then(|def_id| {
1469-
let (trait_m_sig, _) = &tcx.hir().expect_trait_item(def_id).expect_fn();
1469+
let (trait_m_sig, _) = &tcx.hir_expect_trait_item(def_id).expect_fn();
14701470
let pos = trait_number_args.saturating_sub(1);
14711471
trait_m_sig.decl.inputs.get(pos).map(|arg| {
14721472
if pos == 0 {
@@ -1478,7 +1478,7 @@ fn compare_number_of_method_arguments<'tcx>(
14781478
})
14791479
.or_else(|| tcx.hir().span_if_local(trait_m.def_id));
14801480

1481-
let (impl_m_sig, _) = &tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
1481+
let (impl_m_sig, _) = &tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
14821482
let pos = impl_number_args.saturating_sub(1);
14831483
let impl_span = impl_m_sig
14841484
.decl
@@ -1580,10 +1580,10 @@ fn compare_synthetic_generics<'tcx>(
15801580
// as another generic argument
15811581
let new_name = tcx.opt_item_name(trait_def_id)?;
15821582
let trait_m = trait_m.def_id.as_local()?;
1583-
let trait_m = tcx.hir().expect_trait_item(trait_m);
1583+
let trait_m = tcx.hir_expect_trait_item(trait_m);
15841584

15851585
let impl_m = impl_m.def_id.as_local()?;
1586-
let impl_m = tcx.hir().expect_impl_item(impl_m);
1586+
let impl_m = tcx.hir_expect_impl_item(impl_m);
15871587

15881588
// in case there are no generics, take the spot between the function name
15891589
// and the opening paren of the argument list
@@ -1613,7 +1613,7 @@ fn compare_synthetic_generics<'tcx>(
16131613
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
16141614
let _: Option<_> = try {
16151615
let impl_m = impl_m.def_id.as_local()?;
1616-
let impl_m = tcx.hir().expect_impl_item(impl_m);
1616+
let impl_m = tcx.hir_expect_impl_item(impl_m);
16171617
let (sig, _) = impl_m.expect_fn();
16181618
let input_tys = sig.decl.inputs;
16191619

@@ -1855,7 +1855,7 @@ fn compare_const_predicate_entailment<'tcx>(
18551855
debug!(?impl_ty, ?trait_ty);
18561856

18571857
// Locate the Span containing just the type of the offending impl
1858-
let (ty, _) = tcx.hir().expect_impl_item(impl_ct_def_id).expect_const();
1858+
let (ty, _) = tcx.hir_expect_impl_item(impl_ct_def_id).expect_const();
18591859
cause.span = ty.span;
18601860

18611861
let mut diag = struct_span_code_err!(
@@ -1868,7 +1868,7 @@ fn compare_const_predicate_entailment<'tcx>(
18681868

18691869
let trait_c_span = trait_ct.def_id.as_local().map(|trait_ct_def_id| {
18701870
// Add a label to the Span containing just the type of the const
1871-
let (ty, _) = tcx.hir().expect_trait_item(trait_ct_def_id).expect_const();
1871+
let (ty, _) = tcx.hir_expect_trait_item(trait_ct_def_id).expect_const();
18721872
ty.span
18731873
});
18741874

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
513513
continue;
514514
}
515515

516-
let gat_item_hir = tcx.hir().expect_trait_item(gat_def_id);
516+
let gat_item_hir = tcx.hir_expect_trait_item(gat_def_id);
517517
debug!(?required_bounds);
518518
let param_env = tcx.param_env(gat_def_id);
519519

compiler/rustc_hir_analysis/src/check_unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
3131
if used_trait_imports.contains(&id) {
3232
continue;
3333
}
34-
let item = tcx.hir().expect_item(id);
34+
let item = tcx.hir_expect_item(id);
3535
if item.span.is_dummy() {
3636
continue;
3737
}

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn visit_implementation_of_drop(checker: &Checker<'_>) -> Result<(), ErrorGuaran
8282
_ => {}
8383
}
8484

85-
let impl_ = tcx.hir().expect_item(impl_did).expect_impl();
85+
let impl_ = tcx.hir_expect_item(impl_did).expect_impl();
8686

8787
Err(tcx.dcx().emit_err(errors::DropImplOnWrongItem { span: impl_.self_ty.span }))
8888
}
@@ -109,7 +109,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
109109
match type_allowed_to_implement_copy(tcx, param_env, self_type, cause, impl_header.safety) {
110110
Ok(()) => Ok(()),
111111
Err(CopyImplementationError::InfringingFields(fields)) => {
112-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
112+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
113113
Err(infringing_fields_error(
114114
tcx,
115115
fields.into_iter().map(|(field, ty, reason)| (tcx.def_span(field.did), ty, reason)),
@@ -119,15 +119,15 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
119119
))
120120
}
121121
Err(CopyImplementationError::NotAnAdt) => {
122-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
122+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
123123
Err(tcx.dcx().emit_err(errors::CopyImplOnNonAdt { span }))
124124
}
125125
Err(CopyImplementationError::HasDestructor) => {
126-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
126+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
127127
Err(tcx.dcx().emit_err(errors::CopyImplOnTypeWithDtor { span }))
128128
}
129129
Err(CopyImplementationError::HasUnsafeFields) => {
130-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
130+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
131131
Err(tcx
132132
.dcx()
133133
.span_delayed_bug(span, format!("cannot implement `Copy` for `{}`", self_type)))
@@ -157,7 +157,7 @@ fn visit_implementation_of_const_param_ty(
157157
match type_allowed_to_implement_const_param_ty(tcx, param_env, self_type, kind, cause) {
158158
Ok(()) => Ok(()),
159159
Err(ConstParamTyImplementationError::InfrigingFields(fields)) => {
160-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
160+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
161161
Err(infringing_fields_error(
162162
tcx,
163163
fields.into_iter().map(|(field, ty, reason)| (tcx.def_span(field.did), ty, reason)),
@@ -167,11 +167,11 @@ fn visit_implementation_of_const_param_ty(
167167
))
168168
}
169169
Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed) => {
170-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
170+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
171171
Err(tcx.dcx().emit_err(errors::ConstParamTyImplOnNonAdt { span }))
172172
}
173173
Err(ConstParamTyImplementationError::InvalidInnerTyOfBuiltinTy(infringing_tys)) => {
174-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
174+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
175175
Err(infringing_fields_error(
176176
tcx,
177177
infringing_tys.into_iter().map(|(ty, reason)| (span, ty, reason)),
@@ -181,7 +181,7 @@ fn visit_implementation_of_const_param_ty(
181181
))
182182
}
183183
Err(ConstParamTyImplementationError::UnsizedConstParamsFeatureRequired) => {
184-
let span = tcx.hir().expect_item(impl_did).expect_impl().self_ty.span;
184+
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
185185
Err(tcx.dcx().emit_err(errors::ConstParamTyImplOnUnsized { span }))
186186
}
187187
}
@@ -526,7 +526,7 @@ pub(crate) fn coerce_unsized_info<'tcx>(
526526
note: true,
527527
}));
528528
} else if diff_fields.len() > 1 {
529-
let item = tcx.hir().expect_item(impl_did);
529+
let item = tcx.hir_expect_item(impl_did);
530530
let span = if let ItemKind::Impl(hir::Impl { of_trait: Some(t), .. }) = &item.kind {
531531
t.path.span
532532
} else {

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn emit_orphan_check_error<'tcx>(
376376
) -> ErrorGuaranteed {
377377
match err {
378378
traits::OrphanCheckErr::NonLocalInputType(tys) => {
379-
let item = tcx.hir().expect_item(impl_def_id);
379+
let item = tcx.hir_expect_item(impl_def_id);
380380
let impl_ = item.expect_impl();
381381
let hir_trait_ref = impl_.of_trait.as_ref().unwrap();
382382

compiler/rustc_hir_analysis/src/collect.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
469469
hir::Node::Field(_) | hir::Node::Ctor(_) | hir::Node::Variant(_) => {
470470
let item = self
471471
.tcx
472-
.hir()
473-
.expect_item(self.tcx.hir_get_parent_item(self.hir_id()).def_id);
472+
.hir_expect_item(self.tcx.hir_get_parent_item(self.hir_id()).def_id);
474473
match &item.kind {
475474
hir::ItemKind::Enum(_, generics)
476475
| hir::ItemKind::Struct(_, generics)
@@ -1143,7 +1142,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
11431142
}
11441143

11451144
fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
1146-
let item = tcx.hir().expect_item(def_id);
1145+
let item = tcx.hir_expect_item(def_id);
11471146

11481147
let (is_alias, is_auto, safety, items) = match item.kind {
11491148
hir::ItemKind::Trait(is_auto, safety, .., items) => {
@@ -1342,7 +1341,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFn
13421341
),
13431342

13441343
ForeignItem(&hir::ForeignItem { kind: ForeignItemKind::Fn(sig, _, _), .. }) => {
1345-
let abi = tcx.hir().get_foreign_abi(hir_id);
1344+
let abi = tcx.hir_get_foreign_abi(hir_id);
13461345
compute_sig_of_foreign_fn_decl(tcx, def_id, sig.decl, abi, sig.header.safety())
13471346
}
13481347

@@ -1597,7 +1596,7 @@ pub fn suggest_impl_trait<'tcx>(
15971596

15981597
fn impl_trait_header(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::ImplTraitHeader<'_>> {
15991598
let icx = ItemCtxt::new(tcx, def_id);
1600-
let item = tcx.hir().expect_item(def_id);
1599+
let item = tcx.hir_expect_item(def_id);
16011600
let impl_ = item.expect_impl();
16021601
impl_.of_trait.as_ref().map(|ast_trait_ref| {
16031602
let selfty = tcx.type_of(def_id).instantiate_identity();

0 commit comments

Comments
 (0)