Skip to content

Commit f9a337c

Browse files
committed
Auto merge of rust-lang#17411 - Wilfred:clearer_unlinked_file, r=Veykril
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. ![Screenshot 2024-06-12 at 5 55 48 PM](https://github.com/rust-lang/rust-analyzer/assets/70800/c91ee1ed-1c72-495a-9ee3-9e360a5c6977) (Full disclosure: I've tested a rust-analyzer build in VS Code, but the pop-up logic is currently disabled due to rust-lang#17062, so I haven't tested that.)
2 parents a32ce24 + 39179c4 commit f9a337c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ pub(crate) fn unlinked_file(
3030
// FIXME: This is a hack for the vscode extension to notice whether there is an autofix or not before having to resolve diagnostics.
3131
// This is to prevent project linking popups from appearing when there is an autofix. https://github.com/rust-lang/rust-analyzer/issues/14523
3232
let message = if fixes.is_none() {
33-
"file not included in crate hierarchy"
33+
"This file is not included in any crates, so rust-analyzer can't offer IDE services."
3434
} else {
35-
"file not included in module tree"
35+
"This file is not included anywhere in the module tree, so rust-analyzer can't offer IDE services."
3636
};
3737

38+
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.");
39+
3840
let mut range = ctx.sema.db.parse(file_id).syntax_node().text_range();
3941
let mut unused = true;
4042

src/tools/rust-analyzer/editors/code/src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export async function createClient(
7676
// value === "unlinked-file" &&
7777
value === "temporary-disabled" &&
7878
!unlinkedFiles.includes(uri) &&
79-
diag.message !== "file not included in module tree"
79+
(diag.message === "file not included in crate hierarchy" ||
80+
diag.message.startsWith("This file is not included in any crates"))
8081
) {
8182
const config = vscode.workspace.getConfiguration("rust-analyzer");
8283
if (config.get("showUnlinkedFileNotification")) {

0 commit comments

Comments
 (0)