diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-09 10:35:17 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-09 10:35:17 +0000 |
commit | 0d6e5a986cc7c3a434c2107edf748d1c26ac3f69 (patch) | |
tree | c5adb573c201abf473370c947e714c8d9cd129ff /crates/ra_db/src/input.rs | |
parent | 5ced6f4be31576849f37e15c150f3ca3eea37b4d (diff) | |
parent | d761435ba006227bc1a83f8450cfde000dac5aa3 (diff) |
Merge #2771
2771: Remove the Default impl for SourceRoot r=matklad a=michalt
Let's be always explicit whether we create a library (i.e., an immutable
dependency) or a local `SourceRoot`, since it can have a large impact on
the validation performance in salsa. (we found it the hard way recently,
where the `Default` instance made it quite tricky to spot a bug)
Signed-off-by: Michal Terepeta <[email protected]>
Co-authored-by: Michal Terepeta <[email protected]>
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r-- | crates/ra_db/src/input.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 2a7ed20d1..07269237a 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -33,7 +33,7 @@ pub struct FileId(pub u32); | |||
33 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] | 33 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] |
34 | pub struct SourceRootId(pub u32); | 34 | pub struct SourceRootId(pub u32); |
35 | 35 | ||
36 | #[derive(Default, Clone, Debug, PartialEq, Eq)] | 36 | #[derive(Clone, Debug, PartialEq, Eq)] |
37 | pub struct SourceRoot { | 37 | pub struct SourceRoot { |
38 | /// Sysroot or crates.io library. | 38 | /// Sysroot or crates.io library. |
39 | /// | 39 | /// |
@@ -44,11 +44,11 @@ pub struct SourceRoot { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | impl SourceRoot { | 46 | impl SourceRoot { |
47 | pub fn new() -> SourceRoot { | 47 | pub fn new_local() -> SourceRoot { |
48 | Default::default() | 48 | SourceRoot { is_library: false, files: Default::default() } |
49 | } | 49 | } |
50 | pub fn new_library() -> SourceRoot { | 50 | pub fn new_library() -> SourceRoot { |
51 | SourceRoot { is_library: true, ..SourceRoot::new() } | 51 | SourceRoot { is_library: true, files: Default::default() } |
52 | } | 52 | } |
53 | pub fn insert_file(&mut self, path: RelativePathBuf, file_id: FileId) { | 53 | pub fn insert_file(&mut self, path: RelativePathBuf, file_id: FileId) { |
54 | self.files.insert(path, file_id); | 54 | self.files.insert(path, file_id); |