Skip to content

Commit 53864ce

Browse files
committed
auto merge of #12025 : lilac/rust/feature-gate-quote, r=brson
Closes #11630.
2 parents 1bcc73f + 124938b commit 53864ce

File tree

9 files changed

+26
-7
lines changed

9 files changed

+26
-7
lines changed

src/librustc/front/feature_gate.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
4949
("trace_macros", Active),
5050
("simd", Active),
5151
("default_type_params", Active),
52+
("quote", Active),
5253

5354
// These are used to test this portion of the compiler, they don't actually
5455
// mean anything
@@ -189,24 +190,35 @@ impl Visitor<()> for Context {
189190

190191
fn visit_mac(&mut self, macro: &ast::Mac, _: ()) {
191192
let ast::MacInvocTT(ref path, _, _) = macro.node;
193+
let id = path.segments.last().unwrap().identifier;
194+
let quotes = ["quote_tokens", "quote_expr", "quote_ty",
195+
"quote_item", "quote_pat", "quote_stmt"];
196+
let msg = " is not stable enough for use and are subject to change";
192197

193-
if path.segments.last().unwrap().identifier == self.sess.ident_of("macro_rules") {
198+
199+
if id == self.sess.ident_of("macro_rules") {
194200
self.gate_feature("macro_rules", path.span, "macro definitions are \
195201
not stable enough for use and are subject to change");
196202
}
197203

198-
else if path.segments.last().unwrap().identifier == self.sess.ident_of("asm") {
204+
else if id == self.sess.ident_of("asm") {
199205
self.gate_feature("asm", path.span, "inline assembly is not \
200206
stable enough for use and is subject to change");
201207
}
202208

203-
else if path.segments.last().unwrap().identifier == self.sess.ident_of("log_syntax") {
209+
else if id == self.sess.ident_of("log_syntax") {
204210
self.gate_feature("log_syntax", path.span, "`log_syntax!` is not \
205211
stable enough for use and is subject to change");
206212
}
207-
else if path.segments.last().unwrap().identifier == self.sess.ident_of("trace_macros") {
213+
else if id == self.sess.ident_of("trace_macros") {
208214
self.gate_feature("trace_macros", path.span, "`trace_macros` is not \
209215
stable enough for use and is subject to change");
216+
} else {
217+
for &quote in quotes.iter() {
218+
if id == self.sess.ident_of(quote) {
219+
self.gate_feature("quote", path.span, quote + msg);
220+
}
221+
}
210222
}
211223
}
212224

src/librustc/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ This API is completely unstable and subject to change.
2828
html_root_url = "http://static.rust-lang.org/doc/master")];
2929

3030
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
31+
#[allow(unknown_features)]; // Note: remove it after a snapshot.
32+
#[feature(quote)];
3133

3234
extern mod extra;
3335
extern mod flate;

src/libsyntax/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ This API is completely unstable and subject to change.
2727
html_root_url = "http://static.rust-lang.org/doc/master")];
2828

2929
#[feature(macro_rules, globs, managed_boxes)];
30+
#[allow(unknown_features)];// Note: remove it after a snapshot.
31+
#[feature(quote)];
3032

3133
#[deny(non_camel_case_types)];
3234

src/test/auxiliary/macro_crate_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// force-host
1212

13-
#[feature(globs, macro_registrar, macro_rules)];
13+
#[feature(globs, macro_registrar, macro_rules, quote)];
1414

1515
extern mod syntax;
1616

src/test/compile-fail/qquote-1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// xfail-test Can't use syntax crate here
12+
#[feature(quote)];
1213

1314
extern mod extra;
1415
extern mod syntax;

src/test/compile-fail/qquote-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// xfail-test Can't use syntax crate here
12+
#[feature(quote)];
1213

1314
extern mod extra;
1415
extern mod syntax;

src/test/run-pass-fulldeps/qquote.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// xfail-pretty
1212
// xfail-test
13+
#[feature(quote)];
1314

1415
extern mod extra;
1516
extern mod syntax;

src/test/run-pass-fulldeps/quote-tokens.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// xfail-test
12-
12+
#[feature(quote)];
1313
#[feature(managed_boxes)];
1414

1515
extern mod syntax;

src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// xfail-fast
1212
// xfail-android
13-
13+
#[feature(quote)];
1414
#[deny(unused_variable)];
1515

1616
extern mod syntax;

0 commit comments

Comments
 (0)