diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-09-16 11:45:33 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-09-29 08:44:52 +1000 |
| commit | f07d4efc4555c4154fb408b2d230fb72ad53b8be (patch) | |
| tree | 2aadca19dd99db6660b00c1ed969b5904d069b81 /compiler/rustc_save_analysis/src | |
| parent | 5f29a13a5b985229fce5fbb75f9af838734ad264 (diff) | |
| download | rust-f07d4efc4555c4154fb408b2d230fb72ad53b8be.tar.gz rust-f07d4efc4555c4154fb408b2d230fb72ad53b8be.zip | |
Shrink `hir::def::Res`.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some` the first one is never consulted. So we can split it into two variants, `Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res` from 24 bytes to 12. This then shrinks `hir::Path` and `hir::PathSegment`, which are the HIR types that take up the most space.
Diffstat (limited to 'compiler/rustc_save_analysis/src')
| -rw-r--r-- | compiler/rustc_save_analysis/src/dump_visitor.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_save_analysis/src/lib.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_save_analysis/src/sig.rs | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs index adbc119387d..ecb09f0c4b7 100644 --- a/compiler/rustc_save_analysis/src/dump_visitor.rs +++ b/compiler/rustc_save_analysis/src/dump_visitor.rs @@ -913,7 +913,8 @@ impl<'tcx> DumpVisitor<'tcx> { | HirDefKind::AssocTy, _, ) - | Res::SelfTy { .. } => { + | Res::SelfTyParam { .. } + | Res::SelfTyAlias { .. } => { self.dump_path_segment_ref( id, &hir::PathSegment::new(ident, hir::HirId::INVALID, Res::Err), diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index ad7aca3cb94..aa000b7067b 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -740,7 +740,8 @@ impl<'tcx> SaveContext<'tcx> { _, ) | Res::PrimTy(..) - | Res::SelfTy { .. } + | Res::SelfTyParam { .. } + | Res::SelfTyAlias { .. } | Res::ToolMod | Res::NonMacroAttr(..) | Res::SelfCtor(..) @@ -805,7 +806,7 @@ impl<'tcx> SaveContext<'tcx> { fn lookup_def_id(&self, ref_id: hir::HirId) -> Option<DefId> { match self.get_path_res(ref_id) { - Res::PrimTy(_) | Res::SelfTy { .. } | Res::Err => None, + Res::PrimTy(_) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } | Res::Err => None, def => def.opt_def_id(), } } diff --git a/compiler/rustc_save_analysis/src/sig.rs b/compiler/rustc_save_analysis/src/sig.rs index bae1828cd18..62e9f6520fb 100644 --- a/compiler/rustc_save_analysis/src/sig.rs +++ b/compiler/rustc_save_analysis/src/sig.rs @@ -579,7 +579,7 @@ impl<'hir> Sig for hir::Path<'hir> { let res = scx.get_path_res(id.ok_or("Missing id for Path")?); let (name, start, end) = match res { - Res::PrimTy(..) | Res::SelfTy { .. } | Res::Err => { + Res::PrimTy(..) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } | Res::Err => { return Ok(Signature { text: path_to_string(self), defs: vec![], refs: vec![] }); } Res::Def(DefKind::AssocConst | DefKind::Variant | DefKind::Ctor(..), _) => { |
