From 7b1a0d5fb724d3f802fe23f9b4455ffd6d7e114f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 10 Mar 2021 20:30:20 +0100 Subject: [PATCH] Diagnose files that aren't in the module tree --- crates/ide/src/diagnostics.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index fe32f39b643..760c8478050 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -197,9 +197,19 @@ pub(crate) fn diagnostics( ); }); - if let Some(m) = sema.to_module_def(file_id) { - m.diagnostics(db, &mut sink); - }; + match sema.to_module_def(file_id) { + Some(m) => m.diagnostics(db, &mut sink), + None => { + res.borrow_mut().push( + Diagnostic::hint( + parse.tree().syntax().text_range(), + "file not included in module tree".to_string(), + ) + .with_unused(true), + ); + } + } + drop(sink); res.into_inner() }