Skip to content

Commit f1a7941

Browse files
committed
Auto merge of rust-lang#3693 - rust-lang:rustup-2024-06-21, r=oli-obk
Automatic Rustup
2 parents 66ad792 + 9d7de1f commit f1a7941

File tree

605 files changed

+10835
-5413
lines changed

Some content is hidden

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

605 files changed

+10835
-5413
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ build/
5252
/src/tools/x/target
5353
# Created by default with `src/ci/docker/run.sh`
5454
/obj/
55+
/rustc-ice*
5556

5657
## Temporary files
5758
*~

Cargo.lock

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ dependencies = [
709709
"clippy_config",
710710
"itertools 0.12.1",
711711
"rustc-semver",
712+
"rustc_apfloat",
712713
]
713714

714715
[[package]]
@@ -3479,14 +3480,6 @@ dependencies = [
34793480
"wasmparser",
34803481
]
34813482

3482-
[[package]]
3483-
name = "rust-demangler"
3484-
version = "0.0.1"
3485-
dependencies = [
3486-
"regex",
3487-
"rustc-demangle",
3488-
]
3489-
34903483
[[package]]
34913484
name = "rustbook"
34923485
version = "0.1.0"
@@ -4913,6 +4906,7 @@ version = "0.0.0"
49134906
dependencies = [
49144907
"bitflags 2.5.0",
49154908
"derivative",
4909+
"indexmap",
49164910
"rustc_ast_ir",
49174911
"rustc_data_structures",
49184912
"rustc_index",

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ members = [
2323
"src/tools/remote-test-client",
2424
"src/tools/remote-test-server",
2525
"src/tools/rust-installer",
26-
"src/tools/rust-demangler",
2726
"src/tools/rustdoc",
2827
"src/tools/rls",
2928
"src/tools/rustfmt",

compiler/rustc_ast/src/ast.rs

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,9 @@ impl UnOp {
975975
}
976976
}
977977

978-
/// A statement
978+
/// A statement. No `attrs` or `tokens` fields because each `StmtKind` variant
979+
/// contains an AST node with those fields. (Except for `StmtKind::Empty`,
980+
/// which never has attrs or tokens)
979981
#[derive(Clone, Encodable, Decodable, Debug)]
980982
pub struct Stmt {
981983
pub id: NodeId,
@@ -3161,13 +3163,16 @@ pub struct Delegation {
31613163
pub path: Path,
31623164
pub rename: Option<Ident>,
31633165
pub body: Option<P<Block>>,
3166+
/// The item was expanded from a glob delegation item.
3167+
pub from_glob: bool,
31643168
}
31653169

31663170
#[derive(Clone, Encodable, Decodable, Debug)]
31673171
pub struct DelegationMac {
31683172
pub qself: Option<P<QSelf>>,
31693173
pub prefix: Path,
3170-
pub suffixes: ThinVec<(Ident, Option<Ident>)>,
3174+
// Some for list delegation, and None for glob delegation.
3175+
pub suffixes: Option<ThinVec<(Ident, Option<Ident>)>>,
31713176
pub body: Option<P<Block>>,
31723177
}
31733178

@@ -3179,38 +3184,6 @@ pub struct StaticItem {
31793184
pub expr: Option<P<Expr>>,
31803185
}
31813186

3182-
/// A static item in `extern` block.
3183-
// This struct is identical to StaticItem for now but it's going to have a safety attribute.
3184-
#[derive(Clone, Encodable, Decodable, Debug)]
3185-
pub struct StaticForeignItem {
3186-
pub ty: P<Ty>,
3187-
pub safety: Safety,
3188-
pub mutability: Mutability,
3189-
pub expr: Option<P<Expr>>,
3190-
}
3191-
3192-
impl From<StaticItem> for StaticForeignItem {
3193-
fn from(static_item: StaticItem) -> StaticForeignItem {
3194-
StaticForeignItem {
3195-
ty: static_item.ty,
3196-
safety: static_item.safety,
3197-
mutability: static_item.mutability,
3198-
expr: static_item.expr,
3199-
}
3200-
}
3201-
}
3202-
3203-
impl From<StaticForeignItem> for StaticItem {
3204-
fn from(static_item: StaticForeignItem) -> StaticItem {
3205-
StaticItem {
3206-
ty: static_item.ty,
3207-
safety: static_item.safety,
3208-
mutability: static_item.mutability,
3209-
expr: static_item.expr,
3210-
}
3211-
}
3212-
}
3213-
32143187
#[derive(Clone, Encodable, Decodable, Debug)]
32153188
pub struct ConstItem {
32163189
pub defaultness: Defaultness,
@@ -3294,7 +3267,7 @@ pub enum ItemKind {
32943267
///
32953268
/// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
32963269
Delegation(Box<Delegation>),
3297-
/// A list delegation item (`reuse prefix::{a, b, c}`).
3270+
/// A list or glob delegation item (`reuse prefix::{a, b, c}`, `reuse prefix::*`).
32983271
/// Treated similarly to a macro call and expanded early.
32993272
DelegationMac(Box<DelegationMac>),
33003273
}
@@ -3375,7 +3348,7 @@ pub enum AssocItemKind {
33753348
MacCall(P<MacCall>),
33763349
/// An associated delegation item.
33773350
Delegation(Box<Delegation>),
3378-
/// An associated delegation item list.
3351+
/// An associated list or glob delegation item.
33793352
DelegationMac(Box<DelegationMac>),
33803353
}
33813354

@@ -3425,7 +3398,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
34253398
#[derive(Clone, Encodable, Decodable, Debug)]
34263399
pub enum ForeignItemKind {
34273400
/// A foreign static item (`static FOO: u8`).
3428-
Static(Box<StaticForeignItem>),
3401+
Static(Box<StaticItem>),
34293402
/// An foreign function.
34303403
Fn(Box<Fn>),
34313404
/// An foreign type.

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,14 @@ impl NoopVisitItemKind for ItemKind {
11621162
}
11631163
ItemKind::MacCall(m) => vis.visit_mac_call(m),
11641164
ItemKind::MacroDef(def) => vis.visit_macro_def(def),
1165-
ItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
1165+
ItemKind::Delegation(box Delegation {
1166+
id,
1167+
qself,
1168+
path,
1169+
rename,
1170+
body,
1171+
from_glob: _,
1172+
}) => {
11661173
vis.visit_id(id);
11671174
vis.visit_qself(qself);
11681175
vis.visit_path(path);
@@ -1176,10 +1183,12 @@ impl NoopVisitItemKind for ItemKind {
11761183
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
11771184
vis.visit_qself(qself);
11781185
vis.visit_path(prefix);
1179-
for (ident, rename) in suffixes {
1180-
vis.visit_ident(ident);
1181-
if let Some(rename) = rename {
1182-
vis.visit_ident(rename);
1186+
if let Some(suffixes) = suffixes {
1187+
for (ident, rename) in suffixes {
1188+
vis.visit_ident(ident);
1189+
if let Some(rename) = rename {
1190+
vis.visit_ident(rename);
1191+
}
11831192
}
11841193
}
11851194
if let Some(body) = body {
@@ -1218,7 +1227,14 @@ impl NoopVisitItemKind for AssocItemKind {
12181227
visit_opt(ty, |ty| visitor.visit_ty(ty));
12191228
}
12201229
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
1221-
AssocItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
1230+
AssocItemKind::Delegation(box Delegation {
1231+
id,
1232+
qself,
1233+
path,
1234+
rename,
1235+
body,
1236+
from_glob: _,
1237+
}) => {
12221238
visitor.visit_id(id);
12231239
visitor.visit_qself(qself);
12241240
visitor.visit_path(path);
@@ -1232,10 +1248,12 @@ impl NoopVisitItemKind for AssocItemKind {
12321248
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
12331249
visitor.visit_qself(qself);
12341250
visitor.visit_path(prefix);
1235-
for (ident, rename) in suffixes {
1236-
visitor.visit_ident(ident);
1237-
if let Some(rename) = rename {
1238-
visitor.visit_ident(rename);
1251+
if let Some(suffixes) = suffixes {
1252+
for (ident, rename) in suffixes {
1253+
visitor.visit_ident(ident);
1254+
if let Some(rename) = rename {
1255+
visitor.visit_ident(rename);
1256+
}
12391257
}
12401258
}
12411259
if let Some(body) = body {
@@ -1292,12 +1310,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
12921310
impl NoopVisitItemKind for ForeignItemKind {
12931311
fn noop_visit(&mut self, visitor: &mut impl MutVisitor) {
12941312
match self {
1295-
ForeignItemKind::Static(box StaticForeignItem {
1296-
ty,
1297-
mutability: _,
1298-
expr,
1299-
safety: _,
1300-
}) => {
1313+
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
13011314
visitor.visit_ty(ty);
13021315
visit_opt(expr, |expr| visitor.visit_expr(expr));
13031316
}

compiler/rustc_ast/src/token.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,10 @@ impl Token {
558558
/// Returns `true` if the token can appear at the start of a const param.
559559
pub fn can_begin_const_arg(&self) -> bool {
560560
match self.kind {
561-
OpenDelim(Delimiter::Brace) => true,
561+
OpenDelim(Delimiter::Brace) | Literal(..) | BinOp(Minus) => true,
562+
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true,
562563
Interpolated(ref nt) => matches!(&**nt, NtExpr(..) | NtBlock(..) | NtLiteral(..)),
563-
_ => self.can_begin_literal_maybe_minus(),
564+
_ => false,
564565
}
565566
}
566567

@@ -620,6 +621,21 @@ impl Token {
620621
}
621622
}
622623

624+
pub fn can_begin_string_literal(&self) -> bool {
625+
match self.uninterpolate().kind {
626+
Literal(..) => true,
627+
Interpolated(ref nt) => match &**nt {
628+
NtLiteral(_) => true,
629+
NtExpr(e) => match &e.kind {
630+
ast::ExprKind::Lit(_) => true,
631+
_ => false,
632+
},
633+
_ => false,
634+
},
635+
_ => false,
636+
}
637+
}
638+
623639
/// A convenience function for matching on identifiers during parsing.
624640
/// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
625641
/// into the regular identifier or lifetime token it refers to,
@@ -884,7 +900,11 @@ pub enum NonterminalKind {
884900
PatWithOr,
885901
Expr,
886902
/// Matches an expression using the rules from edition 2021 and earlier.
887-
Expr2021,
903+
Expr2021 {
904+
/// Keep track of whether the user used `:expr` or `:expr_2021` and we inferred it from the
905+
/// edition of the span. This is used for diagnostics AND feature gating.
906+
inferred: bool,
907+
},
888908
Ty,
889909
Ident,
890910
Lifetime,
@@ -913,8 +933,13 @@ impl NonterminalKind {
913933
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
914934
},
915935
sym::pat_param => NonterminalKind::PatParam { inferred: false },
916-
sym::expr => NonterminalKind::Expr,
917-
sym::expr_2021 if edition().at_least_rust_2021() => NonterminalKind::Expr2021,
936+
sym::expr => match edition() {
937+
Edition::Edition2015 | Edition::Edition2018 | Edition::Edition2021 => {
938+
NonterminalKind::Expr2021 { inferred: true }
939+
}
940+
Edition::Edition2024 => NonterminalKind::Expr,
941+
},
942+
sym::expr_2021 => NonterminalKind::Expr2021 { inferred: false },
918943
sym::ty => NonterminalKind::Ty,
919944
sym::ident => NonterminalKind::Ident,
920945
sym::lifetime => NonterminalKind::Lifetime,
@@ -933,8 +958,8 @@ impl NonterminalKind {
933958
NonterminalKind::Stmt => sym::stmt,
934959
NonterminalKind::PatParam { inferred: false } => sym::pat_param,
935960
NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat,
936-
NonterminalKind::Expr => sym::expr,
937-
NonterminalKind::Expr2021 => sym::expr_2021,
961+
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: true } => sym::expr,
962+
NonterminalKind::Expr2021 { inferred: false } => sym::expr_2021,
938963
NonterminalKind::Ty => sym::ty,
939964
NonterminalKind::Ident => sym::ident,
940965
NonterminalKind::Lifetime => sym::lifetime,

compiler/rustc_ast/src/visit.rs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,14 @@ impl WalkItemKind for ItemKind {
408408
}
409409
ItemKind::MacCall(mac) => try_visit!(visitor.visit_mac_call(mac)),
410410
ItemKind::MacroDef(ts) => try_visit!(visitor.visit_mac_def(ts, item.id)),
411-
ItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
411+
ItemKind::Delegation(box Delegation {
412+
id,
413+
qself,
414+
path,
415+
rename,
416+
body,
417+
from_glob: _,
418+
}) => {
412419
if let Some(qself) = qself {
413420
try_visit!(visitor.visit_ty(&qself.ty));
414421
}
@@ -421,10 +428,12 @@ impl WalkItemKind for ItemKind {
421428
try_visit!(visitor.visit_ty(&qself.ty));
422429
}
423430
try_visit!(visitor.visit_path(prefix, item.id));
424-
for (ident, rename) in suffixes {
425-
visitor.visit_ident(*ident);
426-
if let Some(rename) = rename {
427-
visitor.visit_ident(*rename);
431+
if let Some(suffixes) = suffixes {
432+
for (ident, rename) in suffixes {
433+
visitor.visit_ident(*ident);
434+
if let Some(rename) = rename {
435+
visitor.visit_ident(*rename);
436+
}
428437
}
429438
}
430439
visit_opt!(visitor, visit_block, body);
@@ -663,12 +672,7 @@ impl WalkItemKind for ForeignItemKind {
663672
) -> V::Result {
664673
let &Item { id, span, ident, ref vis, .. } = item;
665674
match self {
666-
ForeignItemKind::Static(box StaticForeignItem {
667-
ty,
668-
mutability: _,
669-
expr,
670-
safety: _,
671-
}) => {
675+
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
672676
try_visit!(visitor.visit_ty(ty));
673677
visit_opt!(visitor, visit_expr, expr);
674678
}
@@ -837,7 +841,14 @@ impl WalkItemKind for AssocItemKind {
837841
AssocItemKind::MacCall(mac) => {
838842
try_visit!(visitor.visit_mac_call(mac));
839843
}
840-
AssocItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
844+
AssocItemKind::Delegation(box Delegation {
845+
id,
846+
qself,
847+
path,
848+
rename,
849+
body,
850+
from_glob: _,
851+
}) => {
841852
if let Some(qself) = qself {
842853
try_visit!(visitor.visit_ty(&qself.ty));
843854
}
@@ -850,10 +861,12 @@ impl WalkItemKind for AssocItemKind {
850861
try_visit!(visitor.visit_ty(&qself.ty));
851862
}
852863
try_visit!(visitor.visit_path(prefix, item.id));
853-
for (ident, rename) in suffixes {
854-
visitor.visit_ident(*ident);
855-
if let Some(rename) = rename {
856-
visitor.visit_ident(*rename);
864+
if let Some(suffixes) = suffixes {
865+
for (ident, rename) in suffixes {
866+
visitor.visit_ident(*ident);
867+
if let Some(rename) = rename {
868+
visitor.visit_ident(*rename);
869+
}
857870
}
858871
}
859872
visit_opt!(visitor, visit_block, body);

0 commit comments

Comments
 (0)