diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
commit | 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch) | |
tree | 3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /compiler/rustc_lint_defs/src/lib.rs | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip |
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | compiler/rustc_lint_defs/src/lib.rs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 6acbe97a7..11b2d057a 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -1,4 +1,6 @@ #![feature(min_specialization)] +#![deny(rustc::untranslatable_diagnostic)] +#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_macros; @@ -7,7 +9,7 @@ pub use self::Level::*; use rustc_ast::node_id::{NodeId, NodeMap}; use rustc_ast::{AttrId, Attribute}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; -use rustc_error_messages::MultiSpan; +use rustc_error_messages::{DiagnosticMessage, MultiSpan}; use rustc_hir::HashStableContext; use rustc_hir::HirId; use rustc_span::edition::Edition; @@ -39,7 +41,8 @@ macro_rules! pluralize { /// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion /// to determine whether it should be automatically applied or if the user should be consulted /// before applying the suggestion. -#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Hash, Encodable, Decodable, Serialize, Deserialize)] +#[derive(PartialEq, Eq, PartialOrd, Ord)] pub enum Applicability { /// The suggestion is definitely what the user intended, or maintains the exact meaning of the code. /// This suggestion should be automatically applied. @@ -489,7 +492,7 @@ pub struct BufferedEarlyLint { pub span: MultiSpan, /// The lint message. - pub msg: String, + pub msg: DiagnosticMessage, /// The `NodeId` of the AST node that generated the lint. pub node_id: NodeId, @@ -518,11 +521,11 @@ impl LintBuffer { lint: &'static Lint, node_id: NodeId, span: MultiSpan, - msg: &str, + msg: impl Into<DiagnosticMessage>, diagnostic: BuiltinLintDiagnostics, ) { let lint_id = LintId::of(lint); - let msg = msg.to_string(); + let msg = msg.into(); self.add_early_lint(BufferedEarlyLint { lint_id, node_id, span, msg, diagnostic }); } @@ -535,7 +538,7 @@ impl LintBuffer { lint: &'static Lint, id: NodeId, sp: impl Into<MultiSpan>, - msg: &str, + msg: impl Into<DiagnosticMessage>, ) { self.add_lint(lint, id, sp.into(), msg, BuiltinLintDiagnostics::Normal) } @@ -545,7 +548,7 @@ impl LintBuffer { lint: &'static Lint, id: NodeId, sp: impl Into<MultiSpan>, - msg: &str, + msg: impl Into<DiagnosticMessage>, diagnostic: BuiltinLintDiagnostics, ) { self.add_lint(lint, id, sp.into(), msg, diagnostic) @@ -655,18 +658,21 @@ macro_rules! declare_lint { macro_rules! declare_tool_lint { ( $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr + $(, @feature_gate = $gate:expr;)? ) => ( - $crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false} + $crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false $(, @feature_gate = $gate;)?} ); ( $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr, report_in_external_macro: $rep:expr + $(, @feature_gate = $gate:expr;)? ) => ( - $crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep} + $crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep $(, @feature_gate = $gate;)?} ); ( $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr, $external:expr + $(, @feature_gate = $gate:expr;)? ) => ( $(#[$attr])* $vis static $NAME: &$crate::Lint = &$crate::Lint { @@ -677,8 +683,9 @@ macro_rules! declare_tool_lint { report_in_external_macro: $external, future_incompatible: None, is_plugin: true, - feature_gate: None, + $(feature_gate: Some($gate),)? crate_level_only: false, + ..$crate::Lint::default_fields_for_macro() }; ); } |