aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-08-09 23:52:19 +0100
committerPaul Daniel Faria <[email protected]>2020-08-09 23:52:19 +0100
commitbf9b4578bbe038501ef7c337e22b448de477f61c (patch)
treedc307ec47e6bfff850ddc5e0079e14f2512c87a9 /crates/ra_ide_db
parent6cde0b1aa0f6b8623c6b81b2396f4a0345891233 (diff)
Remove Option<...> from result of Crate::root_module
There doesn't seem to be any need for it, and removing it simplies several paths of code that depend on it.
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r--crates/ra_ide_db/src/defs.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index e2a4f2983..9bb95277d 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -93,19 +93,19 @@ pub enum NameClass {
93impl NameClass { 93impl NameClass {
94 pub fn into_definition(self, db: &dyn HirDatabase) -> Option<Definition> { 94 pub fn into_definition(self, db: &dyn HirDatabase) -> Option<Definition> {
95 Some(match self { 95 Some(match self {
96 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db)?.into()), 96 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
97 NameClass::Definition(it) => it, 97 NameClass::Definition(it) => it,
98 NameClass::ConstReference(_) => return None, 98 NameClass::ConstReference(_) => return None,
99 NameClass::FieldShorthand { local, field: _ } => Definition::Local(local), 99 NameClass::FieldShorthand { local, field: _ } => Definition::Local(local),
100 }) 100 })
101 } 101 }
102 102
103 pub fn definition(self, db: &dyn HirDatabase) -> Option<Definition> { 103 pub fn definition(self, db: &dyn HirDatabase) -> Definition {
104 Some(match self { 104 match self {
105 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db)?.into()), 105 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
106 NameClass::Definition(it) | NameClass::ConstReference(it) => it, 106 NameClass::Definition(it) | NameClass::ConstReference(it) => it,
107 NameClass::FieldShorthand { local: _, field } => field, 107 NameClass::FieldShorthand { local: _, field } => field,
108 }) 108 }
109 } 109 }
110} 110}
111 111
@@ -148,7 +148,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
148 }) 148 })
149 .and_then(|name_ref| classify_name_ref(sema, &name_ref))?; 149 .and_then(|name_ref| classify_name_ref(sema, &name_ref))?;
150 150
151 Some(NameClass::Definition(name_ref_class.definition(sema.db)?)) 151 Some(NameClass::Definition(name_ref_class.definition(sema.db)))
152 } else { 152 } else {
153 let extern_crate = it.syntax().parent().and_then(ast::ExternCrate::cast)?; 153 let extern_crate = it.syntax().parent().and_then(ast::ExternCrate::cast)?;
154 let resolved = sema.resolve_extern_crate(&extern_crate)?; 154 let resolved = sema.resolve_extern_crate(&extern_crate)?;
@@ -234,14 +234,12 @@ pub enum NameRefClass {
234} 234}
235 235
236impl NameRefClass { 236impl NameRefClass {
237 pub fn definition(self, db: &dyn HirDatabase) -> Option<Definition> { 237 pub fn definition(self, db: &dyn HirDatabase) -> Definition {
238 Some(match self { 238 match self {
239 NameRefClass::ExternCrate(krate) => { 239 NameRefClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
240 Definition::ModuleDef(krate.root_module(db)?.into())
241 }
242 NameRefClass::Definition(def) => def, 240 NameRefClass::Definition(def) => def,
243 NameRefClass::FieldShorthand { local, field: _ } => Definition::Local(local), 241 NameRefClass::FieldShorthand { local, field: _ } => Definition::Local(local),
244 }) 242 }
245 } 243 }
246} 244}
247 245