Skip to content

Commit e921195

Browse files
committed
Change favor_types to has_constructor
1 parent 5ae18f4 commit e921195

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

crates/ra_hir_def/src/body/lower.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,15 @@ impl ExprCollector<'_> {
575575
self.body.item_scope.define_def(def);
576576
if let Some(name) = name {
577577
let vis = crate::visibility::Visibility::Public; // FIXME determine correctly
578-
let favor_types = match def {
578+
let has_constructor = match def {
579579
ModuleDefId::AdtId(AdtId::StructId(s)) => {
580-
self.db.struct_data(s).variant_data.kind() == StructKind::Record
580+
self.db.struct_data(s).variant_data.kind() != StructKind::Record
581581
}
582-
_ => false,
582+
_ => true,
583583
};
584584
self.body.item_scope.push_res(
585585
name.as_name(),
586-
crate::per_ns::PerNs::from_def(def, vis, favor_types),
586+
crate::per_ns::PerNs::from_def(def, vis, has_constructor),
587587
);
588588
}
589589
}

crates/ra_hir_def/src/item_scope.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,15 @@ impl ItemScope {
151151
}
152152

153153
impl PerNs {
154-
pub(crate) fn from_def(def: ModuleDefId, v: Visibility, favor_types: bool) -> PerNs {
154+
pub(crate) fn from_def(def: ModuleDefId, v: Visibility, has_constructor: bool) -> PerNs {
155155
match def {
156156
ModuleDefId::ModuleId(_) => PerNs::types(def, v),
157157
ModuleDefId::FunctionId(_) => PerNs::values(def, v),
158158
ModuleDefId::AdtId(adt) => match adt {
159159
AdtId::UnionId(_) => PerNs::both(def, def, v),
160160
AdtId::EnumId(_) => PerNs::types(def, v),
161161
AdtId::StructId(_) => {
162-
if favor_types {
162+
if !has_constructor {
163163
PerNs::types(def, v)
164164
} else {
165165
PerNs::both(def, def, v)

crates/ra_hir_def/src/nameres/collector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ impl ModCollector<'_, '_> {
844844
let name = def.name.clone();
845845
let container = ContainerId::ModuleId(module);
846846
let vis = &def.visibility;
847-
let mut favor_types = false;
847+
let mut has_constructor = false;
848848

849849
let def: ModuleDefId = match def.kind {
850850
raw::DefKind::Function(ast_id) => FunctionLoc {
@@ -854,7 +854,7 @@ impl ModCollector<'_, '_> {
854854
.intern(self.def_collector.db)
855855
.into(),
856856
raw::DefKind::Struct(ast_id, mode) => {
857-
favor_types = mode == raw::StructDefKind::Record;
857+
has_constructor = mode != raw::StructDefKind::Record;
858858
StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) }
859859
.intern(self.def_collector.db)
860860
.into()
@@ -899,7 +899,7 @@ impl ModCollector<'_, '_> {
899899
.unwrap_or(Visibility::Public);
900900
self.def_collector.update(
901901
self.module_id,
902-
&[(name, PerNs::from_def(def, vis, favor_types))],
902+
&[(name, PerNs::from_def(def, vis, has_constructor))],
903903
vis,
904904
)
905905
}

0 commit comments

Comments
 (0)