Skip to content

Commit

Permalink
Implement checks for meta-variables in macros
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Jun 29, 2019
1 parent e446a56 commit 98a6587
Show file tree
Hide file tree
Showing 16 changed files with 907 additions and 47 deletions.
7 changes: 7 additions & 0 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ pub mod parser {
Warn,
"ill-formed attribute inputs that were previously accepted and used in practice"
}

declare_lint! {
pub META_VARIABLE_MISUSE,
Allow,
"possible meta-variable misuse at macro definition"
}
}

declare_lint! {
Expand Down Expand Up @@ -439,6 +445,7 @@ declare_lint_pass! {
MACRO_USE_EXTERN_CRATE,
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
parser::ILL_FORMED_ATTRIBUTE_INPUT,
parser::META_VARIABLE_MISUSE,
DEPRECATED_IN_FUTURE,
AMBIGUOUS_ASSOCIATED_ITEMS,
NESTED_IMPL_TRAIT,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::hir::def_id::{CrateNum, LOCAL_CRATE};
use crate::hir::intravisit;
use crate::hir;
use crate::lint::builtin::BuiltinLintDiagnostics;
use crate::lint::builtin::parser::ILL_FORMED_ATTRIBUTE_INPUT;
use crate::lint::builtin::parser::{ILL_FORMED_ATTRIBUTE_INPUT, META_VARIABLE_MISUSE};
use crate::session::{Session, DiagnosticMessageId};
use crate::ty::TyCtxt;
use crate::ty::query::Providers;
Expand Down Expand Up @@ -81,6 +81,7 @@ impl Lint {
pub fn from_parser_lint_id(lint_id: BufferedEarlyLintId) -> &'static Self {
match lint_id {
BufferedEarlyLintId::IllFormedAttributeInput => ILL_FORMED_ATTRIBUTE_INPUT,
BufferedEarlyLintId::MetaVariableMisuse => META_VARIABLE_MISUSE,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/early_buffered_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use syntax_pos::MultiSpan;
/// passed to `rustc::lint::Lint::from_parser_lint_id` to get a `rustc::lint::Lint`.
pub enum BufferedEarlyLintId {
IllFormedAttributeInput,
MetaVariableMisuse,
}

/// Stores buffered lint info which can later be passed to `librustc`.
Expand Down
Loading

0 comments on commit 98a6587

Please sign in to comment.