@@ -33,7 +33,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
3333use rustc_span:: source_map:: { respan, Spanned } ;
3434use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3535use rustc_span:: { Span , DUMMY_SP } ;
36- use std:: convert:: TryFrom ;
3736use std:: fmt;
3837use std:: mem;
3938use thin_vec:: { thin_vec, ThinVec } ;
@@ -1735,8 +1734,10 @@ pub enum StrStyle {
17351734/// A literal in a meta item.
17361735#[ derive( Clone , Encodable , Decodable , Debug , HashStable_Generic ) ]
17371736pub 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 > ,
17401741 /// The "semantic" representation of the literal lowered from the original tokens.
17411742 /// Strings are unescaped, hexadecimal forms are eliminated, etc.
17421743 pub kind : LitKind ,
@@ -1746,13 +1747,14 @@ pub struct MetaItemLit {
17461747/// Similar to `MetaItemLit`, but restricted to string literals.
17471748#[ derive( Clone , Copy , Encodable , Decodable , Debug ) ]
17481749pub 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.
17511751 pub symbol : Symbol ,
1752+ /// The original suffix as written in source code.
17521753 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.
17551755 pub symbol_unescaped : Symbol ,
1756+ pub style : StrStyle ,
1757+ pub span : Span ,
17561758}
17571759
17581760impl StrLit {
@@ -1798,8 +1800,9 @@ pub enum LitKind {
17981800 /// A string literal (`"foo"`). The symbol is unescaped, and so may differ
17991801 /// from the original token's symbol.
18001802 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 ) ,
18031806 /// A byte char (`b'f'`).
18041807 Byte ( u8 ) ,
18051808 /// A character literal (`'a'`).
@@ -1824,7 +1827,7 @@ impl LitKind {
18241827
18251828 /// Returns `true` if this literal is byte literal string.
18261829 pub fn is_bytestr ( & self ) -> bool {
1827- matches ! ( self , LitKind :: ByteStr ( _ ) )
1830+ matches ! ( self , LitKind :: ByteStr ( .. ) )
18281831 }
18291832
18301833 /// Returns `true` if this is a numeric literal.
@@ -2463,20 +2466,14 @@ pub enum ModKind {
24632466 Unloaded ,
24642467}
24652468
2466- #[ derive( Copy , Clone , Encodable , Decodable , Debug ) ]
2469+ #[ derive( Copy , Clone , Encodable , Decodable , Debug , Default ) ]
24672470pub struct ModSpans {
24682471 /// `inner_span` covers the body of the module; for a file module, its the whole file.
24692472 /// For an inline module, its the span inside the `{ ... }`, not including the curly braces.
24702473 pub inner_span : Span ,
24712474 pub inject_use_span : Span ,
24722475}
24732476
2474- impl Default for ModSpans {
2475- fn default ( ) -> ModSpans {
2476- ModSpans { inner_span : Default :: default ( ) , inject_use_span : Default :: default ( ) }
2477- }
2478- }
2479-
24802477/// Foreign module declaration.
24812478///
24822479/// E.g., `extern { .. }` or `extern "C" { .. }`.
@@ -3101,7 +3098,7 @@ mod size_asserts {
31013098 static_assert_size ! ( ItemKind , 112 ) ;
31023099 static_assert_size ! ( LitKind , 24 ) ;
31033100 static_assert_size ! ( Local , 72 ) ;
3104- static_assert_size ! ( MetaItemLit , 48 ) ;
3101+ static_assert_size ! ( MetaItemLit , 40 ) ;
31053102 static_assert_size ! ( Param , 40 ) ;
31063103 static_assert_size ! ( Pat , 88 ) ;
31073104 static_assert_size ! ( Path , 24 ) ;
0 commit comments