@@ -1422,6 +1422,33 @@ pub struct Lit {
1422
1422
pub span : Span ,
1423
1423
}
1424
1424
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
+
1425
1452
// Clippy uses Hash and PartialEq
1426
1453
/// Type of the integer literal based on provided suffix.
1427
1454
#[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug , Hash , PartialEq ) ]
@@ -2128,7 +2155,7 @@ pub struct Mod {
2128
2155
/// E.g., `extern { .. }` or `extern C { .. }`.
2129
2156
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
2130
2157
pub struct ForeignMod {
2131
- pub abi : Option < Abi > ,
2158
+ pub abi : Option < StrLit > ,
2132
2159
pub items : Vec < ForeignItem > ,
2133
2160
}
2134
2161
@@ -2411,25 +2438,16 @@ impl Item {
2411
2438
}
2412
2439
}
2413
2440
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
-
2423
2441
/// `extern` qualifier on a function item or function type.
2424
2442
#[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug ) ]
2425
2443
pub enum Extern {
2426
2444
None ,
2427
2445
Implicit ,
2428
- Explicit ( Abi ) ,
2446
+ Explicit ( StrLit ) ,
2429
2447
}
2430
2448
2431
2449
impl Extern {
2432
- pub fn from_abi ( abi : Option < Abi > ) -> Extern {
2450
+ pub fn from_abi ( abi : Option < StrLit > ) -> Extern {
2433
2451
match abi {
2434
2452
Some ( abi) => Extern :: Explicit ( abi) ,
2435
2453
None => Extern :: Implicit ,
0 commit comments