]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_session/lint.rs
Rollup merge of #67909 - varkor:obsolete-const-print, r=davidtwco
[rust.git] / src / librustc_session / lint.rs
index 0f1c91183bb688fcfd4c585bd4580aee72f4ce23..0cce7e848fd6066dafdc955254c471fc303f2bc5 100644 (file)
@@ -1,12 +1,16 @@
-use syntax_pos::{Symbol, sym};
-use syntax_pos::edition::Edition;
-use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
 pub use self::Level::*;
+use crate::node_id::NodeId;
+use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
+use rustc_span::edition::Edition;
+use rustc_span::{sym, MultiSpan, Symbol};
 
 /// Setting for how to handle a lint.
 #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
 pub enum Level {
-    Allow, Warn, Deny, Forbid,
+    Allow,
+    Warn,
+    Deny,
+    Forbid,
 }
 
 rustc_data_structures::impl_stable_hash_via_hash!(Level);
@@ -129,7 +133,7 @@ fn eq(&self, other: &LintId) -> bool {
     }
 }
 
-impl Eq for LintId { }
+impl Eq for LintId {}
 
 impl std::hash::Hash for LintId {
     fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
@@ -141,9 +145,7 @@ fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
 impl LintId {
     /// Gets the `LintId` for a `Lint`.
     pub fn of(lint: &'static Lint) -> LintId {
-        LintId {
-            lint,
-        }
+        LintId { lint }
     }
 
     pub fn lint_name_raw(&self) -> &'static str {
@@ -172,6 +174,21 @@ fn to_stable_hash_key(&self, _: &HCX) -> &'static str {
     }
 }
 
+/// Stores buffered lint info which can later be passed to `librustc`.
+pub struct BufferedEarlyLint {
+    /// The span of code that we are linting on.
+    pub span: MultiSpan,
+
+    /// The lint message.
+    pub msg: String,
+
+    /// The `NodeId` of the AST node that generated the lint.
+    pub id: NodeId,
+
+    /// A lint Id that can be passed to `rustc::lint::Lint::from_parser_lint_id`.
+    pub lint_id: &'static Lint,
+}
+
 /// Declares a static item of type `&'static Lint`.
 #[macro_export]
 macro_rules! declare_lint {