Rollup merge of #133221 - Urgau:check-cfg-macro-diag, r=jieyouxu
Add external macros specific diagnostics for check-cfg This PR adds specific check-cfg diagnostics for unexpected cfg in external macros. As well as hiding the some of the Cargo specific help/suggestions as they distraction for external macros and are generally not the right solution. Follow-up to #132577 `@rustbot` label +L-unexpected_cfgs r? compiler
This commit is contained in:
commit
f96fdab101
8 changed files with 211 additions and 29 deletions
|
@ -2172,6 +2172,25 @@ impl UnexpectedCfgRustcHelp {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note(lint_unexpected_cfg_from_external_macro_origin)]
|
||||
#[help(lint_unexpected_cfg_from_external_macro_refer)]
|
||||
pub(crate) struct UnexpectedCfgRustcMacroHelp {
|
||||
pub macro_kind: &'static str,
|
||||
pub macro_name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[note(lint_unexpected_cfg_from_external_macro_origin)]
|
||||
#[help(lint_unexpected_cfg_from_external_macro_refer)]
|
||||
#[help(lint_unexpected_cfg_cargo_update)]
|
||||
pub(crate) struct UnexpectedCfgCargoMacroHelp {
|
||||
pub macro_kind: &'static str,
|
||||
pub macro_name: Symbol,
|
||||
// FIXME: Figure out a way to get the crate name
|
||||
// crate_name: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_unexpected_cfg_name)]
|
||||
pub(crate) struct UnexpectedCfgName {
|
||||
|
@ -2276,10 +2295,17 @@ pub(crate) mod unexpected_cfg_name {
|
|||
#[note(lint_unexpected_cfg_doc_cargo)]
|
||||
Cargo {
|
||||
#[subdiagnostic]
|
||||
sub: Option<super::UnexpectedCfgCargoHelp>,
|
||||
macro_help: Option<super::UnexpectedCfgCargoMacroHelp>,
|
||||
#[subdiagnostic]
|
||||
help: Option<super::UnexpectedCfgCargoHelp>,
|
||||
},
|
||||
#[note(lint_unexpected_cfg_doc_rustc)]
|
||||
Rustc(#[subdiagnostic] super::UnexpectedCfgRustcHelp),
|
||||
Rustc {
|
||||
#[subdiagnostic]
|
||||
macro_help: Option<super::UnexpectedCfgRustcMacroHelp>,
|
||||
#[subdiagnostic]
|
||||
help: super::UnexpectedCfgRustcHelp,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2382,9 +2408,19 @@ pub(crate) mod unexpected_cfg_value {
|
|||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum InvocationHelp {
|
||||
#[note(lint_unexpected_cfg_doc_cargo)]
|
||||
Cargo(#[subdiagnostic] Option<CargoHelp>),
|
||||
Cargo {
|
||||
#[subdiagnostic]
|
||||
help: Option<CargoHelp>,
|
||||
#[subdiagnostic]
|
||||
macro_help: Option<super::UnexpectedCfgCargoMacroHelp>,
|
||||
},
|
||||
#[note(lint_unexpected_cfg_doc_rustc)]
|
||||
Rustc(#[subdiagnostic] Option<super::UnexpectedCfgRustcHelp>),
|
||||
Rustc {
|
||||
#[subdiagnostic]
|
||||
help: Option<super::UnexpectedCfgRustcHelp>,
|
||||
#[subdiagnostic]
|
||||
macro_help: Option<super::UnexpectedCfgRustcMacroHelp>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue