diff options
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/mock_analysis.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index ad78d2d93..76910d09b 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs | |||
@@ -4,7 +4,7 @@ use std::str::FromStr; | |||
4 | use std::sync::Arc; | 4 | use std::sync::Arc; |
5 | 5 | ||
6 | use ra_cfg::CfgOptions; | 6 | use ra_cfg::CfgOptions; |
7 | use ra_db::{CrateName, Env, RelativePathBuf}; | 7 | use ra_db::{CrateName, Env}; |
8 | use test_utils::{extract_offset, extract_range, parse_fixture, FixtureEntry, CURSOR_MARKER}; | 8 | use test_utils::{extract_offset, extract_range, parse_fixture, FixtureEntry, CURSOR_MARKER}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -28,7 +28,7 @@ impl MockFileData { | |||
28 | fn path(&self) -> &str { | 28 | fn path(&self) -> &str { |
29 | match self { | 29 | match self { |
30 | MockFileData::Plain { path, .. } => path.as_str(), | 30 | MockFileData::Plain { path, .. } => path.as_str(), |
31 | MockFileData::Fixture(f) => f.meta.path().as_str(), | 31 | MockFileData::Fixture(f) => f.meta.path(), |
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
@@ -167,7 +167,6 @@ impl MockAnalysis { | |||
167 | for (i, data) in self.files.into_iter().enumerate() { | 167 | for (i, data) in self.files.into_iter().enumerate() { |
168 | let path = data.path(); | 168 | let path = data.path(); |
169 | assert!(path.starts_with('/')); | 169 | assert!(path.starts_with('/')); |
170 | let path = RelativePathBuf::from_path(&path[1..]).unwrap(); | ||
171 | let cfg_options = data.cfg_options(); | 170 | let cfg_options = data.cfg_options(); |
172 | let file_id = FileId(i as u32 + 1); | 171 | let file_id = FileId(i as u32 + 1); |
173 | let edition = data.edition(); | 172 | let edition = data.edition(); |
@@ -183,7 +182,8 @@ impl MockAnalysis { | |||
183 | Default::default(), | 182 | Default::default(), |
184 | )); | 183 | )); |
185 | } else if path.ends_with("/lib.rs") { | 184 | } else if path.ends_with("/lib.rs") { |
186 | let crate_name = path.parent().unwrap().file_name().unwrap(); | 185 | let base = &path[..path.len() - "/lib.rs".len()]; |
186 | let crate_name = &base[base.rfind('/').unwrap() + '/'.len_utf8()..]; | ||
187 | let other_crate = crate_graph.add_crate_root( | 187 | let other_crate = crate_graph.add_crate_root( |
188 | file_id, | 188 | file_id, |
189 | edition, | 189 | edition, |
@@ -199,7 +199,7 @@ impl MockAnalysis { | |||
199 | .unwrap(); | 199 | .unwrap(); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | change.add_file(source_root, file_id, path, Arc::new(data.content().to_owned())); | 202 | change.add_file(source_root, file_id, path.into(), Arc::new(data.content().to_owned())); |
203 | } | 203 | } |
204 | change.set_crate_graph(crate_graph); | 204 | change.set_crate_graph(crate_graph); |
205 | host.apply_change(change); | 205 | host.apply_change(change); |