Skip to content

Commit 8959e7f

Browse files
authored
Merge branch 'master' into more-addrspace
2 parents afec259 + f51c987 commit 8959e7f

File tree

834 files changed

+8987
-7837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

834 files changed

+8987
-7837
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ Xinye Tao <[email protected]>
690690
Xuefeng Wu <[email protected]> Xuefeng Wu <[email protected]>
691691
Xuefeng Wu <[email protected]> XuefengWu <[email protected]>
692692
York Xiang <[email protected]>
693+
693694
694695
Youngsuk Kim <[email protected]>
695696
Yuki Okushi <[email protected]>

Cargo.lock

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version = "0.24.2"
88
source = "registry+https://github.com/rust-lang/crates.io-index"
99
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
1010
dependencies = [
11-
"gimli",
11+
"gimli 0.31.1",
1212
]
1313

1414
[[package]]
@@ -1483,6 +1483,17 @@ dependencies = [
14831483
"stable_deref_trait",
14841484
]
14851485

1486+
[[package]]
1487+
name = "gimli"
1488+
version = "0.32.0"
1489+
source = "registry+https://github.com/rust-lang/crates.io-index"
1490+
checksum = "93563d740bc9ef04104f9ed6f86f1e3275c2cdafb95664e26584b9ca807a8ffe"
1491+
dependencies = [
1492+
"fallible-iterator",
1493+
"indexmap",
1494+
"stable_deref_trait",
1495+
]
1496+
14861497
[[package]]
14871498
name = "glob"
14881499
version = "0.3.2"
@@ -2568,7 +2579,7 @@ dependencies = [
25682579
"hashbrown",
25692580
"indexmap",
25702581
"memchr",
2571-
"ruzstd",
2582+
"ruzstd 0.7.3",
25722583
]
25732584

25742585
[[package]]
@@ -2578,9 +2589,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
25782589
checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a"
25792590
dependencies = [
25802591
"crc32fast",
2592+
"flate2",
25812593
"hashbrown",
25822594
"indexmap",
25832595
"memchr",
2596+
"ruzstd 0.8.1",
25842597
"wasmparser 0.234.0",
25852598
]
25862599

@@ -3194,9 +3207,9 @@ version = "0.2.0"
31943207
dependencies = [
31953208
"bstr",
31963209
"build_helper",
3197-
"gimli",
3210+
"gimli 0.32.0",
31983211
"libc",
3199-
"object 0.36.7",
3212+
"object 0.37.1",
32003213
"regex",
32013214
"serde_json",
32023215
"similar",
@@ -3498,7 +3511,7 @@ name = "rustc_codegen_llvm"
34983511
version = "0.0.0"
34993512
dependencies = [
35003513
"bitflags",
3501-
"gimli",
3514+
"gimli 0.31.1",
35023515
"itertools",
35033516
"libc",
35043517
"measureme",
@@ -4473,7 +4486,7 @@ dependencies = [
44734486
"rustc_target",
44744487
"rustc_trait_selection",
44754488
"tracing",
4476-
"twox-hash",
4489+
"twox-hash 1.6.3",
44774490
]
44784491

44794492
[[package]]
@@ -4857,7 +4870,16 @@ version = "0.7.3"
48574870
source = "registry+https://github.com/rust-lang/crates.io-index"
48584871
checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f"
48594872
dependencies = [
4860-
"twox-hash",
4873+
"twox-hash 1.6.3",
4874+
]
4875+
4876+
[[package]]
4877+
name = "ruzstd"
4878+
version = "0.8.1"
4879+
source = "registry+https://github.com/rust-lang/crates.io-index"
4880+
checksum = "3640bec8aad418d7d03c72ea2de10d5c646a598f9883c7babc160d91e3c1b26c"
4881+
dependencies = [
4882+
"twox-hash 2.1.1",
48614883
]
48624884

48634885
[[package]]
@@ -5338,7 +5360,7 @@ version = "0.9.0"
53385360
source = "registry+https://github.com/rust-lang/crates.io-index"
53395361
checksum = "9e9c1e705f82a260173f3eec93f2ff6d7807f23ad5a8cc2e7316a891733ea7a1"
53405362
dependencies = [
5341-
"gimli",
5363+
"gimli 0.31.1",
53425364
"hashbrown",
53435365
"object 0.36.7",
53445366
"tracing",
@@ -5580,6 +5602,12 @@ dependencies = [
55805602
"static_assertions",
55815603
]
55825604

5605+
[[package]]
5606+
name = "twox-hash"
5607+
version = "2.1.1"
5608+
source = "registry+https://github.com/rust-lang/crates.io-index"
5609+
checksum = "8b907da542cbced5261bd3256de1b3a1bf340a3d37f93425a07362a1d687de56"
5610+
55835611
[[package]]
55845612
name = "type-map"
55855613
version = "0.5.1"

compiler/rustc_ast/src/ast.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
2121
use std::borrow::Cow;
22-
use std::sync::Arc;
2322
use std::{cmp, fmt};
2423

2524
pub use GenericArgs::*;
@@ -32,7 +31,7 @@ use rustc_data_structures::tagged_ptr::Tag;
3231
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3332
pub use rustc_span::AttrId;
3433
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};
3635
use thin_vec::{ThinVec, thin_vec};
3736

3837
pub 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)]
20702076
pub 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)]
21332139
pub 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 {
25772585
pub 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
}

