aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-22 16:30:23 +0100
committerAleksey Kladov <[email protected]>2020-06-22 23:14:44 +0100
commit6a6098d4c31f6b54c8768e32f24182645ac077d6 (patch)
tree66879957613620b5c2788f9d98ac36fd24a603d6 /crates/ra_ide
parent5a0331e5575034a145956f76316ee0fcdf72077e (diff)
Remove RelativePathBuf from fixture
The paths in fixture are not really relative (the default one is `/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/mock_analysis.rs10
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;
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use ra_cfg::CfgOptions; 6use ra_cfg::CfgOptions;
7use ra_db::{CrateName, Env, RelativePathBuf}; 7use ra_db::{CrateName, Env};
8use test_utils::{extract_offset, extract_range, parse_fixture, FixtureEntry, CURSOR_MARKER}; 8use test_utils::{extract_offset, extract_range, parse_fixture, FixtureEntry, CURSOR_MARKER};
9 9
10use crate::{ 10use 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);