aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_expand/src/db.rs6
-rw-r--r--crates/rust-analyzer/src/main_loop.rs104
-rw-r--r--crates/rust-analyzer/src/reload.rs2
3 files changed, 64 insertions, 48 deletions
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs
index 46ebdbc74..bf16b56b1 100644
--- a/crates/hir_expand/src/db.rs
+++ b/crates/hir_expand/src/db.rs
@@ -189,6 +189,7 @@ fn macro_expand_with_arg(
189 id: MacroCallId, 189 id: MacroCallId,
190 arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>, 190 arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>,
191) -> ExpandResult<Option<Arc<tt::Subtree>>> { 191) -> ExpandResult<Option<Arc<tt::Subtree>>> {
192 let _p = profile::span("macro_expand");
192 let lazy_id = match id { 193 let lazy_id = match id {
193 MacroCallId::LazyMacro(id) => id, 194 MacroCallId::LazyMacro(id) => id,
194 MacroCallId::EagerMacro(id) => { 195 MacroCallId::EagerMacro(id) => {
@@ -276,14 +277,15 @@ fn parse_macro_with_arg(
276 macro_file: MacroFile, 277 macro_file: MacroFile,
277 arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>, 278 arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>,
278) -> ExpandResult<Option<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)>> { 279) -> ExpandResult<Option<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)>> {
279 let _p = profile::span("parse_macro_query");
280
281 let macro_call_id = macro_file.macro_call_id; 280 let macro_call_id = macro_file.macro_call_id;
282 let result = if let Some(arg) = arg { 281 let result = if let Some(arg) = arg {
283 macro_expand_with_arg(db, macro_call_id, Some(arg)) 282 macro_expand_with_arg(db, macro_call_id, Some(arg))
284 } else { 283 } else {
285 db.macro_expand(macro_call_id) 284 db.macro_expand(macro_call_id)
286 }; 285 };
286
287 let _p = profile::span("parse_macro_expansion");
288
287 if let Some(err) = &result.err { 289 if let Some(err) = &result.err {
288 // Note: 290 // Note:
289 // The final goal we would like to make all parse_macro success, 291 // The final goal we would like to make all parse_macro success,
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 866d1d176..f349b0810 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -289,55 +289,69 @@ impl GlobalState {
289 } 289 }
290 } 290 }
291 } 291 }
292 Event::Flycheck(task) => match task { 292 Event::Flycheck(mut task) => {
293 flycheck::Message::AddDiagnostic { workspace_root, diagnostic } => { 293 let _p = profile::span("GlobalState::handle_event/flycheck");
294 let diagnostics = crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp( 294 loop {
295 &self.config.diagnostics_map, 295 match task {
296 &diagnostic, 296 flycheck::Message::AddDiagnostic { workspace_root, diagnostic } => {
297 &workspace_root, 297 let diagnostics =
298 ); 298 crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp(
299 for diag in diagnostics { 299 &self.config.diagnostics_map,
300 match url_to_file_id(&self.vfs.read().0, &diag.url) { 300 &diagnostic,
301 Ok(file_id) => self.diagnostics.add_check_diagnostic( 301 &workspace_root,
302 file_id, 302 );
303 diag.diagnostic, 303 for diag in diagnostics {
304 diag.fixes, 304 match url_to_file_id(&self.vfs.read().0, &diag.url) {
305 ), 305 Ok(file_id) => self.diagnostics.add_check_diagnostic(
306 Err(err) => { 306 file_id,
307 log::error!("File with cargo diagnostic not found in VFS: {}", err); 307 diag.diagnostic,
308 } 308 diag.fixes,
309 }; 309 ),
310 } 310 Err(err) => {
311 } 311 log::error!(
312 312 "File with cargo diagnostic not found in VFS: {}",
313 flycheck::Message::Progress { id, progress } => { 313 err
314 let (state, message) = match progress { 314 );
315 flycheck::Progress::DidStart => { 315 }
316 self.diagnostics.clear_check(); 316 };
317 (Progress::Begin, None)
318 }
319 flycheck::Progress::DidCheckCrate(target) => {
320 (Progress::Report, Some(target))
321 }
322 flycheck::Progress::DidCancel => (Progress::End, None),
323 flycheck::Progress::DidFinish(result) => {
324 if let Err(err) = result {
325 log::error!("cargo check failed: {}", err)
326 } 317 }
327 (Progress::End, None)
328 } 318 }
329 };
330 319
331 // When we're running multiple flychecks, we have to include a disambiguator in 320 flycheck::Message::Progress { id, progress } => {
332 // the title, or the editor complains. Note that this is a user-facing string. 321 let (state, message) = match progress {
333 let title = if self.flycheck.len() == 1 { 322 flycheck::Progress::DidStart => {
334 "cargo check".to_string() 323 self.diagnostics.clear_check();
335 } else { 324 (Progress::Begin, None)
336 format!("cargo check (#{})", id + 1) 325 }
337 }; 326 flycheck::Progress::DidCheckCrate(target) => {
338 self.report_progress(&title, state, message, None); 327 (Progress::Report, Some(target))
328 }
329 flycheck::Progress::DidCancel => (Progress::End, None),
330 flycheck::Progress::DidFinish(result) => {
331 if let Err(err) = result {
332 log::error!("cargo check failed: {}", err)
333 }
334 (Progress::End, None)
335 }
336 };
337
338 // When we're running multiple flychecks, we have to include a disambiguator in
339 // the title, or the editor complains. Note that this is a user-facing string.
340 let title = if self.flycheck.len() == 1 {
341 "cargo check".to_string()
342 } else {
343 format!("cargo check (#{})", id + 1)
344 };
345 self.report_progress(&title, state, message, None);
346 }
347 }
348 // Coalesce many flycheck updates into a single loop turn
349 task = match self.flycheck_receiver.try_recv() {
350 Ok(task) => task,
351 Err(_) => break,
352 }
339 } 353 }
340 }, 354 }
341 } 355 }
342 356
343 let state_changed = self.process_changes(); 357 let state_changed = self.process_changes();
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 001bf5949..b2d35f535 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -205,7 +205,7 @@ impl GlobalState {
205 } 205 }
206 let res = vfs.file_id(&vfs_path); 206 let res = vfs.file_id(&vfs_path);
207 if res.is_none() { 207 if res.is_none() {
208 log::error!("failed to load {}", path.display()) 208 log::warn!("failed to load {}", path.display())
209 } 209 }
210 res 210 res
211 }; 211 };