diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-11 13:21:08 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-11 13:21:08 +0100 |
commit | 05399250d47cdceffbf1ded08983b13a9dcc87c1 (patch) | |
tree | c3165d3c3236893c23deb881a792c2c34be2e2bf /crates/ra_ide_db | |
parent | eb892d707c379eff514df9c2a6b2203f38874b14 (diff) | |
parent | 3d66aa054230ad788162ce49f0d334e900458cac (diff) |
Merge #4421
4421: Find references to a function outside module r=flodiebold a=montekki
Fixes #4188
Yet again, it looks like although the code in
https://github.com/rust-analyzer/rust-analyzer/blob/da1f316b0246ce41d7cb8560181e294089f06ef3/crates/ra_ide_db/src/search.rs#L128-L132
may be wrong, it is not hit since the `vis` is `None` at this point. The fix is similar to the #4237 case: just add another special case to `Definition::visibility()`.
Co-authored-by: Fedor Sakharov <[email protected]>
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index f990e3bb9..60c11178e 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -6,7 +6,7 @@ | |||
6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). | 6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). |
7 | 7 | ||
8 | use hir::{ | 8 | use hir::{ |
9 | Adt, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, | 9 | Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, |
10 | Semantics, TypeParam, Visibility, | 10 | Semantics, TypeParam, Visibility, |
11 | }; | 11 | }; |
12 | use ra_prof::profile; | 12 | use ra_prof::profile; |
@@ -42,18 +42,10 @@ impl Definition { | |||
42 | } | 42 | } |
43 | 43 | ||
44 | pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> { | 44 | pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> { |
45 | let module = self.module(db); | ||
46 | |||
47 | match self { | 45 | match self { |
48 | Definition::Macro(_) => None, | 46 | Definition::Macro(_) => None, |
49 | Definition::Field(sf) => Some(sf.visibility(db)), | 47 | Definition::Field(sf) => Some(sf.visibility(db)), |
50 | Definition::ModuleDef(def) => match def { | 48 | Definition::ModuleDef(def) => def.definition_visibility(db), |
51 | ModuleDef::EnumVariant(id) => { | ||
52 | let parent = id.parent_enum(db); | ||
53 | module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent))) | ||
54 | } | ||
55 | _ => module?.visibility_of(db, def), | ||
56 | }, | ||
57 | Definition::SelfType(_) => None, | 49 | Definition::SelfType(_) => None, |
58 | Definition::Local(_) => None, | 50 | Definition::Local(_) => None, |
59 | Definition::TypeParam(_) => None, | 51 | Definition::TypeParam(_) => None, |