diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-15 21:14:36 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-15 21:14:36 +0100 |
commit | 9bddd2af551702e472fb1a678466bc620b8973fa (patch) | |
tree | 54c0b67022c05c8fb5f57184bef6272af8ec1218 /crates/base_db | |
parent | d0f2bc3b878d1c1d8eaf081e6f670ebb928b7a5f (diff) | |
parent | 7cbcbccc7888b9a515cbebe2cd20fd3eebec463b (diff) |
Merge #9294
9294: internal: introduce minicore -- a subset of libcore for testing r=matklad a=matklad
Clearly, we need one more fixed point iteration loop!
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/base_db')
-rw-r--r-- | crates/base_db/src/fixture.rs | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs index 1b17db102..d56b20b83 100644 --- a/crates/base_db/src/fixture.rs +++ b/crates/base_db/src/fixture.rs | |||
@@ -9,8 +9,8 @@ use test_utils::{ | |||
9 | use vfs::{file_set::FileSet, VfsPath}; | 9 | use vfs::{file_set::FileSet, VfsPath}; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | input::CrateName, Change, CrateGraph, CrateId, Edition, Env, FileId, FilePosition, FileRange, | 12 | input::CrateName, Change, CrateDisplayName, CrateGraph, CrateId, Edition, Env, FileId, |
13 | SourceDatabaseExt, SourceRoot, SourceRootId, | 13 | FilePosition, FileRange, SourceDatabaseExt, SourceRoot, SourceRootId, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | pub const WORKSPACE: SourceRootId = SourceRootId(0); | 16 | pub const WORKSPACE: SourceRootId = SourceRootId(0); |
@@ -81,7 +81,7 @@ pub struct ChangeFixture { | |||
81 | 81 | ||
82 | impl ChangeFixture { | 82 | impl ChangeFixture { |
83 | pub fn parse(ra_fixture: &str) -> ChangeFixture { | 83 | pub fn parse(ra_fixture: &str) -> ChangeFixture { |
84 | let fixture = Fixture::parse(ra_fixture); | 84 | let (mini_core, fixture) = Fixture::parse(ra_fixture); |
85 | let mut change = Change::new(); | 85 | let mut change = Change::new(); |
86 | 86 | ||
87 | let mut files = Vec::new(); | 87 | let mut files = Vec::new(); |
@@ -166,6 +166,31 @@ impl ChangeFixture { | |||
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | if let Some(mini_core) = mini_core { | ||
170 | let core_file = file_id; | ||
171 | file_id.0 += 1; | ||
172 | |||
173 | let mut fs = FileSet::default(); | ||
174 | fs.insert(core_file, VfsPath::new_virtual_path("/sysroot/core/lib.rs".to_string())); | ||
175 | roots.push(SourceRoot::new_library(fs)); | ||
176 | |||
177 | change.change_file(core_file, Some(Arc::new(mini_core.source_code()))); | ||
178 | |||
179 | let all_crates = crate_graph.crates_in_topological_order(); | ||
180 | |||
181 | let core_crate = crate_graph.add_crate_root( | ||
182 | core_file, | ||
183 | Edition::Edition2021, | ||
184 | Some(CrateDisplayName::from_canonical_name("core".to_string())), | ||
185 | CfgOptions::default(), | ||
186 | Env::default(), | ||
187 | Vec::new(), | ||
188 | ); | ||
189 | |||
190 | for krate in all_crates { | ||
191 | crate_graph.add_dep(krate, CrateName::new("core").unwrap(), core_crate).unwrap(); | ||
192 | } | ||
193 | } | ||
169 | roots.push(SourceRoot::new_local(mem::take(&mut file_set))); | 194 | roots.push(SourceRoot::new_local(mem::take(&mut file_set))); |
170 | change.set_roots(roots); | 195 | change.set_roots(roots); |
171 | change.set_crate_graph(crate_graph); | 196 | change.set_crate_graph(crate_graph); |