@@ -33,7 +33,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
33
33
use rustc_span:: source_map:: { respan, Spanned } ;
34
34
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
35
35
use rustc_span:: { Span , DUMMY_SP } ;
36
- use std:: convert:: TryFrom ;
37
36
use std:: fmt;
38
37
use std:: mem;
39
38
use thin_vec:: { thin_vec, ThinVec } ;
@@ -1735,8 +1734,10 @@ pub enum StrStyle {
1735
1734
/// A literal in a meta item.
1736
1735
#[ derive( Clone , Encodable , Decodable , Debug , HashStable_Generic ) ]
1737
1736
pub struct MetaItemLit {
1738
- /// The original literal token as written in source code.
1739
- pub token_lit : token:: Lit ,
1737
+ /// The original literal as written in the source code.
1738
+ pub symbol : Symbol ,
1739
+ /// The original suffix as written in the source code.
1740
+ pub suffix : Option < Symbol > ,
1740
1741
/// The "semantic" representation of the literal lowered from the original tokens.
1741
1742
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
1742
1743
pub kind : LitKind ,
@@ -1746,13 +1747,14 @@ pub struct MetaItemLit {
1746
1747
/// Similar to `MetaItemLit`, but restricted to string literals.
1747
1748
#[ derive( Clone , Copy , Encodable , Decodable , Debug ) ]
1748
1749
pub struct StrLit {
1749
- /// The original literal token as written in source code.
1750
- pub style : StrStyle ,
1750
+ /// The original literal as written in source code.
1751
1751
pub symbol : Symbol ,
1752
+ /// The original suffix as written in source code.
1752
1753
pub suffix : Option < Symbol > ,
1753
- pub span : Span ,
1754
- /// The unescaped "semantic" representation of the literal lowered from the original token.
1754
+ /// The semantic (unescaped) representation of the literal.
1755
1755
pub symbol_unescaped : Symbol ,
1756
+ pub style : StrStyle ,
1757
+ pub span : Span ,
1756
1758
}
1757
1759
1758
1760
impl StrLit {
@@ -1798,8 +1800,9 @@ pub enum LitKind {
1798
1800
/// A string literal (`"foo"`). The symbol is unescaped, and so may differ
1799
1801
/// from the original token's symbol.
1800
1802
Str ( Symbol , StrStyle ) ,
1801
- /// A byte string (`b"foo"`).
1802
- ByteStr ( Lrc < [ u8 ] > ) ,
1803
+ /// A byte string (`b"foo"`). Not stored as a symbol because it might be
1804
+ /// non-utf8, and symbols only allow utf8 strings.
1805
+ ByteStr ( Lrc < [ u8 ] > , StrStyle ) ,
1803
1806
/// A byte char (`b'f'`).
1804
1807
Byte ( u8 ) ,
1805
1808
/// A character literal (`'a'`).
@@ -1824,7 +1827,7 @@ impl LitKind {
1824
1827
1825
1828
/// Returns `true` if this literal is byte literal string.
1826
1829
pub fn is_bytestr ( & self ) -> bool {
1827
- matches ! ( self , LitKind :: ByteStr ( _ ) )
1830
+ matches ! ( self , LitKind :: ByteStr ( .. ) )
1828
1831
}
1829
1832
1830
1833
/// Returns `true` if this is a numeric literal.
@@ -2463,20 +2466,14 @@ pub enum ModKind {
2463
2466
Unloaded ,
2464
2467
}
2465
2468
2466
- #[ derive( Copy , Clone , Encodable , Decodable , Debug ) ]
2469
+ #[ derive( Copy , Clone , Encodable , Decodable , Debug , Default ) ]
2467
2470
pub struct ModSpans {
2468
2471
/// `inner_span` covers the body of the module; for a file module, its the whole file.
2469
2472
/// For an inline module, its the span inside the `{ ... }`, not including the curly braces.
2470
2473
pub inner_span : Span ,
2471
2474
pub inject_use_span : Span ,
2472
2475
}
2473
2476
2474
- impl Default for ModSpans {
2475
- fn default ( ) -> ModSpans {
2476
- ModSpans { inner_span : Default :: default ( ) , inject_use_span : Default :: default ( ) }
2477
- }
2478
- }
2479
-
2480
2477
/// Foreign module declaration.
2481
2478
///
2482
2479
/// E.g., `extern { .. }` or `extern "C" { .. }`.
@@ -3101,7 +3098,7 @@ mod size_asserts {
3101
3098
static_assert_size ! ( ItemKind , 112 ) ;
3102
3099
static_assert_size ! ( LitKind , 24 ) ;
3103
3100
static_assert_size ! ( Local , 72 ) ;
3104
- static_assert_size ! ( MetaItemLit , 48 ) ;
3101
+ static_assert_size ! ( MetaItemLit , 40 ) ;
3105
3102
static_assert_size ! ( Param , 40 ) ;
3106
3103
static_assert_size ! ( Pat , 88 ) ;
3107
3104
static_assert_size ! ( Path , 24 ) ;
0 commit comments