diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-03 09:32:11 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-13 13:50:00 +0000 |
| commit | 5bd3841668f43626b89c9295de960cc7e2a3c2aa (patch) | |
| tree | 2bf18d93915fec9a004fe323e4fed58fe7bc1817 /compiler/rustc_hir_analysis/src | |
| parent | 36bc0948e0a67f5aeb2a1d997acf4cd94d948fa9 (diff) | |
| download | rust-5bd3841668f43626b89c9295de960cc7e2a3c2aa.tar.gz rust-5bd3841668f43626b89c9295de960cc7e2a3c2aa.zip | |
Retire hir::ForeignItemRef.
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index f4bbf03f0c2..70fbb8a543e 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -930,8 +930,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), check_abi(tcx, it.hir_id(), it.span, abi); - for item in items { - let def_id = item.id.owner_id.def_id; + for &item in items { + let def_id = item.owner_id.def_id; let generics = tcx.generics_of(def_id); let own_counts = generics.own_counts(); @@ -943,13 +943,14 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), (0, _) => ("const", "consts", None), _ => ("type or const", "types or consts", None), }; + let span = tcx.def_span(def_id); struct_span_code_err!( tcx.dcx(), - item.span, + span, E0044, "foreign items may not have {kinds} parameters", ) - .with_span_label(item.span, format!("can't have {kinds} parameters")) + .with_span_label(span, format!("can't have {kinds} parameters")) .with_help( // FIXME: once we start storing spans for type arguments, turn this // into a suggestion. @@ -963,22 +964,23 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), .emit(); } - let item = tcx.hir_foreign_item(item.id); - tcx.ensure_ok().generics_of(item.owner_id); - tcx.ensure_ok().type_of(item.owner_id); - tcx.ensure_ok().predicates_of(item.owner_id); + tcx.ensure_ok().generics_of(def_id); + tcx.ensure_ok().type_of(def_id); + tcx.ensure_ok().predicates_of(def_id); if tcx.is_conditionally_const(def_id) { tcx.ensure_ok().explicit_implied_const_bounds(def_id); tcx.ensure_ok().const_conditions(def_id); } - match item.kind { - hir::ForeignItemKind::Fn(sig, ..) => { - tcx.ensure_ok().codegen_fn_attrs(item.owner_id); - tcx.ensure_ok().fn_sig(item.owner_id); + match tcx.def_kind(def_id) { + DefKind::Fn => { + tcx.ensure_ok().codegen_fn_attrs(def_id); + tcx.ensure_ok().fn_sig(def_id); + let item = tcx.hir_foreign_item(item); + let hir::ForeignItemKind::Fn(sig, ..) = item.kind else { bug!() }; require_c_abi_if_c_variadic(tcx, sig.decl, abi, item.span); } - hir::ForeignItemKind::Static(..) => { - tcx.ensure_ok().codegen_fn_attrs(item.owner_id); + DefKind::Static { .. } => { + tcx.ensure_ok().codegen_fn_attrs(def_id); } _ => (), } |
