Skip to content

Commit 99a1b8f

Browse files
committed
Auto merge of rust-lang#16747 - Veykril:cleanup, r=Veykril
internal: Clean some stuff up Just a bunch of small refactorings, mainly from browsing through `hir-def`
2 parents 2074cc2 + 4303e74 commit 99a1b8f

File tree

42 files changed

+421
-456
lines changed

Some content is hidden

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

42 files changed

+421
-456
lines changed

Cargo.lock

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/base-db/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ tracing.workspace = true
2121

2222
# local deps
2323
cfg.workspace = true
24-
profile.workspace = true
2524
stdx.workspace = true
2625
syntax.workspace = true
2726
vfs.workspace = true

crates/hir-def/src/body.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use cfg::{CfgExpr, CfgOptions};
1313
use either::Either;
1414
use hir_expand::{name::Name, HirFileId, InFile};
1515
use la_arena::{Arena, ArenaMap};
16-
use profile::Count;
1716
use rustc_hash::FxHashMap;
1817
use syntax::{ast, AstPtr, SyntaxNodePtr};
1918
use triomphe::Arc;
@@ -51,7 +50,6 @@ pub struct Body {
5150
pub body_expr: ExprId,
5251
/// Block expressions in this body that may contain inner items.
5352
block_scopes: Vec<BlockId>,
54-
_c: Count<Self>,
5553
}
5654

