diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-12 20:37:53 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-12 20:37:53 +1000 |
| commit | d862ae2fce07c32252adc95bf32904fc74bbc532 (patch) | |
| tree | 5f64932ad738f1920023a0393a82ed1714ab9725 /compiler/rustc_lint/src | |
| parent | 38483d8eb156f5947deedf3ca2654e2ac560a082 (diff) | |
| parent | 928dd114377f5a0c9db521d85987f0df73ca254d (diff) | |
| download | rust-d862ae2fce07c32252adc95bf32904fc74bbc532.tar.gz rust-d862ae2fce07c32252adc95bf32904fc74bbc532.zip | |
Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmann
Tweak invalid builtin attribute output - Add link to reference/docs when possible - More accurate suggestions by supporting multiple alternative suggestions ``` error: malformed `crate_type` attribute input --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> help: the following are the possible correct uses | LL - #![crate_type = foo!()] LL + #![crate_type = "bin"] | LL - #![crate_type = foo!()] LL + #![crate_type = "cdylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "dylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "lib"] | = and 4 other candidates ```
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/early/diagnostics.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/lints.rs | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index f0fbf5bc81e..1e4bc79ce70 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -447,12 +447,14 @@ pub fn decorate_builtin_lint( BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => { lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag) } - BuiltinLintDiag::IllFormedAttributeInput { suggestions } => { + BuiltinLintDiag::IllFormedAttributeInput { suggestions, docs } => { lints::IllFormedAttributeInput { num_suggestions: suggestions.len(), suggestions: DiagArgValue::StrListSepByAnd( suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(), ), + has_docs: docs.is_some(), + docs: docs.unwrap_or(""), } .decorate_lint(diag) } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 73e69a1791a..ba0112c8ac6 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -2685,6 +2685,9 @@ pub(crate) struct UnusedCrateDependency { pub(crate) struct IllFormedAttributeInput { pub num_suggestions: usize, pub suggestions: DiagArgValue, + #[note] + pub has_docs: bool, + pub docs: &'static str, } #[derive(LintDiagnostic)] |
