Skip to content

Commit 1754946

Browse files
committed
Auto merge of #3238 - rust-lang:rustup-2023-12-24, r=saethlin
Automatic Rustup
2 parents 2c7e0fd + 29f25ee commit 1754946

File tree

330 files changed

+5136
-4555
lines changed

Some content is hidden

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

330 files changed

+5136
-4555
lines changed

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ jobs:
289289
os: ubuntu-20.04-4core-16gb
290290
env: {}
291291
- name: x86_64-gnu-integration
292+
env:
293+
CI_ONLY_WHEN_CHANNEL: nightly
292294
os: ubuntu-20.04-16core-64gb
293-
env: {}
294295
- name: x86_64-gnu-debug
295296
os: ubuntu-20.04-8core-32gb
296297
env: {}

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4340,6 +4340,7 @@ dependencies = [
43404340
name = "rustc_pattern_analysis"
43414341
version = "0.0.0"
43424342
dependencies = [
4343+
"derivative",
43434344
"rustc_apfloat",
43444345
"rustc_arena",
43454346
"rustc_data_structures",

compiler/rustc_abi/src/layout.rs

+634-584
Large diffs are not rendered by default.

compiler/rustc_ast/src/ast.rs

+71-41
Original file line numberDiff line numberDiff line change
@@ -286,41 +286,16 @@ impl ParenthesizedArgs {
286286

287287
pub use crate::node_id::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
288288

289-
/// A modifier on a bound, e.g., `?Trait` or `~const Trait`.
290-
///
291-
/// Negative bounds should also be handled here.
289+
/// Modifiers on a trait bound like `~const`, `?` and `!`.
292290
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
293-
pub enum TraitBoundModifier {
294-
/// No modifiers
295-
None,
296-
297-
/// `!Trait`
298-
Negative,
299-
300-
/// `?Trait`
301-
Maybe,
302-
303-
/// `~const Trait`
304-
MaybeConst(Span),
305-
306-
/// `~const !Trait`
307-
//
308-
// This parses but will be rejected during AST validation.
309-
MaybeConstNegative,
310-
311-
/// `~const ?Trait`
312-
//
313-
// This parses but will be rejected during AST validation.
314-
MaybeConstMaybe,
291+
pub struct TraitBoundModifiers {
292+
pub constness: BoundConstness,
293+
pub polarity: BoundPolarity,
315294
}
316295

317-
impl TraitBoundModifier {
318-
pub fn to_constness(self) -> Const {
319-
match self {
320-
Self::MaybeConst(span) => Const::Yes(span),
321-
_ => Const::No,
322-
}
323-
}
296+
impl TraitBoundModifiers {
297+
pub const NONE: Self =
298+
Self { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
324299
}
325300

326301
/// The AST represents all type param bounds as types.
@@ -329,7 +304,7 @@ impl TraitBoundModifier {
329304
/// detects `Copy`, `Send` and `Sync`.
330305
#[derive(Clone, Encodable, Decodable, Debug)]
331306
pub enum GenericBound {
332-
Trait(PolyTraitRef, TraitBoundModifier),
307+
Trait(PolyTraitRef, TraitBoundModifiers),
333308
Outlives(Lifetime),
334309
}
335310

@@ -779,8 +754,7 @@ pub enum PatKind {
779754
Ident(BindingAnnotation, Ident, Option<P<Pat>>),
780755

781756
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
782-
/// The `bool` is `true` in the presence of a `..`.
783-
Struct(Option<P<QSelf>>, Path, ThinVec<PatField>, /* recovered */ bool),
757+
Struct(Option<P<QSelf>>, Path, ThinVec<PatField>, PatFieldsRest),
784758

785759
/// A tuple struct/variant pattern (`Variant(x, y, .., z)`).
786760
TupleStruct(Option<P<QSelf>>, Path, ThinVec<P<Pat>>),
@@ -837,6 +811,15 @@ pub enum PatKind {
837811
MacCall(P<MacCall>),
838812
}
839813

814+
/// Whether the `..` is present in a struct fields pattern.
815+
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq)]
816+
pub enum PatFieldsRest {
817+
/// `module::StructName { field, ..}`
818+
Rest,
819+
/// `module::StructName { field }`
820+
None,
821+
}
822+
840823
/// The kind of borrow in an `AddrOf` expression,
841824
/// e.g., `&place` or `&raw const place`.
842825
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -1193,7 +1176,7 @@ impl Expr {
11931176
match &self.kind {
11941177
ExprKind::Path(None, path) => Some(GenericBound::Trait(
11951178
PolyTraitRef::new(ThinVec::new(), path.clone(), self.span),
1196-
TraitBoundModifier::None,
1179+
TraitBoundModifiers::NONE,
11971180
)),
11981181
_ => None,
11991182
}
@@ -1274,7 +1257,7 @@ impl Expr {
12741257
ExprKind::Let(..) => ExprPrecedence::Let,
12751258
ExprKind::If(..) => ExprPrecedence::If,
12761259
ExprKind::While(..) => ExprPrecedence::While,
1277-
ExprKind::ForLoop(..) => ExprPrecedence::ForLoop,
1260+
ExprKind::ForLoop { .. } => ExprPrecedence::ForLoop,
12781261
ExprKind::Loop(..) => ExprPrecedence::Loop,
12791262
ExprKind::Match(..) => ExprPrecedence::Match,
12801263
ExprKind::Closure(..) => ExprPrecedence::Closure,
@@ -1436,10 +1419,10 @@ pub enum ExprKind {
14361419
While(P<Expr>, P<Block>, Option<Label>),
14371420
/// A `for` loop, with an optional label.
14381421
///
1439-
/// `'label: for pat in expr { block }`
1422+
/// `'label: for await? pat in iter { block }`
14401423
///
14411424
/// This is desugared to a combination of `loop` and `match` expressions.
1442-
ForLoop(P<Pat>, P<Expr>, P<Block>, Option<Label>),
1425+
ForLoop { pat: P<Pat>, iter: P<Expr>, body: P<Block>, label: Option<Label>, kind: ForLoopKind },
14431426
/// Conditionless loop (can be exited with `break`, `continue`, or `return`).
14441427
///
14451428
/// `'label: loop { block }`
@@ -1542,6 +1525,13 @@ pub enum ExprKind {
15421525
Err,
15431526
}
15441527

1528+
/// Used to differentiate between `for` loops and `for await` loops.
1529+
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Eq)]
1530+
pub enum ForLoopKind {
1531+
For,
1532+
ForAwait,
1533+
}
1534+
15451535
/// Used to differentiate between `async {}` blocks and `gen {}` blocks.
15461536
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
15471537
pub enum GenBlockKind {
@@ -2491,6 +2481,15 @@ pub enum Const {
24912481
No,
24922482
}
24932483

2484+
impl From<BoundConstness> for Const {
2485+
fn from(constness: BoundConstness) -> Self {
2486+
match constness {
2487+
BoundConstness::Maybe(span) => Self::Yes(span),
2488+
BoundConstness::Never => Self::No,
2489+
}
2490+
}
2491+
}
2492+
24942493
/// Item defaultness.
24952494
/// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532).
24962495
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
@@ -2516,7 +2515,9 @@ impl fmt::Debug for ImplPolarity {
25162515
}
25172516
}
25182517

2519-
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
2518+
/// The polarity of a trait bound.
2519+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
2520+
#[derive(HashStable_Generic)]
25202521
pub enum BoundPolarity {
25212522
/// `Type: Trait`
25222523
Positive,
@@ -2526,6 +2527,35 @@ pub enum BoundPolarity {
25262527
Maybe(Span),
25272528
}
25282529

2530+
impl BoundPolarity {
2531+
pub fn as_str(self) -> &'static str {
2532+
match self {
2533+
Self::Positive => "",
2534+
Self::Negative(_) => "!",
2535+
Self::Maybe(_) => "?",
2536+
}
2537+
}
2538+
}
2539+
2540+
/// The constness of a trait bound.
2541+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
2542+
#[derive(HashStable_Generic)]
2543+
pub enum BoundConstness {
2544+
/// `Type: Trait`
2545+
Never,
2546+
/// `Type: ~const Trait`
2547+
Maybe(Span),
2548+
}
2549+
2550+
impl BoundConstness {
2551+
pub fn as_str(self) -> &'static str {
2552+
match self {
2553+
Self::Never => "",
2554+
Self::Maybe(_) => "~const",
2555+
}
2556+
}
2557+
}
2558+
25292559
#[derive(Clone, Encodable, Decodable, Debug)]
25302560
pub enum FnRetTy {
25312561
/// Returns type is not specified.
@@ -3259,7 +3289,7 @@ mod size_asserts {
32593289
static_assert_size!(ForeignItem, 96);
32603290
static_assert_size!(ForeignItemKind, 24);
32613291
static_assert_size!(GenericArg, 24);
3262-
static_assert_size!(GenericBound, 64);
3292+
static_assert_size!(GenericBound, 72);
32633293
static_assert_size!(Generics, 40);
32643294
static_assert_size!(Impl, 136);
32653295
static_assert_size!(Item, 136);

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
13891389
vis.visit_block(body);
13901390
visit_opt(label, |label| vis.visit_label(label));
13911391
}
1392-
ExprKind::ForLoop(pat, iter, body, label) => {
1392+
ExprKind::ForLoop { pat, iter, body, label, kind: _ } => {
13931393
vis.visit_pat(pat);
13941394
vis.visit_expr(iter);
13951395
vis.visit_block(body);

compiler/rustc_ast/src/util/classify.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
1919
| ast::ExprKind::Block(..)
2020
| ast::ExprKind::While(..)
2121
| ast::ExprKind::Loop(..)
22-
| ast::ExprKind::ForLoop(..)
22+
| ast::ExprKind::ForLoop { .. }
2323
| ast::ExprKind::TryBlock(..)
2424
| ast::ExprKind::ConstBlock(..)
2525
)
@@ -48,8 +48,16 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
4848
Closure(closure) => {
4949
expr = &closure.body;
5050
}
51-
Gen(..) | Block(..) | ForLoop(..) | If(..) | Loop(..) | Match(..) | Struct(..)
52-
| TryBlock(..) | While(..) | ConstBlock(_) => break Some(expr),
51+
Gen(..)
52+
| Block(..)
53+
| ForLoop { .. }
54+
| If(..)
55+
| Loop(..)
56+
| Match(..)
57+
| Struct(..)
58+
| TryBlock(..)
59+
| While(..)
60+
| ConstBlock(_) => break Some(expr),
5361

5462
// FIXME: These can end in `}`, but changing these would break stable code.
5563
InlineAsm(_) | OffsetOf(_, _) | MacCall(_) | IncludedBytes(_) | FormatArgs(_) => {

compiler/rustc_ast/src/visit.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,11 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
844844
visitor.visit_expr(subexpression);
845845
visitor.visit_block(block);
846846
}
847-
ExprKind::ForLoop(pattern, subexpression, block, opt_label) => {
848-
walk_list!(visitor, visit_label, opt_label);
849-
visitor.visit_pat(pattern);
850-
visitor.visit_expr(subexpression);
851-
visitor.visit_block(block);
847+
ExprKind::ForLoop { pat, iter, body, label, kind: _ } => {
848+
walk_list!(visitor, visit_label, label);
849+
visitor.visit_pat(pat);
850+
visitor.visit_expr(iter);
851+
visitor.visit_block(body);
852852
}
853853
ExprKind::Loop(block, opt_label, _) => {
854854
walk_list!(visitor, visit_label, opt_label);

0 commit comments

Comments
 (0)