diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-06-10 13:54:13 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-13 13:53:34 -0700 |
| commit | 2ed473487323bb4e5a600a3318e0981981214210 (patch) | |
| tree | a48635d0cac054e7045be8d0fbbd506f4f50b74e /src/libsyntax/ext/bytes.rs | |
| parent | e7f11f20e5e72a3b22863a9913df94303321a5ce (diff) | |
| download | rust-2ed473487323bb4e5a600a3318e0981981214210.tar.gz rust-2ed473487323bb4e5a600a3318e0981981214210.zip | |
librustc: Fix the issue with labels shadowing variable names by making
the leading quote part of the identifier for the purposes of hygiene. This adopts @jbclements' solution to #14539. I'm not sure if this is a breaking change or not. Closes #12512. [breaking-change]
Diffstat (limited to 'src/libsyntax/ext/bytes.rs')
| -rw-r--r-- | src/libsyntax/ext/bytes.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index b2088d2bc82..b87a25d4a44 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -94,6 +94,18 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } let e = cx.expr_vec_slice(sp, bytes); - let e = quote_expr!(cx, { static BYTES: &'static [u8] = $e; BYTES}); + let ty = cx.ty(sp, ast::TyVec(cx.ty_ident(sp, cx.ident_of("u8")))); + let lifetime = cx.lifetime(sp, cx.ident_of("'static").name); + let item = cx.item_static(sp, + cx.ident_of("BYTES"), + cx.ty_rptr(sp, + ty, + Some(lifetime), + ast::MutImmutable), + ast::MutImmutable, + e); + let e = cx.expr_block(cx.block(sp, + vec!(cx.stmt_item(sp, item)), + Some(cx.expr_ident(sp, cx.ident_of("BYTES"))))); MacExpr::new(e) } |
