1919//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
2121use std:: borrow:: Cow ;
22- use std:: sync:: Arc ;
2322use std:: { cmp, fmt} ;
2423
2524pub use GenericArgs :: * ;
@@ -32,7 +31,7 @@ use rustc_data_structures::tagged_ptr::Tag;
3231use rustc_macros:: { Decodable , Encodable , HashStable_Generic } ;
3332pub use rustc_span:: AttrId ;
3433use 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} ;
3635use thin_vec:: { ThinVec , thin_vec} ;
3736
3837pub use crate :: format:: * ;
@@ -1805,10 +1804,17 @@ pub enum ExprKind {
18051804 Become ( P < Expr > ) ,
18061805
18071806 /// Bytes included via `include_bytes!`
1807+ ///
18081808 /// Added for optimization purposes to avoid the need to escape
18091809 /// large binary blobs - should always behave like [`ExprKind::Lit`]
18101810 /// 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 ) ,
18121818
18131819 /// A `format_args!()` expression.
18141820 FormatArgs ( P < FormatArgs > ) ,
@@ -2066,7 +2072,7 @@ impl YieldKind {
20662072}
20672073
20682074/// A literal in a meta item.
2069- #[ derive( Clone , Encodable , Decodable , Debug , HashStable_Generic ) ]
2075+ #[ derive( Clone , Copy , Encodable , Decodable , Debug , HashStable_Generic ) ]
20702076pub struct MetaItemLit {
20712077 /// The original literal as written in the source code.
20722078 pub symbol : Symbol ,
@@ -2129,16 +2135,18 @@ pub enum LitFloatType {
21292135/// deciding the `LitKind`. This means that float literals like `1f32` are
21302136/// classified by this type as `Float`. This is different to `token::LitKind`
21312137/// 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 ) ]
21332139pub enum LitKind {
21342140 /// A string literal (`"foo"`). The symbol is unescaped, and so may differ
21352141 /// from the original token's symbol.
21362142 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 ) ,
21422150 /// A byte char (`b'f'`).
21432151 Byte ( u8 ) ,
21442152 /// A character literal (`'a'`).
@@ -2577,8 +2585,7 @@ pub enum TyPatKind {
25772585pub enum TraitObjectSyntax {
25782586 // SAFETY: When adding new variants make sure to update the `Tag` impl.
25792587 Dyn = 0 ,
2580- DynStar = 1 ,
2581- None = 2 ,
2588+ None = 1 ,
25822589}
25832590
25842591/// SAFETY: `TraitObjectSyntax` only has 3 data-less variants which means
@@ -2594,8 +2601,7 @@ unsafe impl Tag for TraitObjectSyntax {
25942601 unsafe fn from_usize ( tag : usize ) -> Self {
25952602 match tag {
25962603 0 => TraitObjectSyntax :: Dyn ,
2597- 1 => TraitObjectSyntax :: DynStar ,
2598- 2 => TraitObjectSyntax :: None ,
2604+ 1 => TraitObjectSyntax :: None ,
25992605 _ => unreachable ! ( ) ,
26002606 }
26012607 }
0 commit comments