19
19
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
20
20
21
21
use std:: borrow:: Cow ;
22
- use std:: sync:: Arc ;
23
22
use std:: { cmp, fmt} ;
24
23
25
24
pub use GenericArgs :: * ;
@@ -32,7 +31,7 @@ use rustc_data_structures::tagged_ptr::Tag;
32
31
use rustc_macros:: { Decodable , Encodable , HashStable_Generic } ;
33
32
pub use rustc_span:: AttrId ;
34
33
use rustc_span:: source_map:: { Spanned , respan} ;
35
- use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Ident , Span , Symbol , kw, sym} ;
34
+ use rustc_span:: { ByteSymbol , DUMMY_SP , ErrorGuaranteed , Ident , Span , Symbol , kw, sym} ;
36
35
use thin_vec:: { ThinVec , thin_vec} ;
37
36
38
37
pub use crate :: format:: * ;
@@ -1805,10 +1804,17 @@ pub enum ExprKind {
1805
1804
Become ( P < Expr > ) ,
1806
1805
1807
1806
/// Bytes included via `include_bytes!`
1807
+ ///
1808
1808
/// Added for optimization purposes to avoid the need to escape
1809
1809
/// large binary blobs - should always behave like [`ExprKind::Lit`]
1810
1810
/// with a `ByteStr` literal.
1811
- IncludedBytes ( Arc < [ u8 ] > ) ,
1811
+ ///
1812
+ /// The value is stored as a `ByteSymbol`. It's unfortunate that we need to
1813
+ /// intern (hash) the bytes because they're likely to be large and unique.
1814
+ /// But it's necessary because this will eventually be lowered to
1815
+ /// `LitKind::ByteStr`, which needs a `ByteSymbol` to impl `Copy` and avoid
1816
+ /// arena allocation.
1817
+ IncludedBytes ( ByteSymbol ) ,
1812
1818
1813
1819
/// A `format_args!()` expression.
1814
1820
FormatArgs ( P < FormatArgs > ) ,
@@ -2066,7 +2072,7 @@ impl YieldKind {
2066
2072
}
2067
2073
2068
2074
/// A literal in a meta item.
2069
- #[ derive( Clone , Encodable , Decodable , Debug , HashStable_Generic ) ]
2075
+ #[ derive( Clone , Copy , Encodable , Decodable , Debug , HashStable_Generic ) ]
2070
2076
pub struct MetaItemLit {
2071
2077
/// The original literal as written in the source code.
2072
2078
pub symbol : Symbol ,
@@ -2129,16 +2135,18 @@ pub enum LitFloatType {
2129
2135
/// deciding the `LitKind`. This means that float literals like `1f32` are
2130
2136
/// classified by this type as `Float`. This is different to `token::LitKind`
2131
2137
/// which does *not* consider the suffix.
2132
- #[ derive( Clone , Encodable , Decodable , Debug , Hash , Eq , PartialEq , HashStable_Generic ) ]
2138
+ #[ derive( Clone , Copy , Encodable , Decodable , Debug , Hash , Eq , PartialEq , HashStable_Generic ) ]
2133
2139
pub enum LitKind {
2134
2140
/// A string literal (`"foo"`). The symbol is unescaped, and so may differ
2135
2141
/// from the original token's symbol.
2136
2142
Str ( Symbol , StrStyle ) ,
2137
- /// A byte string (`b"foo"`). Not stored as a symbol because it might be
2138
- /// non-utf8, and symbols only allow utf8 strings.
2139
- ByteStr ( Arc < [ u8 ] > , StrStyle ) ,
2140
- /// A C String (`c"foo"`). Guaranteed to only have `\0` at the end.
2141
- CStr ( Arc < [ u8 ] > , StrStyle ) ,
2143
+ /// A byte string (`b"foo"`). The symbol is unescaped, and so may differ
2144
+ /// from the original token's symbol.
2145
+ ByteStr ( ByteSymbol , StrStyle ) ,
2146
+ /// A C String (`c"foo"`). Guaranteed to only have `\0` at the end. The
2147
+ /// symbol is unescaped, and so may differ from the original token's
2148
+ /// symbol.
2149
+ CStr ( ByteSymbol , StrStyle ) ,
2142
2150
/// A byte char (`b'f'`).
2143
2151
Byte ( u8 ) ,
2144
2152
/// A character literal (`'a'`).
@@ -2577,8 +2585,7 @@ pub enum TyPatKind {
2577
2585
pub enum TraitObjectSyntax {
2578
2586
// SAFETY: When adding new variants make sure to update the `Tag` impl.
2579
2587
Dyn = 0 ,
2580
- DynStar = 1 ,
2581
- None = 2 ,
2588
+ None = 1 ,
2582
2589
}
2583
2590
2584
2591
/// SAFETY: `TraitObjectSyntax` only has 3 data-less variants which means
@@ -2594,8 +2601,7 @@ unsafe impl Tag for TraitObjectSyntax {
2594
2601
unsafe fn from_usize ( tag : usize ) -> Self {
2595
2602
match tag {
2596
2603
0 => TraitObjectSyntax :: Dyn ,
2597
- 1 => TraitObjectSyntax :: DynStar ,
2598
- 2 => TraitObjectSyntax :: None ,
2604
+ 1 => TraitObjectSyntax :: None ,
2599
2605
_ => unreachable ! ( ) ,
2600
2606
}
2601
2607
}
0 commit comments