5755
pub type ExprPtr = AstPtr<ast::Expr>;
@@ -216,7 +214,6 @@ impl Body {
216214

217215
fn shrink_to_fit(&mut self) {
218216
let Self {
219-
_c: _,
220217
body_expr: _,
221218
block_scopes,
222219
exprs,
@@ -300,7 +297,6 @@ impl Default for Body {
300297
params: Default::default(),
301298
block_scopes: Default::default(),
302299
binding_owners: Default::default(),
303-
_c: Default::default(),
304300
}
305301
}
306302
}

crates/hir-def/src/body/lower.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use hir_expand::{
1010
ExpandError, InFile,
1111
};
1212
use intern::Interned;
13-
use profile::Count;
1413
use rustc_hash::FxHashMap;
1514
use smallvec::SmallVec;
1615
use span::AstIdMap;
@@ -76,7 +75,6 @@ pub(super) fn lower(
7675
params: Vec::new(),
7776
body_expr: dummy_expr_id(),
7877
block_scopes: Vec::new(),
79-
_c: Count::new(),
8078
},
8179
expander,
8280
current_try_block_label: None,

crates/hir-def/src/item_tree.rs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use either::Either;
5050
use hir_expand::{attrs::RawAttrs, name::Name, ExpandTo, HirFileId, InFile};
5151
use intern::Interned;
5252
use la_arena::{Arena, Idx, IdxRange, RawIdx};
53-
use profile::Count;
5453
use rustc_hash::FxHashMap;
5554
use smallvec::SmallVec;
5655
use span::{AstIdNode, FileAstId, Span};
@@ -94,8 +93,6 @@ impl fmt::Debug for RawVisibilityId {
9493
/// The item tree of a source file.
9594
#[derive(Debug, Default, Eq, PartialEq)]
9695
pub struct ItemTree {
97-
_c: Count<Self>,
98-
9996
top_level: SmallVec<[ModItem; 1]>,
10097
attrs: FxHashMap<AttrOwner, RawAttrs>,
10198

@@ -263,14 +260,6 @@ impl ItemVisibilities {
263260
}
264261
}
265262

266-
static VIS_PUB: RawVisibility = RawVisibility::Public;
267-
static VIS_PRIV_IMPLICIT: RawVisibility =
268-
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Implicit);
269-
static VIS_PRIV_EXPLICIT: RawVisibility =
270-
RawVisibility::Module(ModPath::from_kind(PathKind::Super(0)), VisibilityExplicitness::Explicit);
271-
static VIS_PUB_CRATE: RawVisibility =
272-
RawVisibility::Module(ModPath::from_kind(PathKind::Crate), VisibilityExplicitness::Explicit);
273-
274263
#[derive(Default, Debug, Eq, PartialEq)]
275264
struct ItemTreeData {
276265
uses: Arena<Use>,
@@ -562,6 +551,20 @@ impl_index!(fields: Field, variants: Variant, params: Param);
562551
impl Index<RawVisibilityId> for ItemTree {
563552
type Output = RawVisibility;
564553
fn index(&self, index: RawVisibilityId) -> &Self::Output {
554+
static VIS_PUB: RawVisibility = RawVisibility::Public;
555+
static VIS_PRIV_IMPLICIT: RawVisibility = RawVisibility::Module(
556+
ModPath::from_kind(PathKind::Super(0)),
557+
VisibilityExplicitness::Implicit,
558+
);
559+
static VIS_PRIV_EXPLICIT: RawVisibility = RawVisibility::Module(
560+
ModPath::from_kind(PathKind::Super(0)),
561+
VisibilityExplicitness::Explicit,
562+
);
563+
static VIS_PUB_CRATE: RawVisibility = RawVisibility::Module(
564+
ModPath::from_kind(PathKind::Crate),
565+
VisibilityExplicitness::Explicit,
566+
);
567+
565568
match index {
566569
RawVisibilityId::PRIV_IMPLICIT => &VIS_PRIV_IMPLICIT,
567570
RawVisibilityId::PRIV_EXPLICIT => &VIS_PRIV_EXPLICIT,
@@ -871,25 +874,19 @@ impl UseTree {
871874
prefix: Option<ModPath>,
872875
path: &ModPath,
873876
) -> Option<(ModPath, ImportKind)> {
874-
match (prefix, &path.kind) {
877+
match (prefix, path.kind) {
875878
(None, _) => Some((path.clone(), ImportKind::Plain)),
876879
(Some(mut prefix), PathKind::Plain) => {
877-
for segment in path.segments() {
878-
prefix.push_segment(segment.clone());
879-
}
880+
prefix.extend(path.segments().iter().cloned());
880881
Some((prefix, ImportKind::Plain))
881882
}
882-
(Some(mut prefix), PathKind::Super(n))
883-
if *n > 0 && prefix.segments().is_empty() =>
884-
{
883+
(Some(mut prefix), PathKind::Super(n)) if n > 0 && prefix.segments().is_empty() => {
885884
// `super::super` + `super::rest`
886885
match &mut prefix.kind {
887886
PathKind::Super(m) => {
888887
cov_mark::hit!(concat_super_mod_paths);
889-
*m += *n;
890-
for segment in path.segments() {
891-
prefix.push_segment(segment.clone());
892-
}
888+
*m += n;
889+
prefix.extend(path.segments().iter().cloned());
893890
Some((prefix, ImportKind::Plain))
894891
}
895892
_ => None,
@@ -963,10 +960,10 @@ impl ModItem {
963960
| ModItem::Mod(_)
964961
| ModItem::MacroRules(_)
965962
| ModItem::Macro2(_) => None,
966-
ModItem::MacroCall(call) => Some(AssocItem::MacroCall(*call)),
967-
ModItem::Const(konst) => Some(AssocItem::Const(*konst)),
968-
ModItem::TypeAlias(alias) => Some(AssocItem::TypeAlias(*alias)),
969-
ModItem::Function(func) => Some(AssocItem::Function(*func)),
963+
&ModItem::MacroCall(call) => Some(AssocItem::MacroCall(call)),
964+
&ModItem::Const(konst) => Some(AssocItem::Const(konst)),
965+
&ModItem::TypeAlias(alias) => Some(AssocItem::TypeAlias(alias)),
966+
&ModItem::Function(func) => Some(AssocItem::Function(func)),
970967
}
971968
}
972969

0 commit comments

Comments
 (0)