diff options
-rw-r--r-- | crates/ra_hir_def/src/item_scope.rs | 31 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 47 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli/analysis_stats.rs | 2 | ||||
-rw-r--r-- | crates/vfs/src/vfs_path.rs | 19 | ||||
-rw-r--r-- | editors/code/rollup.config.js | 7 |
5 files changed, 86 insertions, 20 deletions
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index b03ba939a..c81b966c3 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs | |||
@@ -5,6 +5,7 @@ use hir_expand::name::Name; | |||
5 | use once_cell::sync::Lazy; | 5 | use once_cell::sync::Lazy; |
6 | use ra_db::CrateId; | 6 | use ra_db::CrateId; |
7 | use rustc_hash::FxHashMap; | 7 | use rustc_hash::FxHashMap; |
8 | use test_utils::mark; | ||
8 | 9 | ||
9 | use crate::{ | 10 | use crate::{ |
10 | db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, HasModule, ImplId, | 11 | db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, HasModule, ImplId, |
@@ -126,19 +127,27 @@ impl ItemScope { | |||
126 | let mut changed = false; | 127 | let mut changed = false; |
127 | let existing = self.visible.entry(name).or_default(); | 128 | let existing = self.visible.entry(name).or_default(); |
128 | 129 | ||
129 | if existing.types.is_none() && def.types.is_some() { | 130 | macro_rules! check_changed { |
130 | existing.types = def.types; | 131 | ($changed:ident, $existing:expr, $def:expr) => { |
131 | changed = true; | 132 | match ($existing, $def) { |
132 | } | 133 | (None, Some(_)) => { |
133 | if existing.values.is_none() && def.values.is_some() { | 134 | $existing = $def; |
134 | existing.values = def.values; | 135 | $changed = true; |
135 | changed = true; | 136 | } |
136 | } | 137 | (Some(e), Some(d)) if e.0 != d.0 => { |
137 | if existing.macros.is_none() && def.macros.is_some() { | 138 | mark::hit!(import_shadowed); |
138 | existing.macros = def.macros; | 139 | $existing = $def; |
139 | changed = true; | 140 | $changed = true; |
141 | } | ||
142 | _ => {} | ||
143 | } | ||
144 | }; | ||
140 | } | 145 | } |
141 | 146 | ||
147 | check_changed!(changed, existing.types, def.types); | ||
148 | check_changed!(changed, existing.values, def.values); | ||
149 | check_changed!(changed, existing.macros, def.macros); | ||
150 | |||
142 | changed | 151 | changed |
143 | } | 152 | } |
144 | 153 | ||
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs index 2b12c0daa..2f440975a 100644 --- a/crates/ra_hir_def/src/nameres/tests/globs.rs +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -229,3 +229,50 @@ fn glob_enum_group() { | |||
229 | "### | 229 | "### |
230 | ); | 230 | ); |
231 | } | 231 | } |
232 | |||
233 | #[test] | ||
234 | fn glob_shadowed_def() { | ||
235 | mark::check!(import_shadowed); | ||
236 | let map = def_map( | ||
237 | r###" | ||
238 | //- /lib.rs | ||
239 | mod foo; | ||
240 | mod bar; | ||
241 | |||
242 | use foo::*; | ||
243 | use bar::baz; | ||
244 | |||
245 | use baz::Bar; | ||
246 | |||
247 | //- /foo.rs | ||
248 | pub mod baz { | ||
249 | pub struct Foo; | ||
250 | } | ||
251 | |||
252 | //- /bar.rs | ||
253 | pub mod baz { | ||
254 | pub struct Bar; | ||
255 | } | ||
256 | "###, | ||
257 | ); | ||
258 | assert_snapshot!(map, @r###" | ||
259 | ⋮crate | ||
260 | ⋮Bar: t v | ||
261 | ⋮bar: t | ||
262 | ⋮baz: t | ||
263 | ⋮foo: t | ||
264 | ⋮ | ||
265 | ⋮crate::bar | ||
266 | ⋮baz: t | ||
267 | ⋮ | ||
268 | ⋮crate::bar::baz | ||
269 | ⋮Bar: t v | ||
270 | ⋮ | ||
271 | ⋮crate::foo | ||
272 | ⋮baz: t | ||
273 | ⋮ | ||
274 | ⋮crate::foo::baz | ||
275 | ⋮Foo: t v | ||
276 | "### | ||
277 | ); | ||
278 | } | ||
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 90868760b..2f4c29e06 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs | |||
@@ -121,7 +121,7 @@ pub fn analysis_stats( | |||
121 | let original_file = src.file_id.original_file(db); | 121 | let original_file = src.file_id.original_file(db); |
122 | let path = vfs.file_path(original_file); | 122 | let path = vfs.file_path(original_file); |
123 | let syntax_range = src.value.syntax().text_range(); | 123 | let syntax_range = src.value.syntax().text_range(); |
124 | format_to!(msg, " ({:?} {:?})", path, syntax_range); | 124 | format_to!(msg, " ({} {:?})", path, syntax_range); |
125 | } | 125 | } |
126 | if verbosity.is_spammy() { | 126 | if verbosity.is_spammy() { |
127 | bar.println(msg.to_string()); | 127 | bar.println(msg.to_string()); |
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs index 0a8a86c62..940f91d0e 100644 --- a/crates/vfs/src/vfs_path.rs +++ b/crates/vfs/src/vfs_path.rs | |||
@@ -5,7 +5,7 @@ use paths::{AbsPath, AbsPathBuf}; | |||
5 | 5 | ||
6 | /// Long-term, we want to support files which do not reside in the file-system, | 6 | /// Long-term, we want to support files which do not reside in the file-system, |
7 | /// so we treat VfsPaths as opaque identifiers. | 7 | /// so we treat VfsPaths as opaque identifiers. |
8 | #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] | 8 | #[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] |
9 | pub struct VfsPath(VfsPathRepr); | 9 | pub struct VfsPath(VfsPathRepr); |
10 | 10 | ||
11 | impl VfsPath { | 11 | impl VfsPath { |
@@ -50,7 +50,7 @@ impl VfsPath { | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] | 53 | #[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] |
54 | enum VfsPathRepr { | 54 | enum VfsPathRepr { |
55 | PathBuf(AbsPathBuf), | 55 | PathBuf(AbsPathBuf), |
56 | VirtualPath(VirtualPath), | 56 | VirtualPath(VirtualPath), |
@@ -71,6 +71,21 @@ impl fmt::Display for VfsPath { | |||
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | impl fmt::Debug for VfsPath { | ||
75 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
76 | fmt::Debug::fmt(&self.0, f) | ||
77 | } | ||
78 | } | ||
79 | |||
80 | impl fmt::Debug for VfsPathRepr { | ||
81 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
82 | match &self { | ||
83 | VfsPathRepr::PathBuf(it) => fmt::Debug::fmt(&it.display(), f), | ||
84 | VfsPathRepr::VirtualPath(VirtualPath(it)) => fmt::Debug::fmt(&it, f), | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
74 | #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] | 89 | #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] |
75 | struct VirtualPath(String); | 90 | struct VirtualPath(String); |
76 | 91 | ||
diff --git a/editors/code/rollup.config.js b/editors/code/rollup.config.js index 58360eabb..4b4c47f4a 100644 --- a/editors/code/rollup.config.js +++ b/editors/code/rollup.config.js | |||
@@ -11,12 +11,7 @@ export default { | |||
11 | resolve({ | 11 | resolve({ |
12 | preferBuiltins: true | 12 | preferBuiltins: true |
13 | }), | 13 | }), |
14 | commonjs({ | 14 | commonjs() |
15 | namedExports: { | ||
16 | // squelch missing import warnings | ||
17 | 'vscode-languageclient': ['CreateFile', 'RenameFile', 'ErrorCodes', 'WorkDoneProgress', 'WorkDoneProgressBegin', 'WorkDoneProgressReport', 'WorkDoneProgressEnd'] | ||
18 | } | ||
19 | }) | ||
20 | ], | 15 | ], |
21 | external: [...nodeBuiltins, 'vscode'], | 16 | external: [...nodeBuiltins, 'vscode'], |
22 | output: { | 17 | output: { |