compiler/rustc_ast/src/util/literal.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{ascii, fmt, str};
55
use rustc_literal_escaper::{
66
MixedUnit, unescape_byte, unescape_byte_str, unescape_c_str, unescape_char, unescape_str,
77
};
8-
use rustc_span::{Span, Symbol, kw, sym};
8+
use rustc_span::{ByteSymbol, Span, Symbol, kw, sym};
99
use tracing::debug;
1010

1111
use crate::ast::{self, LitKind, MetaItemLit, StrStyle};
@@ -116,13 +116,12 @@ impl LitKind {
116116
assert!(!err.is_fatal(), "failed to unescape string literal")
117117
}
118118
});
119-
LitKind::ByteStr(buf.into(), StrStyle::Cooked)
119+
LitKind::ByteStr(ByteSymbol::intern(&buf), StrStyle::Cooked)
120120
}
121121
token::ByteStrRaw(n) => {
122-
// Raw strings have no escapes so we can convert the symbol
123-
// directly to a `Arc<u8>`.
122+
// Raw byte strings have no escapes so no work is needed here.
124123
let buf = symbol.as_str().to_owned().into_bytes();
125-
LitKind::ByteStr(buf.into(), StrStyle::Raw(n))
124+
LitKind::ByteStr(ByteSymbol::intern(&buf), StrStyle::Raw(n))
126125
}
127126
token::CStr => {
128127
let s = symbol.as_str();
@@ -137,15 +136,15 @@ impl LitKind {
137136
}
138137
});
139138
buf.push(0);
140-
LitKind::CStr(buf.into(), StrStyle::Cooked)
139+
LitKind::CStr(ByteSymbol::intern(&buf), StrStyle::Cooked)
141140
}
142141
token::CStrRaw(n) => {
143142
// Raw strings have no escapes so we can convert the symbol
144143
// directly to a `Arc<u8>` after appending the terminating NUL
145144
// char.
146145
let mut buf = symbol.as_str().to_owned().into_bytes();
147146
buf.push(0);
148-
LitKind::CStr(buf.into(), StrStyle::Raw(n))
147+
LitKind::CStr(ByteSymbol::intern(&buf), StrStyle::Raw(n))
149148
}
150149
token::Err(guar) => LitKind::Err(guar),
151150
})
@@ -167,12 +166,12 @@ impl fmt::Display for LitKind {
167166
delim = "#".repeat(n as usize),
168167
string = sym
169168
)?,
170-
LitKind::ByteStr(ref bytes, StrStyle::Cooked) => {
171-
write!(f, "b\"{}\"", escape_byte_str_symbol(bytes))?
169+
LitKind::ByteStr(ref byte_sym, StrStyle::Cooked) => {
170+
write!(f, "b\"{}\"", escape_byte_str_symbol(byte_sym.as_byte_str()))?
172171
}
173-
LitKind::ByteStr(ref bytes, StrStyle::Raw(n)) => {
172+
LitKind::ByteStr(ref byte_sym, StrStyle::Raw(n)) => {
174173
// Unwrap because raw byte string literals can only contain ASCII.
175-
let symbol = str::from_utf8(bytes).unwrap();
174+
let symbol = str::from_utf8(byte_sym.as_byte_str()).unwrap();
176175
write!(
177176
f,
178177
"br{delim}\"{string}\"{delim}",
@@ -181,11 +180,11 @@ impl fmt::Display for LitKind {
181180
)?;
182181
}
183182
LitKind::CStr(ref bytes, StrStyle::Cooked) => {
184-
write!(f, "c\"{}\"", escape_byte_str_symbol(bytes))?
183+
write!(f, "c\"{}\"", escape_byte_str_symbol(bytes.as_byte_str()))?
185184
}
186185
LitKind::CStr(ref bytes, StrStyle::Raw(n)) => {
187186
// This can only be valid UTF-8.
188-
let symbol = str::from_utf8(bytes).unwrap();
187+
let symbol = str::from_utf8(bytes.as_byte_str()).unwrap();
189188
write!(f, "cr{delim}\"{symbol}\"{delim}", delim = "#".repeat(n as usize),)?;
190189
}
191190
LitKind::Int(n, ty) => {

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
144144
hir::ExprKind::Unary(op, ohs)
145145
}
146146
ExprKind::Lit(token_lit) => hir::ExprKind::Lit(self.lower_lit(token_lit, e.span)),
147-
ExprKind::IncludedBytes(bytes) => {
148-
let lit = self.arena.alloc(respan(
147+
ExprKind::IncludedBytes(byte_sym) => {
148+
let lit = respan(
149149
self.lower_span(e.span),
150-
LitKind::ByteStr(Arc::clone(bytes), StrStyle::Cooked),
151-
));
150+
LitKind::ByteStr(*byte_sym, StrStyle::Cooked),
151+
);
152152
hir::ExprKind::Lit(lit)
153153
}
154154
ExprKind::Cast(expr, ty) => {
@@ -421,19 +421,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
421421
})
422422
}
423423

424-
pub(crate) fn lower_lit(
425-
&mut self,
426-
token_lit: &token::Lit,
427-
span: Span,
428-
) -> &'hir Spanned<LitKind> {
424+
pub(crate) fn lower_lit(&mut self, token_lit: &token::Lit, span: Span) -> hir::Lit {
429425
let lit_kind = match LitKind::from_token_lit(*token_lit) {
430426
Ok(lit_kind) => lit_kind,
431427
Err(err) => {
432428
let guar = report_lit_error(&self.tcx.sess.psess, err, *token_lit, span);
433429
LitKind::Err(guar)
434430
}
435431
};
436-
self.arena.alloc(respan(self.lower_span(span), lit_kind))
432+
respan(self.lower_span(span), lit_kind)
437433
}
438434

439435
fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
@@ -2141,10 +2137,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
21412137
}
21422138

21432139
fn expr_uint(&mut self, sp: Span, ty: ast::UintTy, value: u128) -> hir::Expr<'hir> {
2144-
let lit = self.arena.alloc(hir::Lit {
2140+
let lit = hir::Lit {
21452141
span: sp,
21462142
node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ty)),
2147-
});
2143+
};
21482144
self.expr(sp, hir::ExprKind::Lit(lit))
21492145
}
21502146

