Skip to content

Commit 107e074

Browse files
committed
internal: remove erroneous Default impl for ModuleOrigin
In rust-analyzer, we avoid defualt impls for types which don't have sensible, "empty" defaults. In particular, we avoid using invalid indices for defaults and similar hacks.
1 parent 745be39 commit 107e074

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

crates/hir_def/src/nameres.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ pub enum ModuleOrigin {
145145
},
146146
}
147147

148-
impl Default for ModuleOrigin {
149-
fn default() -> Self {
150-
ModuleOrigin::CrateRoot { definition: FileId(0) }
151-
}
152-
}
153-
154148
impl ModuleOrigin {
155149
fn declaration(&self) -> Option<AstId<ast::Module>> {
156150
match self {
@@ -196,7 +190,7 @@ impl ModuleOrigin {
196190
}
197191
}
198192

199-
#[derive(Default, Debug, PartialEq, Eq)]
193+
#[derive(Debug, PartialEq, Eq)]
200194
pub struct ModuleData {
201195
pub parent: Option<LocalModuleId>,
202196
pub children: FxHashMap<Name, LocalModuleId>,
@@ -206,6 +200,17 @@ pub struct ModuleData {
206200
pub origin: ModuleOrigin,
207201
}
208202

203+
impl Default for ModuleData {
204+
fn default() -> Self {
205+
ModuleData {
206+
parent: None,
207+
children: FxHashMap::default(),
208+
scope: ItemScope::default(),
209+
origin: ModuleOrigin::CrateRoot { definition: FileId(!0) },
210+
}
211+
}
212+
}
213+
209214
impl DefMap {
210215
pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<DefMap> {
211216
let _p = profile::span("crate_def_map_query").detail(|| {

0 commit comments

Comments
 (0)