From 38f2526beb8bcd0a8501aecfe95a2f65841a1c7f Mon Sep 17 00:00:00 2001 From: James Deng Date: Tue, 4 Feb 2014 16:35:57 +1100 Subject: [PATCH 1/2] Feature gate all quasi-quoting macros. --- src/librustc/front/feature_gate.rs | 25 ++++++++++++++++--- src/librustc/lib.rs | 2 ++ src/libsyntax/lib.rs | 2 ++ src/test/auxiliary/macro_crate_test.rs | 2 +- src/test/compile-fail/qquote-1.rs | 1 + src/test/compile-fail/qquote-2.rs | 1 + src/test/run-pass-fulldeps/qquote.rs | 1 + src/test/run-pass-fulldeps/quote-tokens.rs | 2 +- .../quote-unused-sp-no-warning.rs | 2 +- 9 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index ed4455c2f89a1..ae6c6ec683123 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -49,6 +49,12 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("trace_macros", Active), ("simd", Active), ("default_type_params", Active), + ("quote_tokens", Active), + ("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 @@ -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 "e in quotes.iter() { + if id == self.sess.ident_of(quote) { + self.gate_feature(quote, path.span, quote + msg); + } + } } } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index c5f7d61c224a5..2d65fa0640eaa 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -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; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index e2aa9e3b3ee67..8f549d528bcfb 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -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)]; diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index e5bf8574366c8..8fe8d545374eb 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -10,7 +10,7 @@ // force-host -#[feature(globs, macro_registrar, macro_rules)]; +#[feature(globs, macro_registrar, macro_rules, quote_expr)]; extern mod syntax; diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index f55fcfc204b2f..7dd809137512a 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -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; diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index 262abc045a411..4ef5e41a3be66 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -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; diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 05225eb0e7ada..d1bf0abd0d021 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -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; diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index dc95faa198647..47bcb3e75750e 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -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; diff --git a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs index a8b7dc3d382f3..a7979d19389d5 100644 --- a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs +++ b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs @@ -10,7 +10,7 @@ // xfail-fast // xfail-android - +#[feature(quote_expr)]; #[deny(unused_variable)]; extern mod syntax; From 124938bcf5381bf6e686dfe5741d2d411574acac Mon Sep 17 00:00:00 2001 From: James Deng Date: Tue, 4 Feb 2014 22:03:00 +1100 Subject: [PATCH 2/2] Replaced with a single "quote" feature gate. --- src/librustc/front/feature_gate.rs | 9 ++------- src/librustc/lib.rs | 2 +- src/libsyntax/lib.rs | 4 ++-- src/test/auxiliary/macro_crate_test.rs | 2 +- src/test/compile-fail/qquote-1.rs | 2 +- src/test/compile-fail/qquote-2.rs | 2 +- src/test/run-pass-fulldeps/qquote.rs | 2 +- src/test/run-pass-fulldeps/quote-tokens.rs | 2 +- src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs | 2 +- 9 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index ae6c6ec683123..15056d9d2d842 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -49,12 +49,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("trace_macros", Active), ("simd", Active), ("default_type_params", Active), - ("quote_tokens", Active), - ("quote_expr", Active), - ("quote_ty", Active), - ("quote_item", Active), - ("quote_pat", Active), - ("quote_stmt", Active), + ("quote", Active), // These are used to test this portion of the compiler, they don't actually // mean anything @@ -221,7 +216,7 @@ impl Visitor<()> for Context { } else { for "e in quotes.iter() { if id == self.sess.ident_of(quote) { - self.gate_feature(quote, path.span, quote + msg); + self.gate_feature("quote", path.span, quote + msg); } } } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 2d65fa0640eaa..f80b30126f853 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -29,7 +29,7 @@ This API is completely unstable and subject to change. #[feature(macro_rules, globs, struct_variant, managed_boxes)]; #[allow(unknown_features)]; // Note: remove it after a snapshot. -#[feature(quote_item, quote_expr)]; +#[feature(quote)]; extern mod extra; extern mod flate; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 8f549d528bcfb..a61c354e7cd38 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -27,8 +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)]; +#[allow(unknown_features)];// Note: remove it after a snapshot. +#[feature(quote)]; #[deny(non_camel_case_types)]; diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 8fe8d545374eb..2867e0f814306 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -10,7 +10,7 @@ // force-host -#[feature(globs, macro_registrar, macro_rules, quote_expr)]; +#[feature(globs, macro_registrar, macro_rules, quote)]; extern mod syntax; diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index 7dd809137512a..6dcbf3df9d653 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test Can't use syntax crate here -#[feature(quote_expr)]; +#[feature(quote)]; extern mod extra; extern mod syntax; diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index 4ef5e41a3be66..0e5c852fd6ecb 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test Can't use syntax crate here -#[feature(quote_stmt)]; +#[feature(quote)]; extern mod extra; extern mod syntax; diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index d1bf0abd0d021..dc67ff21585dc 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -10,7 +10,7 @@ // xfail-pretty // xfail-test -#[feature(quote_expr, quote_ty, quote_item, quote_stmt, quote_pat)]; +#[feature(quote)]; extern mod extra; extern mod syntax; diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index 47bcb3e75750e..7429ac45904cc 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -#[feature(quote_expr, quote_tokens, quote_item, quote_pat, quote_stmt)]; +#[feature(quote)]; #[feature(managed_boxes)]; extern mod syntax; diff --git a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs index a7979d19389d5..0411c0b1cea3f 100644 --- a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs +++ b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs @@ -10,7 +10,7 @@ // xfail-fast // xfail-android -#[feature(quote_expr)]; +#[feature(quote)]; #[deny(unused_variable)]; extern mod syntax;