Skip to content

Commit 2b5b43e

Browse files
Merge remote-tracking branch 'upstream/master' into HEAD
2 parents 379908e + b054da8 commit 2b5b43e

File tree

1,489 files changed

+18642
-10363
lines changed

Some content is hidden

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

1,489 files changed

+18642
-10363
lines changed

Cargo.lock

+8-2
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ version = "0.1.0"
469469

470470
[[package]]
471471
name = "cc"
472-
version = "1.0.79"
472+
version = "1.0.90"
473473
source = "registry+https://github.com/rust-lang/crates.io-index"
474-
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
474+
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
475475

476476
[[package]]
477477
name = "cfg-if"
@@ -3970,6 +3970,7 @@ version = "0.0.0"
39703970
dependencies = [
39713971
"itertools 0.11.0",
39723972
"rustc_ast",
3973+
"rustc_ast_ir",
39733974
"rustc_attr",
39743975
"rustc_data_structures",
39753976
"rustc_errors",
@@ -4038,6 +4039,7 @@ dependencies = [
40384039
name = "rustc_infer"
40394040
version = "0.0.0"
40404041
dependencies = [
4042+
"rustc_ast_ir",
40414043
"rustc_data_structures",
40424044
"rustc_errors",
40434045
"rustc_fluent_macro",
@@ -4570,6 +4572,7 @@ name = "rustc_span"
45704572
version = "0.0.0"
45714573
dependencies = [
45724574
"indexmap",
4575+
"itoa",
45734576
"md-5",
45744577
"rustc_arena",
45754578
"rustc_data_structures",
@@ -4632,6 +4635,7 @@ dependencies = [
46324635
"bitflags 2.4.2",
46334636
"itertools 0.11.0",
46344637
"rustc_ast",
4638+
"rustc_ast_ir",
46354639
"rustc_attr",
46364640
"rustc_data_structures",
46374641
"rustc_errors",
@@ -4670,6 +4674,7 @@ name = "rustc_transmute"
46704674
version = "0.0.0"
46714675
dependencies = [
46724676
"itertools 0.11.0",
4677+
"rustc_ast_ir",
46734678
"rustc_data_structures",
46744679
"rustc_hir",
46754680
"rustc_infer",
@@ -4685,6 +4690,7 @@ name = "rustc_ty_utils"
46854690
version = "0.0.0"
46864691
dependencies = [
46874692
"itertools 0.11.0",
4693+
"rustc_ast_ir",
46884694
"rustc_data_structures",
46894695
"rustc_errors",
46904696
"rustc_fluent_macro",

compiler/rustc_abi/src/layout.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
use std::borrow::{Borrow, Cow};
2+
use std::cmp;
13
use std::fmt::{self, Write};
4+
use std::iter;
5+
use std::ops::Bound;
26
use std::ops::Deref;
3-
use std::{borrow::Borrow, cmp, iter, ops::Bound};
47

58
use rustc_index::Idx;
69
use tracing::debug;
@@ -32,7 +35,7 @@ where
3235
pub trait LayoutCalculator {
3336
type TargetDataLayoutRef: Borrow<TargetDataLayout>;
3437

35-
fn delayed_bug(&self, txt: String);
38+
fn delayed_bug(&self, txt: impl Into<Cow<'static, str>>);
3639
fn current_data_layout(&self) -> Self::TargetDataLayoutRef;
3740

3841
fn scalar_pair<FieldIdx: Idx, VariantIdx: Idx>(

compiler/rustc_abi/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1612,8 +1612,9 @@ pub enum PointerKind {
16121612
SharedRef { frozen: bool },
16131613
/// Mutable reference. `unpin` indicates the absence of any pinned data.
16141614
MutableRef { unpin: bool },
1615-
/// Box. `unpin` indicates the absence of any pinned data.
1616-
Box { unpin: bool },
1615+
/// Box. `unpin` indicates the absence of any pinned data. `global` indicates whether this box
1616+
/// uses the global allocator or a custom one.
1617+
Box { unpin: bool, global: bool },
16171618
}
16181619

16191620
/// Note that this information is advisory only, and backends are free to ignore it.
@@ -1622,6 +1623,8 @@ pub enum PointerKind {
16221623
pub struct PointeeInfo {
16231624
pub size: Size,
16241625
pub align: Align,
1626+
/// If this is `None`, then this is a raw pointer, so size and alignment are not guaranteed to
1627+
/// be reliable.
16251628
pub safe: Option<PointerKind>,
16261629
}
16271630

compiler/rustc_ast/src/ast.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,9 @@ pub enum InlineAsmOperand {
23022302
Sym {
23032303
sym: InlineAsmSym,
23042304
},
2305+
Label {
2306+
block: P<Block>,
2307+
},
23052308
}
23062309

23072310
impl InlineAsmOperand {
@@ -2311,7 +2314,7 @@ impl InlineAsmOperand {
23112314
| Self::Out { reg, .. }
23122315
| Self::InOut { reg, .. }
23132316
| Self::SplitInOut { reg, .. } => Some(reg),
2314-
Self::Const { .. } | Self::Sym { .. } => None,
2317+
Self::Const { .. } | Self::Sym { .. } | Self::Label { .. } => None,
23152318
}
23162319
}
23172320
}

compiler/rustc_ast/src/mut_visit.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@ pub fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
13311331
}
13321332
InlineAsmOperand::Const { anon_const } => vis.visit_anon_const(anon_const),
13331333
InlineAsmOperand::Sym { sym } => vis.visit_inline_asm_sym(sym),
1334+
InlineAsmOperand::Label { block } => vis.visit_block(block),
13341335
}
13351336
}
13361337
}
@@ -1604,7 +1605,10 @@ pub fn noop_visit_capture_by<T: MutVisitor>(capture_by: &mut CaptureBy, vis: &mu
16041605
}
16051606
}
16061607

1607-
/// Some value for the AST node that is valid but possibly meaningless.
1608+
/// Some value for the AST node that is valid but possibly meaningless. Similar
1609+
/// to `Default` but not intended for wide use. The value will never be used
1610+
/// meaningfully, it exists just to support unwinding in `visit_clobber` in the
1611+
/// case where its closure panics.
16081612
pub trait DummyAstNode {
16091613
fn dummy() -> Self;
16101614
}
@@ -1679,19 +1683,6 @@ impl DummyAstNode for Stmt {
16791683
}
16801684
}
16811685

1682-
impl DummyAstNode for Block {
1683-
fn dummy() -> Self {
1684-
Block {
1685-
stmts: Default::default(),
1686-
id: DUMMY_NODE_ID,
1687-
rules: BlockCheckMode::Default,
1688-
span: Default::default(),
1689-
tokens: Default::default(),
1690-
could_be_bare_literal: Default::default(),
1691-
}
1692-
}
1693-
}
1694-
16951686
impl DummyAstNode for Crate {
16961687
fn dummy() -> Self {
16971688
Crate {

compiler/rustc_ast/src/visit.rs

+4-65
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
1616
use crate::ast::*;
1717

18-
use core::ops::ControlFlow;
19-
2018
use rustc_span::symbol::Ident;
2119
use rustc_span::Span;
2220

21+
pub use rustc_ast_ir::visit::VisitorResult;
22+
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
23+
2324
#[derive(Copy, Clone, Debug, PartialEq)]
2425
pub enum AssocCtxt {
2526
Trait,
@@ -101,51 +102,6 @@ pub enum LifetimeCtxt {
101102
GenericArg,
102103
}
103104

104-
/// Similar to the `Try` trait, but also implemented for `()`.
105-
pub trait VisitorResult {
106-
type Residual;
107-
fn output() -> Self;
108-
fn from_residual(residual: Self::Residual) -> Self;
109-
fn branch(self) -> ControlFlow<Self::Residual>;
110-
}
111-
112-
impl VisitorResult for () {
113-
type Residual = !;
114-
115-
fn output() -> Self {}
116-
fn from_residual(_: !) -> Self {}
117-
fn branch(self) -> ControlFlow<!> {
118-
ControlFlow::Continue(())
119-
}
120-
}
121-
122-
impl<T> VisitorResult for ControlFlow<T> {
123-
type Residual = T;
124-
125-
fn output() -> Self {
126-
ControlFlow::Continue(())
127-
}
128-
fn from_residual(residual: Self::Residual) -> Self {
129-
ControlFlow::Break(residual)
130-
}
131-
fn branch(self) -> ControlFlow<T> {
132-
self
133-
}
134-
}
135-
136-
#[macro_export]
137-
macro_rules! try_visit {
138-
($e:expr) => {
139-
match $crate::visit::VisitorResult::branch($e) {
140-
core::ops::ControlFlow::Continue(()) => (),
141-
#[allow(unreachable_code)]
142-
core::ops::ControlFlow::Break(r) => {
143-
return $crate::visit::VisitorResult::from_residual(r);
144-
}
145-
}
146-
};
147-
}
148-
149105
/// Each method of the `Visitor` trait is a hook to be potentially
150106
/// overridden. Each method's default implementation recursively visits
151107
/// the substructure of the input via the corresponding `walk` method;
@@ -316,24 +272,6 @@ pub trait Visitor<'ast>: Sized {
316272
}
317273
}
318274

319-
#[macro_export]
320-
macro_rules! walk_list {
321-
($visitor: expr, $method: ident, $list: expr $(, $($extra_args: expr),* )?) => {
322-
for elem in $list {
323-
$crate::try_visit!($visitor.$method(elem $(, $($extra_args,)* )?));
324-
}
325-
}
326-
}
327-
328-
#[macro_export]
329-
macro_rules! visit_opt {
330-
($visitor: expr, $method: ident, $opt: expr $(, $($extra_args: expr),* )?) => {
331-
if let Some(x) = $opt {
332-
$crate::try_visit!($visitor.$method(x $(, $($extra_args,)* )?));
333-
}
334-
}
335-
}
336-
337275
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) -> V::Result {
338276
walk_list!(visitor, visit_item, &krate.items);
339277
walk_list!(visitor, visit_attribute, &krate.attrs);
@@ -885,6 +823,7 @@ pub fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm)
885823
try_visit!(visitor.visit_anon_const(anon_const))
886824
}
887825
InlineAsmOperand::Sym { sym } => try_visit!(visitor.visit_inline_asm_sym(sym)),
826+
InlineAsmOperand::Label { block } => try_visit!(visitor.visit_block(block)),
888827
}
889828
}
890829
V::Result::output()

compiler/rustc_ast_ir/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
#![cfg_attr(feature = "nightly", feature(never_type))]
12
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
23
#![cfg_attr(feature = "nightly", allow(internal_features))]
34

45
#[cfg(feature = "nightly")]
56
#[macro_use]
67
extern crate rustc_macros;
78

9+
pub mod visit;
10+
811
/// The movability of a coroutine / closure literal:
912
/// whether a coroutine contains self-references, causing it to be `!Unpin`.
1013
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]

compiler/rustc_ast_ir/src/visit.rs

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
use core::ops::ControlFlow;
2+
3+
/// Similar to the `Try` trait, but also implemented for `()`.
4+
pub trait VisitorResult {
5+
type Residual;
6+
fn output() -> Self;
7+
fn from_residual(residual: Self::Residual) -> Self;
8+
fn from_branch(b: ControlFlow<Self::Residual>) -> Self;
9+
fn branch(self) -> ControlFlow<Self::Residual>;
10+
}
11+
12+
impl VisitorResult for () {
13+
#[cfg(feature = "nightly")]
14+
type Residual = !;
15+
16+
#[cfg(not(feature = "nightly"))]
17+
type Residual = core::ops::Infallible;
18+
19+
fn output() -> Self {}
20+
fn from_residual(_: Self::Residual) -> Self {}
21+
fn from_branch(_: ControlFlow<Self::Residual>) -> Self {}
22+
fn branch(self) -> ControlFlow<Self::Residual> {
23+
ControlFlow::Continue(())
24+
}
25+
}
26+
27+
impl<T> VisitorResult for ControlFlow<T> {
28+
type Residual = T;
29+
30+
fn output() -> Self {
31+
ControlFlow::Continue(())
32+
}
33+
fn from_residual(residual: Self::Residual) -> Self {
34+
ControlFlow::Break(residual)
35+
}
36+
fn from_branch(b: Self) -> Self {
37+
b
38+
}
39+
fn branch(self) -> Self {
40+
self
41+
}
42+
}
43+
44+
#[macro_export]
45+
macro_rules! try_visit {
46+
($e:expr) => {
47+
match $crate::visit::VisitorResult::branch($e) {
48+
core::ops::ControlFlow::Continue(()) => (),
49+
#[allow(unreachable_code)]
50+
core::ops::ControlFlow::Break(r) => {
51+
return $crate::visit::VisitorResult::from_residual(r);
52+
}
53+
}
54+
};
55+
}
56+
57+
#[macro_export]
58+
macro_rules! visit_opt {
59+
($visitor: expr, $method: ident, $opt: expr $(, $($extra_args: expr),* )?) => {
60+
if let Some(x) = $opt {
61+
$crate::try_visit!($visitor.$method(x $(, $($extra_args,)* )?));
62+
}
63+
}
64+
}
65+
66+
#[macro_export]
67+
macro_rules! walk_list {
68+
($visitor: expr, $method: ident, $list: expr $(, $($extra_args: expr),* )?) => {
69+
for elem in $list {
70+
$crate::try_visit!($visitor.$method(elem $(, $($extra_args,)* )?));
71+
}
72+
}
73+
}
74+
75+
#[macro_export]
76+
macro_rules! walk_visitable_list {
77+
($visitor: expr, $list: expr $(, $($extra_args: expr),* )?) => {
78+
for elem in $list {
79+
$crate::try_visit!(elem.visit_with($visitor $(, $($extra_args,)* )?));
80+
}
81+
}
82+
}

compiler/rustc_ast_lowering/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ ast_lowering_invalid_abi_suggestion = did you mean
8888
ast_lowering_invalid_asm_template_modifier_const =
8989
asm template modifiers are not allowed for `const` arguments
9090
91+
ast_lowering_invalid_asm_template_modifier_label =
92+
asm template modifiers are not allowed for `label` arguments
93+
9194
ast_lowering_invalid_asm_template_modifier_reg_class =
9295
invalid asm template modifier for this register class
9396

0 commit comments

Comments
 (0)