@@ -1422,6 +1422,33 @@ pub struct Lit {
14221422 pub span : Span ,
14231423}
14241424
1425+ /// Same as `Lit`, but restricted to string literals.
1426+ #[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug ) ]
1427+ pub struct StrLit {
1428+ /// The original literal token as written in source code.
1429+ pub style : StrStyle ,
1430+ pub symbol : Symbol ,
1431+ pub suffix : Option < Symbol > ,
1432+ pub span : Span ,
1433+ /// The unescaped "semantic" representation of the literal lowered from the original token.
1434+ /// FIXME: Remove this and only create the semantic representation during lowering to HIR.
1435+ pub symbol_unescaped : Symbol ,
1436+ }
1437+
1438+ impl StrLit {
1439+ crate fn as_lit ( & self ) -> Lit {
1440+ let token_kind = match self . style {
1441+ StrStyle :: Cooked => token:: Str ,
1442+ StrStyle :: Raw ( n) => token:: StrRaw ( n) ,
1443+ } ;
1444+ Lit {
1445+ token : token:: Lit :: new ( token_kind, self . symbol , self . suffix ) ,
1446+ span : self . span ,
1447+ kind : LitKind :: Str ( self . symbol_unescaped , self . style ) ,
1448+ }
1449+ }
1450+ }
1451+
14251452// Clippy uses Hash and PartialEq
14261453/// Type of the integer literal based on provided suffix.
14271454#[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug , Hash , PartialEq ) ]
@@ -2128,7 +2155,7 @@ pub struct Mod {
21282155/// E.g., `extern { .. }` or `extern C { .. }`.
21292156#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
21302157pub struct ForeignMod {
2131- pub abi : Option < Abi > ,
2158+ pub abi : Option < StrLit > ,
21322159 pub items : Vec < ForeignItem > ,
21332160}
21342161
@@ -2411,25 +2438,16 @@ impl Item {
24112438 }
24122439}
24132440
2414- /// A reference to an ABI.
2415- ///
2416- /// In AST our notion of an ABI is still syntactic unlike in `rustc_target::spec::abi::Abi`.
2417- #[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug , PartialEq ) ]
2418- pub struct Abi {
2419- pub symbol : Symbol ,
2420- pub span : Span ,
2421- }
2422-
24232441/// `extern` qualifier on a function item or function type.
24242442#[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug ) ]
24252443pub enum Extern {
24262444 None ,
24272445 Implicit ,
2428- Explicit ( Abi ) ,
2446+ Explicit ( StrLit ) ,
24292447}
24302448
24312449impl Extern {
2432- pub fn from_abi ( abi : Option < Abi > ) -> Extern {
2450+ pub fn from_abi ( abi : Option < StrLit > ) -> Extern {
24332451 match abi {
24342452 Some ( abi) => Extern :: Explicit ( abi) ,
24352453 None => Extern :: Implicit ,
0 commit comments