Skip to content

Commit 8eb4941

Browse files
committed
Implement 2015 vs 2018 ? kleene op + test
1 parent 2a7ae04 commit 8eb4941

22 files changed

+862
-465
lines changed

src/librustc/lint/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ macro_rules! declare_lint {
127127
};
128128
);
129129
($vis: vis $NAME: ident, $Level: ident, $desc: expr,
130-
$lint_edition: expr => $edition_level: ident $(,)?
130+
$lint_edition: expr => $edition_level: ident
131131
) => (
132132
$vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
133133
name: stringify!($NAME),
@@ -142,7 +142,8 @@ macro_rules! declare_lint {
142142
/// Declare a static `LintArray` and return it as an expression.
143143
#[macro_export]
144144
macro_rules! lint_array {
145-
($( $lint:expr ),* $(,)?) => {{
145+
($( $lint:expr ),* ,) => { lint_array!( $($lint),* ) };
146+
($( $lint:expr ),*) => {{
146147
vec![$($lint),*]
147148
}}
148149
}

src/librustc_lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ declare_lint! {
617617
pub ANONYMOUS_PARAMETERS,
618618
Allow,
619619
"detects anonymous parameters",
620-
Edition::Edition2018 => Warn,
620+
Edition::Edition2018 => Warn
621621
}
622622

623623
/// Checks for use of anonymous parameters (RFC 1685)
@@ -1706,7 +1706,7 @@ impl LintPass for SoftLints {
17061706
UNIONS_WITH_DROP_FIELDS,
17071707
UNREACHABLE_PUB,
17081708
TYPE_ALIAS_BOUNDS,
1709-
TRIVIAL_BOUNDS,
1709+
TRIVIAL_BOUNDS
17101710
)
17111711
}
17121712
}

src/libsyntax/ext/expand.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ macro_rules! ast_fragments {
4444
(
4545
$($Kind:ident($AstTy:ty) {
4646
$kind_name:expr;
47-
$(one fn $fold_ast:ident; fn $visit_ast:ident;)?
48-
$(many fn $fold_ast_elt:ident; fn $visit_ast_elt:ident;)?
47+
// FIXME: HACK: this should be `$(one ...)?` and `$(many ...)?` but `?` macro
48+
// repetition was removed from 2015 edition in #51587 because of ambiguities.
49+
$(one fn $fold_ast:ident; fn $visit_ast:ident;)*
50+
$(many fn $fold_ast_elt:ident; fn $visit_ast_elt:ident;)*
4951
fn $make_ast:ident;
5052
})*
5153
) => {
@@ -100,22 +102,22 @@ macro_rules! ast_fragments {
100102
AstFragment::OptExpr(expr) =>
101103
AstFragment::OptExpr(expr.and_then(|expr| folder.fold_opt_expr(expr))),
102104
$($(AstFragment::$Kind(ast) =>
103-
AstFragment::$Kind(folder.$fold_ast(ast)),)?)*
105+
AstFragment::$Kind(folder.$fold_ast(ast)),)*)*
104106
$($(AstFragment::$Kind(ast) =>
105107
AstFragment::$Kind(ast.into_iter()
106108
.flat_map(|ast| folder.$fold_ast_elt(ast))
107-
.collect()),)?)*
109+
.collect()),)*)*
108110
}
109111
}
110112

111113
pub fn visit_with<'a, V: Visitor<'a>>(&'a self, visitor: &mut V) {
112114
match *self {
113115
AstFragment::OptExpr(Some(ref expr)) => visitor.visit_expr(expr),
114116
AstFragment::OptExpr(None) => {}
115-
$($(AstFragment::$Kind(ref ast) => visitor.$visit_ast(ast),)?)*
117+
$($(AstFragment::$Kind(ref ast) => visitor.$visit_ast(ast),)*)*
116118
$($(AstFragment::$Kind(ref ast) => for ast_elt in &ast[..] {
117119
visitor.$visit_ast_elt(ast_elt);
118-
})?)*
120+
})*)*
119121
}
120122
}
121123
}
@@ -126,10 +128,10 @@ macro_rules! ast_fragments {
126128
}
127129
$($(fn $fold_ast(&mut self, ast: $AstTy) -> $AstTy {
128130
self.expand_fragment(AstFragment::$Kind(ast)).$make_ast()
129-
})?)*
131+
})*)*
130132
$($(fn $fold_ast_elt(&mut self, ast_elt: <$AstTy as IntoIterator>::Item) -> $AstTy {
131133
self.expand_fragment(AstFragment::$Kind(SmallVector::one(ast_elt))).$make_ast()
132-
})?)*
134+
})*)*
133135
}
134136

135137
impl<'a> MacResult for ::ext::tt::macro_rules::ParserAnyMacro<'a> {

0 commit comments

Comments
 (0)