@@ -2161,9 +2157,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21612157
}
21622158

21632159
pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> {
2164-
let lit = self
2165-
.arena
2166-
.alloc(hir::Lit { span: sp, node: ast::LitKind::Str(value, ast::StrStyle::Cooked) });
2160+
let lit = hir::Lit { span: sp, node: ast::LitKind::Str(value, ast::StrStyle::Cooked) };
21672161
self.expr(sp, hir::ExprKind::Lit(lit))
21682162
}
21692163

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
390390
allow_paths: bool,
391391
) -> &'hir hir::PatExpr<'hir> {
392392
let span = self.lower_span(expr.span);
393-
let err = |guar| hir::PatExprKind::Lit {
394-
lit: self.arena.alloc(respan(span, LitKind::Err(guar))),
395-
negated: false,
396-
};
393+
let err =
394+
|guar| hir::PatExprKind::Lit { lit: respan(span, LitKind::Err(guar)), negated: false };
397395
let kind = match &expr.kind {
398396
ExprKind::Lit(lit) => {
399397
hir::PatExprKind::Lit { lit: self.lower_lit(lit, span), negated: false }
400398
}
401399
ExprKind::ConstBlock(c) => hir::PatExprKind::ConstBlock(self.lower_const_block(c)),
402-
ExprKind::IncludedBytes(bytes) => hir::PatExprKind::Lit {
403-
lit: self
404-
.arena
405-
.alloc(respan(span, LitKind::ByteStr(Arc::clone(bytes), StrStyle::Cooked))),
400+
ExprKind::IncludedBytes(byte_sym) => hir::PatExprKind::Lit {
401+
lit: respan(span, LitKind::ByteStr(*byte_sym, StrStyle::Cooked)),
406402
negated: false,
407403
},
408404
ExprKind::Err(guar) => err(*guar),

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
505505
);
506506
gate_all!(associated_const_equality, "associated const equality is incomplete");
507507
gate_all!(yeet_expr, "`do yeet` expression is experimental");
508-
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
509508
gate_all!(const_closures, "const closures are experimental");
510509
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");
511510
gate_all!(ergonomic_clones, "ergonomic clones are experimental");

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ impl<'a> State<'a> {
13031303
ast::TyKind::TraitObject(bounds, syntax) => {
13041304
match syntax {
13051305
ast::TraitObjectSyntax::Dyn => self.word_nbsp("dyn"),
1306-
ast::TraitObjectSyntax::DynStar => self.word_nbsp("dyn*"),
13071306
ast::TraitObjectSyntax::None => {}
13081307
}
13091308
self.print_type_bounds(bounds);

0 commit comments

Comments
 (0)