diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-15 23:49:55 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-16 01:36:06 +0100 |
| commit | dc0797c0c99e7079170d0e09f82fc6f66b721932 (patch) | |
| tree | 5b0e828bc786427580c67ade6f7a26f1390997a3 /src/libsyntax/feature_gate.rs | |
| parent | 52bdda778ad595e661d06b16a193b3affe443d41 (diff) | |
| download | rust-dc0797c0c99e7079170d0e09f82fc6f66b721932.tar.gz rust-dc0797c0c99e7079170d0e09f82fc6f66b721932.zip | |
Address the other cases of #22234; fix #22234.
The other cases: `concat_idents!`, `log_syntax!`, and `trace_macros!`, (these macros, with `asm!`, are handled (eagerly) in feature_gate.rs).
Diffstat (limited to 'src/libsyntax/feature_gate.rs')
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9d14f894a46..5e29f3a6b69 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -158,6 +158,9 @@ pub struct Features { pub visible_private_types: bool, pub allow_quote: bool, pub allow_asm: bool, + pub allow_log_syntax: bool, + pub allow_concat_idents: bool, + pub allow_trace_macros: bool, pub old_orphan_check: bool, pub simd_ffi: bool, pub unmarked_api: bool, @@ -175,6 +178,9 @@ impl Features { visible_private_types: false, allow_quote: false, allow_asm: false, + allow_log_syntax: false, + allow_concat_idents: false, + allow_trace_macros: false, old_orphan_check: false, simd_ffi: false, unmarked_api: false, @@ -226,6 +232,15 @@ pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain: pub const EXPLAIN_ASM: &'static str = "inline assembly is not stable enough for use and is subject to change"; +pub const EXPLAIN_LOG_SYNTAX: &'static str = + "`log_syntax!` is not stable enough for use and is subject to change"; + +pub const EXPLAIN_CONCAT_IDENTS: &'static str = + "`concat_idents` is not stable enough for use and is subject to change"; + +pub const EXPLAIN_TRACE_MACROS: &'static str = + "`trace_macros` is not stable enough for use and is subject to change"; + struct MacroVisitor<'a> { context: &'a Context<'a> } @@ -235,23 +250,28 @@ impl<'a, 'v> Visitor<'v> for MacroVisitor<'a> { let ast::MacInvocTT(ref path, _, _) = mac.node; let id = path.segments.last().unwrap().identifier; + // Issue 22234: If you add a new case here, make sure to also + // add code to catch the macro during or after expansion. + // + // We still keep this MacroVisitor (rather than *solely* + // relying on catching cases during or after expansion) to + // catch uses of these macros within conditionally-compiled + // code, e.g. `#[cfg]`-guarded functions. + if id == token::str_to_ident("asm") { self.context.gate_feature("asm", path.span, EXPLAIN_ASM); } else if id == token::str_to_ident("log_syntax") { - self.context.gate_feature("log_syntax", path.span, "`log_syntax!` is not \ - stable enough for use and is subject to change"); + self.context.gate_feature("log_syntax", path.span, EXPLAIN_LOG_SYNTAX); } else if id == token::str_to_ident("trace_macros") { - self.context.gate_feature("trace_macros", path.span, "`trace_macros` is not \ - stable enough for use and is subject to change"); + self.context.gate_feature("trace_macros", path.span, EXPLAIN_TRACE_MACROS); } else if id == token::str_to_ident("concat_idents") { - self.context.gate_feature("concat_idents", path.span, "`concat_idents` is not \ - stable enough for use and is subject to change"); + self.context.gate_feature("concat_idents", path.span, EXPLAIN_CONCAT_IDENTS); } } } @@ -594,12 +614,18 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C check(&mut cx, krate); + // FIXME (pnkfelix): Before adding the 99th entry below, change it + // to a single-pass (instead of N calls to `.has_feature`). + Features { unboxed_closures: cx.has_feature("unboxed_closures"), rustc_diagnostic_macros: cx.has_feature("rustc_diagnostic_macros"), visible_private_types: cx.has_feature("visible_private_types"), allow_quote: cx.has_feature("quote"), allow_asm: cx.has_feature("asm"), + allow_log_syntax: cx.has_feature("log_syntax"), + allow_concat_idents: cx.has_feature("concat_idents"), + allow_trace_macros: cx.has_feature("trace_macros"), old_orphan_check: cx.has_feature("old_orphan_check"), simd_ffi: cx.has_feature("simd_ffi"), unmarked_api: cx.has_feature("unmarked_api"), |
