diff options
| author | bors <bors@rust-lang.org> | 2018-04-18 14:44:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-18 14:44:54 +0000 |
| commit | 3dfda165259bf6beefab31bf8708bdf3ec505fe0 (patch) | |
| tree | fc39639749811c041d34696e7117d83dfc7642ed /src/libsyntax/ext | |
| parent | 65d201f7d682ad921ac6e67ac07f922aa63a8ce4 (diff) | |
| parent | 4d34bfd00a57f8a8bdb60ec3f908c5d4256f8a9a (diff) | |
| download | rust-3dfda165259bf6beefab31bf8708bdf3ec505fe0.tar.gz rust-3dfda165259bf6beefab31bf8708bdf3ec505fe0.zip | |
Auto merge of #49993 - nnethercote:shrink-Token, r=alexcrichton
Change the hashcounts in raw `Lit` variants from usize to u16. This reduces the size of `Token` from 32 bytes to 24 bytes on 64-bit platforms.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 36244f0a3c4..a9f48342243 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -139,6 +139,7 @@ pub trait AstBuilder { fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>; fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr>; fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>; + fn expr_u16(&self, sp: Span, u: u16) -> P<ast::Expr>; fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr>; fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>; @@ -708,6 +709,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U32))) } + fn expr_u16(&self, sp: Span, u: u16) -> P<ast::Expr> { + self.expr_lit(sp, ast::LitKind::Int(u as u128, + ast::LitIntType::Unsigned(ast::UintTy::U16))) + } fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> { self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U8))) } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 3303955d398..eeed291c0ca 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -623,7 +623,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> { ($name: expr, $suffix: expr, $content: expr $(, $count: expr)*) => {{ let name = mk_name(cx, sp, ast::Ident::with_empty_ctxt($content)); let inner = cx.expr_call(sp, mk_token_path(cx, sp, $name), vec![ - name $(, cx.expr_usize(sp, $count))* + name $(, cx.expr_u16(sp, $count))* ]); let suffix = match $suffix { Some(name) => cx.expr_some(sp, mk_name(cx, sp, ast::Ident::with_empty_ctxt(name))), |
