diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-11 14:32:00 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-11 19:08:14 +1000 |
| commit | 9eca59a94021089905c482011a2d88ee9b862a73 (patch) | |
| tree | e8b788e412fb4fb8575ce9824ffd76da37772e73 /compiler/rustc_hir/src/def.rs | |
| parent | fad2535e4b49f95becb8f2e3166795cbf408ec73 (diff) | |
| download | rust-9eca59a94021089905c482011a2d88ee9b862a73.tar.gz rust-9eca59a94021089905c482011a2d88ee9b862a73.zip | |
Introduce `DefPathData::AnonAssocTy`.
PR #137977 changed `DefPathData::TypeNs` to contain `Option<Symbol>` to account for RPITIT assoc types being anonymous. This commit changes it back to `Symbol` and gives anonymous assoc types their own variant. It makes things a bit nicer overall.
Diffstat (limited to 'compiler/rustc_hir/src/def.rs')
| -rw-r--r-- | compiler/rustc_hir/src/def.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index dc00b52a593..9372ab532bf 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -267,11 +267,16 @@ impl DefKind { | DefKind::ForeignTy | DefKind::TraitAlias | DefKind::TyParam - | DefKind::ExternCrate => DefPathData::TypeNs(Some(name.unwrap())), - - // An associated type names will be missing for an RPITIT. It will - // later be given a name with `synthetic` in it, if necessary. - DefKind::AssocTy => DefPathData::TypeNs(name), + | DefKind::ExternCrate => DefPathData::TypeNs(name.unwrap()), + + // An associated type name will be missing for an RPITIT. + DefKind::AssocTy => { + if let Some(name) = name { + DefPathData::TypeNs(name) + } else { + DefPathData::AnonAssocTy + } + } // It's not exactly an anon const, but wrt DefPathData, there // is no difference. |
