From f03d8f305a80778ae034b0205803ea3edc297ac8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 12 Nov 2019 12:09:20 -0500 Subject: Move early lint declarations to librustc_session --- src/libsyntax/Cargo.toml | 1 + src/libsyntax/early_buffered_lints.rs | 31 ++++++++++++++++++++++++------- src/libsyntax/sess.rs | 4 ++-- 3 files changed, 27 insertions(+), 9 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index 085c1760c80..8a00bcbfe17 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -24,3 +24,4 @@ rustc_lexer = { path = "../librustc_lexer" } rustc_macros = { path = "../librustc_macros" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_error_codes = { path = "../librustc_error_codes" } +rustc_session = { path = "../librustc_session" } diff --git a/src/libsyntax/early_buffered_lints.rs b/src/libsyntax/early_buffered_lints.rs index 5cc953b9066..e6b86a0f4fb 100644 --- a/src/libsyntax/early_buffered_lints.rs +++ b/src/libsyntax/early_buffered_lints.rs @@ -5,13 +5,30 @@ use crate::ast::NodeId; use syntax_pos::MultiSpan; +use rustc_session::lint::FutureIncompatibleInfo; +use rustc_session::declare_lint; +pub use rustc_session::lint::BufferedEarlyLint; -/// Since we cannot import `LintId`s from `rustc::lint`, we define some Ids here which can later be -/// passed to `rustc::lint::Lint::from_parser_lint_id` to get a `rustc::lint::Lint`. -pub enum BufferedEarlyLintId { - IllFormedAttributeInput, - MetaVariableMisuse, - IncompleteInclude, +declare_lint! { + pub ILL_FORMED_ATTRIBUTE_INPUT, + Deny, + "ill-formed attribute inputs that were previously accepted and used in practice", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #57571 ", + edition: None, + }; +} + +declare_lint! { + pub META_VARIABLE_MISUSE, + Allow, + "possible meta-variable misuse at macro definition" +} + +declare_lint! { + pub INCOMPLETE_INCLUDE, + Deny, + "trailing content in included file" } /// Stores buffered lint info which can later be passed to `librustc`. @@ -26,5 +43,5 @@ pub struct BufferedEarlyLint { pub id: NodeId, /// A lint Id that can be passed to `rustc::lint::Lint::from_parser_lint_id`. - pub lint_id: BufferedEarlyLintId, + pub lint_id: &'static rustc_session::lint::Lint, } diff --git a/src/libsyntax/sess.rs b/src/libsyntax/sess.rs index aa9217c1b69..555e8a134f7 100644 --- a/src/libsyntax/sess.rs +++ b/src/libsyntax/sess.rs @@ -2,7 +2,7 @@ //! It also serves as an input to the parser itself. use crate::ast::{CrateConfig, NodeId}; -use crate::early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; +use crate::early_buffered_lints::BufferedEarlyLint; use errors::{Applicability, emitter::SilentEmitter, Handler, ColorConfig, DiagnosticBuilder}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; @@ -137,7 +137,7 @@ impl ParseSess { pub fn buffer_lint( &self, - lint_id: BufferedEarlyLintId, + lint_id: &'static rustc_session::lint::Lint, span: impl Into, id: NodeId, msg: &str, -- cgit 1.4.1-3-g733a5