diff options
| author | Wilfred Hughes <wilfred@meta.com> | 2024-06-12 17:31:39 -0700 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2024-06-20 09:32:48 -0700 |
| commit | 39179c49c657adcc7178d5218edc19f725fc0c42 (patch) | |
| tree | 05ff5fcba3cb4a9fe9fca220a07b07aa197d17ff | |
| parent | 9b8b6f92b21e27d26ae334f091cab90f9f9678e5 (diff) | |
| download | rust-39179c49c657adcc7178d5218edc19f725fc0c42.tar.gz rust-39179c49c657adcc7178d5218edc19f725fc0c42.zip | |
fix: Improve hover text in unlinked file diagnostics
Use full sentences, and mention how to disable the diagnostic if users are intentionally working on unowned files.
| -rw-r--r-- | src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs | 6 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/client.ts | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs index cbf50d13f58..77ffd0fd968 100644 --- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs +++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs @@ -30,11 +30,13 @@ pub(crate) fn unlinked_file( // FIXME: This is a hack for the vscode extension to notice whether there is an autofix or not before having to resolve diagnostics. // This is to prevent project linking popups from appearing when there is an autofix. https://github.com/rust-lang/rust-analyzer/issues/14523 let message = if fixes.is_none() { - "file not included in crate hierarchy" + "This file is not included in any crates, so rust-analyzer can't offer IDE services." } else { - "file not included in module tree" + "This file is not included anywhere in the module tree, so rust-analyzer can't offer IDE services." }; + let message = format!("{message}\n\nIf you're intentionally working on unowned files, you can silence this warning by adding \"unlinked-file\" to rust-analyzer.diagnostics.disabled in your settings."); + let mut range = ctx.sema.db.parse(file_id).syntax_node().text_range(); let mut unused = true; diff --git a/src/tools/rust-analyzer/editors/code/src/client.ts b/src/tools/rust-analyzer/editors/code/src/client.ts index 1c2a34b484d..542233e7b91 100644 --- a/src/tools/rust-analyzer/editors/code/src/client.ts +++ b/src/tools/rust-analyzer/editors/code/src/client.ts @@ -76,7 +76,8 @@ export async function createClient( // value === "unlinked-file" && value === "temporary-disabled" && !unlinkedFiles.includes(uri) && - diag.message !== "file not included in module tree" + (diag.message === "file not included in crate hierarchy" || + diag.message.startsWith("This file is not included in any crates")) ) { const config = vscode.workspace.getConfiguration("rust-analyzer"); if (config.get("showUnlinkedFileNotification")) { |
