rust/compiler/rustc_hir_analysis/src
Matthias Krüger e1acc68c9d
Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease
Move `hir::Item::ident` into `hir::ItemKind`.

 `hir::Item` has an `ident` field.

- It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, Trait`, TraitAalis`.

- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`, `Impl`.

- For `Use`, it is non-empty for `UseKind::Single` and empty for `UseKind::{Glob,ListStem}`.

All of this is quite non-obvious; the only documentation is a single comment saying "The name might be a dummy name in case of anonymous items". Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out.

This is step towards `kw::Empty` elimination (#137978).

r? `@fmease`
2025-03-17 22:49:04 +01:00
..
check Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease 2025-03-17 22:49:04 +01:00
coherence Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
collect Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
errors Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
hir_ty_lowering Rollup merge of #138384 - nnethercote:hir-ItemKind-idents, r=fmease 2025-03-17 22:49:04 +01:00
impl_wf_check Fix a comment typo. 2025-01-31 08:28:14 +11:00
outlives Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
variance Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
autoderef.rs Rename structurally_normalize to structurally_normalize_ty 2025-01-22 07:04:53 +00:00
check_unused.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
collect.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
constrained_generic_params.rs Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
delegation.rs Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
errors.rs Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
hir_wf_check.rs Move hir::Item::ident into hir::ItemKind. 2025-03-18 06:29:50 +11:00
impl_wf_check.rs Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
lib.rs Add RTN support to rustdoc 2025-03-15 18:13:27 +00:00