Skip to content

Feature gate all quasi-quoting macros. #12025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/librustc/front/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("trace_macros", Active),
("simd", Active),
("default_type_params", Active),
("quote_tokens", Active),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these could all be covered by the same gate (e.g. called quote)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I didn't think about it. It seems that there was only one "quote" macro, but later split to multiple ones.
I am not sure if there is a gain to keep them separate in feature gate as well.
If not, I am happy to replace with a single gate, that is simpler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes to the single, simple quote feature gate.

("quote_expr", Active),
("quote_ty", Active),
("quote_item", Active),
("quote_pat", Active),
("quote_stmt", Active),

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

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

if path.segments.last().unwrap().identifier == self.sess.ident_of("macro_rules") {

if id == self.sess.ident_of("macro_rules") {
self.gate_feature("macro_rules", path.span, "macro definitions are \
not stable enough for use and are subject to change");
}

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

else if path.segments.last().unwrap().identifier == self.sess.ident_of("log_syntax") {
else if id == self.sess.ident_of("log_syntax") {
self.gate_feature("log_syntax", path.span, "`log_syntax!` is not \
stable enough for use and is subject to change");
}
else if path.segments.last().unwrap().identifier == self.sess.ident_of("trace_macros") {
else if id == self.sess.ident_of("trace_macros") {
self.gate_feature("trace_macros", path.span, "`trace_macros` is not \
stable enough for use and is subject to change");
} else {
for &quote in quotes.iter() {
if id == self.sess.ident_of(quote) {
self.gate_feature(quote, path.span, quote + msg);
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This API is completely unstable and subject to change.
html_root_url = "http://static.rust-lang.org/doc/master")];

#[feature(macro_rules, globs, struct_variant, managed_boxes)];
#[allow(unknown_features)]; // Note: remove it after a snapshot.
#[feature(quote_item, quote_expr)];

extern mod extra;
extern mod flate;
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ This API is completely unstable and subject to change.
html_root_url = "http://static.rust-lang.org/doc/master")];

#[feature(macro_rules, globs, managed_boxes)];
#[allow(unknown_features)];
#[feature(quote_expr)];

#[deny(non_camel_case_types)];

Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/macro_crate_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// force-host

#[feature(globs, macro_registrar, macro_rules)];
#[feature(globs, macro_registrar, macro_rules, quote_expr)];

extern mod syntax;

Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/qquote-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// xfail-test Can't use syntax crate here
#[feature(quote_expr)];

extern mod extra;
extern mod syntax;
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/qquote-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// xfail-test Can't use syntax crate here
#[feature(quote_stmt)];

extern mod extra;
extern mod syntax;
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass-fulldeps/qquote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// xfail-pretty
// xfail-test
#[feature(quote_expr, quote_ty, quote_item, quote_stmt, quote_pat)];

extern mod extra;
extern mod syntax;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/quote-tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

// xfail-test

#[feature(quote_expr, quote_tokens, quote_item, quote_pat, quote_stmt)];
#[feature(managed_boxes)];

extern mod syntax;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// xfail-fast
// xfail-android

#[feature(quote_expr)];
#[deny(unused_variable)];

extern mod syntax;
Expand Down