aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/handlers/raw_string.rs2
-rw-r--r--crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs2
-rw-r--r--crates/ra_hir_def/src/nameres.rs20
-rw-r--r--crates/ra_hir_def/src/nameres/tests.rs2
-rw-r--r--crates/ra_hir_ty/src/lower.rs2
-rw-r--r--crates/ra_ide/src/completion.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs4
-rw-r--r--crates/ra_ide/src/diagnostics.rs2
-rw-r--r--crates/ra_ide/src/inlay_hints.rs2
-rw-r--r--crates/ra_project_model/src/project_json.rs60
-rw-r--r--crates/rust-analyzer/src/reload.rs2
-rw-r--r--crates/vfs/src/loader.rs14
-rw-r--r--xtask/src/release.rs2
13 files changed, 62 insertions, 54 deletions
diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/ra_assists/src/handlers/raw_string.rs
index ba1dcb610..4e8a0c2db 100644
--- a/crates/ra_assists/src/handlers/raw_string.rs
+++ b/crates/ra_assists/src/handlers/raw_string.rs
@@ -131,7 +131,7 @@ pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
131 let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?; 131 let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?;
132 132
133 let text = token.text().as_str(); 133 let text = token.text().as_str();
134 if !text.starts_with("r#") && text.ends_with("#") { 134 if !text.starts_with("r#") && text.ends_with('#') {
135 return None; 135 return None;
136 } 136 }
137 137
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs
index dfd314abf..3d51faa54 100644
--- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs
+++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs
@@ -106,7 +106,7 @@ fn maybe_replace_path(
106 path: ast::Path, 106 path: ast::Path,
107 target: ast::Path, 107 target: ast::Path,
108) -> Option<()> { 108) -> Option<()> {
109 if !path_eq(path.clone(), target.clone()) { 109 if !path_eq(path.clone(), target) {
110 return None; 110 return None;
111 } 111 }
112 112
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index b279bdeef..5a9de3d3e 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -229,12 +229,11 @@ impl CrateDefMap {
229 // even), as this should be a great debugging aid. 229 // even), as this should be a great debugging aid.
230 pub fn dump(&self) -> String { 230 pub fn dump(&self) -> String {
231 let mut buf = String::new(); 231 let mut buf = String::new();
232 go(&mut buf, self, "\ncrate", self.root); 232 go(&mut buf, self, "crate", self.root);
233 return buf.trim().to_string(); 233 return buf;
234 234
235 fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { 235 fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) {
236 *buf += path; 236 format_to!(buf, "{}\n", path);
237 *buf += "\n";
238 237
239 let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); 238 let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect();
240 entries.sort_by_key(|(name, _)| name.clone()); 239 entries.sort_by_key(|(name, _)| name.clone());
@@ -243,23 +242,24 @@ impl CrateDefMap {
243 format_to!(buf, "{}:", name); 242 format_to!(buf, "{}:", name);
244 243
245 if def.types.is_some() { 244 if def.types.is_some() {
246 *buf += " t"; 245 buf.push_str(" t");
247 } 246 }
248 if def.values.is_some() { 247 if def.values.is_some() {
249 *buf += " v"; 248 buf.push_str(" v");
250 } 249 }
251 if def.macros.is_some() { 250 if def.macros.is_some() {
252 *buf += " m"; 251 buf.push_str(" m");
253 } 252 }
254 if def.is_none() { 253 if def.is_none() {
255 *buf += " _"; 254 buf.push_str(" _");
256 } 255 }
257 256
258 *buf += "\n"; 257 buf.push_str("\n");
259 } 258 }
260 259
261 for (name, child) in map.modules[module].children.iter() { 260 for (name, child) in map.modules[module].children.iter() {
262 let path = &format!("{}::{}", path, name); 261 let path = format!("{}::{}", path, name);
262 buf.push('\n');
263 go(buf, map, &path, *child); 263 go(buf, map, &path, *child);
264 } 264 }
265 } 265 }
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index 02dca80c2..205d3528b 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -21,7 +21,7 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
21fn check(ra_fixture: &str, expect: Expect) { 21fn check(ra_fixture: &str, expect: Expect) {
22 let db = TestDB::with_files(ra_fixture); 22 let db = TestDB::with_files(ra_fixture);
23 let krate = db.crate_graph().iter().next().unwrap(); 23 let krate = db.crate_graph().iter().next().unwrap();
24 let actual = db.crate_def_map(krate).dump() + "\n"; 24 let actual = db.crate_def_map(krate).dump();
25 expect.assert_eq(&actual); 25 expect.assert_eq(&actual);
26} 26}
27 27
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index f274579ea..1eacc6f95 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -341,7 +341,7 @@ impl Ty {
341 let segment = remaining_segments.first().unwrap(); 341 let segment = remaining_segments.first().unwrap();
342 let found = associated_type_by_name_including_super_traits( 342 let found = associated_type_by_name_including_super_traits(
343 ctx.db, 343 ctx.db,
344 trait_ref.clone(), 344 trait_ref,
345 &segment.name, 345 &segment.name,
346 ); 346 );
347 match found { 347 match found {
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs
index f3a5e9573..68ac05e4c 100644
--- a/crates/ra_ide/src/completion.rs
+++ b/crates/ra_ide/src/completion.rs
@@ -63,7 +63,7 @@ pub use crate::completion::{
63// There also snippet completions: 63// There also snippet completions:
64// 64//
65// .Expressions 65// .Expressions
66// - `pd` -> `eprintln!(" = {:?}", );")` 66// - `pd` -> `eprintln!(" = {:?}", );`
67// - `ppd` -> `eprintln!(" = {:#?}", );` 67// - `ppd` -> `eprintln!(" = {:#?}", );`
68// 68//
69// .Items 69// .Items
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 9e82d6854..c84d43d77 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -215,7 +215,7 @@ impl<'a> CompletionContext<'a> {
215 215
216 fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) { 216 fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) {
217 let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap(); 217 let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap();
218 let syntax_element = NodeOrToken::Token(fake_ident_token.clone()); 218 let syntax_element = NodeOrToken::Token(fake_ident_token);
219 self.block_expr_parent = has_block_expr_parent(syntax_element.clone()); 219 self.block_expr_parent = has_block_expr_parent(syntax_element.clone());
220 self.unsafe_is_prev = unsafe_is_prev(syntax_element.clone()); 220 self.unsafe_is_prev = unsafe_is_prev(syntax_element.clone());
221 self.if_is_prev = if_is_prev(syntax_element.clone()); 221 self.if_is_prev = if_is_prev(syntax_element.clone());
@@ -228,7 +228,7 @@ impl<'a> CompletionContext<'a> {
228 self.trait_as_prev_sibling = has_trait_as_prev_sibling(syntax_element.clone()); 228 self.trait_as_prev_sibling = has_trait_as_prev_sibling(syntax_element.clone());
229 self.is_match_arm = is_match_arm(syntax_element.clone()); 229 self.is_match_arm = is_match_arm(syntax_element.clone());
230 self.has_item_list_or_source_file_parent = 230 self.has_item_list_or_source_file_parent =
231 has_item_list_or_source_file_parent(syntax_element.clone()); 231 has_item_list_or_source_file_parent(syntax_element);
232 } 232 }
233 233
234 fn fill( 234 fn fill(
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index fe75f4b2c..e029af0dc 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -183,7 +183,7 @@ fn missing_struct_field_fix(
183 } 183 }
184 new_field = format!("\n{}{}", indent, new_field); 184 new_field = format!("\n{}{}", indent, new_field);
185 185
186 let needs_comma = !last_field_syntax.to_string().ends_with(","); 186 let needs_comma = !last_field_syntax.to_string().ends_with(',');
187 if needs_comma { 187 if needs_comma {
188 new_field = format!(",{}", new_field); 188 new_field = format!(",{}", new_field);
189 } 189 }
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 43a5e29b5..09883ab4d 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -171,7 +171,7 @@ fn get_param_name_hints(
171 .map(|(param_name, arg)| InlayHint { 171 .map(|(param_name, arg)| InlayHint {
172 range: arg.syntax().text_range(), 172 range: arg.syntax().text_range(),
173 kind: InlayKind::ParameterHint, 173 kind: InlayKind::ParameterHint,
174 label: param_name.to_string().into(), 174 label: param_name.into(),
175 }); 175 });
176 176
177 acc.extend(hints); 177 acc.extend(hints);
diff --git a/crates/ra_project_model/src/project_json.rs b/crates/ra_project_model/src/project_json.rs
index b96227949..778cc84ef 100644
--- a/crates/ra_project_model/src/project_json.rs
+++ b/crates/ra_project_model/src/project_json.rs
@@ -34,6 +34,7 @@ pub struct Crate {
34 pub(crate) target: Option<String>, 34 pub(crate) target: Option<String>,
35 pub(crate) out_dir: Option<AbsPathBuf>, 35 pub(crate) out_dir: Option<AbsPathBuf>,
36 pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>, 36 pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>,
37 pub(crate) is_workspace_member: bool,
37} 38}
38 39
39impl ProjectJson { 40impl ProjectJson {
@@ -43,32 +44,42 @@ impl ProjectJson {
43 crates: data 44 crates: data
44 .crates 45 .crates
45 .into_iter() 46 .into_iter()
46 .map(|crate_data| Crate { 47 .map(|crate_data| {
47 root_module: base.join(crate_data.root_module), 48 let is_workspace_member = crate_data.is_workspace_member.unwrap_or_else(|| {
48 edition: crate_data.edition.into(), 49 crate_data.root_module.is_relative()
49 deps: crate_data 50 && !crate_data.root_module.starts_with("..")
50 .deps 51 || crate_data.root_module.starts_with(base)
51 .into_iter() 52 });
52 .map(|dep_data| Dependency { 53 Crate {
53 crate_id: CrateId(dep_data.krate as u32), 54 root_module: base.join(crate_data.root_module),
54 name: dep_data.name, 55 edition: crate_data.edition.into(),
55 }) 56 deps: crate_data
56 .collect::<Vec<_>>(), 57 .deps
57 cfg: { 58 .into_iter()
58 let mut cfg = CfgOptions::default(); 59 .map(|dep_data| Dependency {
59 for entry in &crate_data.cfg { 60 crate_id: CrateId(dep_data.krate as u32),
60 match split_delim(entry, '=') { 61 name: dep_data.name,
61 Some((key, value)) => { 62 })
62 cfg.insert_key_value(key.into(), value.into()); 63 .collect::<Vec<_>>(),
64 cfg: {
65 let mut cfg = CfgOptions::default();
66 for entry in &crate_data.cfg {
67 match split_delim(entry, '=') {
68 Some((key, value)) => {
69 cfg.insert_key_value(key.into(), value.into());
70 }
71 None => cfg.insert_atom(entry.into()),
63 } 72 }
64 None => cfg.insert_atom(entry.into()),
65 } 73 }
66 } 74 cfg
67 cfg 75 },
68 }, 76 target: crate_data.target,
69 target: crate_data.target, 77 out_dir: crate_data.out_dir.map(|it| base.join(it)),
70 out_dir: crate_data.out_dir.map(|it| base.join(it)), 78 proc_macro_dylib_path: crate_data
71 proc_macro_dylib_path: crate_data.proc_macro_dylib_path.map(|it| base.join(it)), 79 .proc_macro_dylib_path
80 .map(|it| base.join(it)),
81 is_workspace_member,
82 }
72 }) 83 })
73 .collect::<Vec<_>>(), 84 .collect::<Vec<_>>(),
74 } 85 }
@@ -91,6 +102,7 @@ struct CrateData {
91 target: Option<String>, 102 target: Option<String>,
92 out_dir: Option<PathBuf>, 103 out_dir: Option<PathBuf>,
93 proc_macro_dylib_path: Option<PathBuf>, 104 proc_macro_dylib_path: Option<PathBuf>,
105 is_workspace_member: Option<bool>,
94} 106}
95 107
96#[derive(Deserialize)] 108#[derive(Deserialize)]
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 3f4dbdd8c..d7ae00b07 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -242,7 +242,7 @@ impl GlobalState {
242 }) 242 })
243 .map(move |cargo| { 243 .map(move |cargo| {
244 let cargo_project_root = cargo.workspace_root().to_path_buf(); 244 let cargo_project_root = cargo.workspace_root().to_path_buf();
245 FlycheckHandle::spawn(sender, config.clone(), cargo_project_root.into()) 245 FlycheckHandle::spawn(sender, config, cargo_project_root.into())
246 }) 246 })
247 } 247 }
248} 248}
diff --git a/crates/vfs/src/loader.rs b/crates/vfs/src/loader.rs
index 9c6e4b6a7..04e257f53 100644
--- a/crates/vfs/src/loader.rs
+++ b/crates/vfs/src/loader.rs
@@ -83,11 +83,11 @@ impl Directories {
83 self.includes_path(path) 83 self.includes_path(path)
84 } 84 }
85 fn includes_path(&self, path: &AbsPath) -> bool { 85 fn includes_path(&self, path: &AbsPath) -> bool {
86 let mut include = None; 86 let mut include: Option<&AbsPathBuf> = None;
87 for incl in &self.include { 87 for incl in &self.include {
88 if is_prefix(incl, path) { 88 if path.starts_with(incl) {
89 include = Some(match include { 89 include = Some(match include {
90 Some(prev) if is_prefix(incl, prev) => prev, 90 Some(prev) if prev.starts_with(incl) => prev,
91 _ => incl, 91 _ => incl,
92 }) 92 })
93 } 93 }
@@ -97,15 +97,11 @@ impl Directories {
97 None => return false, 97 None => return false,
98 }; 98 };
99 for excl in &self.exclude { 99 for excl in &self.exclude {
100 if is_prefix(excl, path) && is_prefix(include, excl) { 100 if path.starts_with(excl) && excl.starts_with(include) {
101 return false; 101 return false;
102 } 102 }
103 } 103 }
104 return true; 104 true
105
106 fn is_prefix(short: &AbsPath, long: &AbsPath) -> bool {
107 long.strip_prefix(short).is_some()
108 }
109 } 105 }
110} 106}
111 107
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index 530bd8205..7fa0966aa 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -37,7 +37,7 @@ Release: release:{}[]
37 37
38== Sponsors 38== Sponsors
39 39
40**Become a sponsor:** https://opencollective.com/rust-analyzer/[opecollective.com/rust-analyzer] 40**Become a sponsor:** https://opencollective.com/rust-analyzer/[opencollective.com/rust-analyzer]
41 41
42== New Features 42== New Features
43 43