Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1447f9d

Browse files
committed
Auto merge of rust-lang#122869 - matthiaskrgr:rollup-0navj4l, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#121619 (Experimental feature postfix match) - rust-lang#122370 (Gracefully handle `AnonConst` in `diagnostic_hir_wf_check()`) - rust-lang#122537 (interpret/allocation: fix aliasing issue in interpreter and refactor getters a bit) - rust-lang#122542 (coverage: Clean up marker statements that aren't needed later) - rust-lang#122800 (Add `NonNull::<[T]>::is_empty`.) - rust-lang#122820 (Stop using `<DefId as Ord>` in various diagnostic situations) - rust-lang#122847 (Suggest `RUST_MIN_STACK` workaround on overflow) - rust-lang#122855 (Fix Itanium mangling usizes) - rust-lang#122863 (add more ice tests ) r? `@ghost` `@rustbot` modify labels: rollup
2 parents eff958c + a5de4fb commit 1447f9d

File tree

73 files changed

+1200
-248
lines changed

Some content is hidden

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

73 files changed

+1200
-248
lines changed

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4236,6 +4236,7 @@ name = "rustc_middle"
42364236
version = "0.0.0"
42374237
dependencies = [
42384238
"bitflags 2.4.2",
4239+
"derivative",
42394240
"either",
42404241
"field-offset",
42414242
"gsgdt",

‎compiler/rustc_ast/src/ast.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ pub enum ExprKind {
14371437
/// `'label: loop { block }`
14381438
Loop(P<Block>, Option<Label>, Span),
14391439
/// A `match` block.
1440-
Match(P<Expr>, ThinVec<Arm>),
1440+
Match(P<Expr>, ThinVec<Arm>,MatchKind),
14411441
/// A closure (e.g., `move |a, b, c| a + b + c`).
14421442
Closure(Box<Closure>),
14431443
/// A block (`'label: { ... }`).
@@ -1762,6 +1762,15 @@ pub enum StrStyle {
17621762
Raw(u8),
17631763
}
17641764

1765+
/// The kind of match expression
1766+
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq)]
1767+
pub enum MatchKind {
1768+
/// match expr { ... }
1769+
Prefix,
1770+
/// expr.match { ... }
1771+
Postfix,
1772+
}
1773+
17651774
/// A literal in a meta item.
17661775
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
17671776
pub struct MetaItemLit {

‎compiler/rustc_ast/src/mut_visit.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
14251425
visit_opt(label, |label| vis.visit_label(label));
14261426
vis.visit_span(span);
14271427
}
1428-
ExprKind::Match(expr, arms) => {
1428+
ExprKind::Match(expr, arms, _kind) => {
14291429
vis.visit_expr(expr);
14301430
arms.flat_map_in_place(|arm| vis.flat_map_arm(arm));
14311431
}

‎compiler/rustc_ast/src/visit.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
923923
visit_opt!(visitor, visit_label, opt_label);
924924
try_visit!(visitor.visit_block(block));
925925
}
926-
ExprKind::Match(subexpression, arms) => {
926+
ExprKind::Match(subexpression, arms, _kind) => {
927927
try_visit!(visitor.visit_expr(subexpression));
928928
walk_list!(visitor, visit_arm, arms);
929929
}

‎compiler/rustc_ast_lowering/src/expr.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
181181
)
182182
}),
183183
ExprKind::TryBlock(body) => self.lower_expr_try_block(body),
184-
ExprKind::Match(expr, arms) => hir::ExprKind::Match(
184+
ExprKind::Match(expr, arms, kind) => hir::ExprKind::Match(
185185
self.lower_expr(expr),
186186
self.arena.alloc_from_iter(arms.iter().map(|x| self.lower_arm(x))),
187-
hir::MatchSource::Normal,
187+
match kind {
188+
MatchKind::Prefix => hir::MatchSource::Normal,
189+
MatchKind::Postfix => hir::MatchSource::Postfix,
190+
},
188191
),
189192
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
190193
ExprKind::Closure(box Closure {

‎compiler/rustc_ast_passes/src/feature_gate.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
564564
gate_all!(generic_const_items, "generic const items are experimental");
565565
gate_all!(unnamed_fields, "unnamed fields are not yet fully implemented");
566566
gate_all!(fn_delegation, "functions delegation is not yet fully implemented");
567+
gate_all!(postfix_match, "postfix match is experimental");
567568

568569
if !visitor.features.never_patterns {
569570
if let Some(spans) = spans.get(&sym::never_patterns) {

‎compiler/rustc_ast_pretty/src/pprust/state/expr.rs‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::pp::Breaks::Inconsistent;
22
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
3-
use ast::ForLoopKind;
3+
use ast::{ForLoopKind,MatchKind};
44
use itertools::{Itertools, Position};
55
use rustc_ast::ptr::P;
66
use rustc_ast::token;
@@ -589,12 +589,22 @@ impl<'a> State<'a> {
589589
self.word_nbsp("loop");
590590
self.print_block_with_attrs(blk, attrs);
591591
}
592-
ast::ExprKind::Match(expr, arms) => {
592+
ast::ExprKind::Match(expr, arms, match_kind) => {
593593
self.cbox(0);
594594
self.ibox(0);
595-
self.word_nbsp("match");
596-
self.print_expr_as_cond(expr);
597-
self.space();
595+
596+
match match_kind {
597+
MatchKind::Prefix => {
598+
self.word_nbsp("match");
599+
self.print_expr_as_cond(expr);
600+
self.space();
601+
}
602+
MatchKind::Postfix => {
603+
self.print_expr_as_cond(expr);
604+
self.word_nbsp(".match");
605+
}
606+
}
607+
598608
self.bopen();
599609
self.print_inner_attributes_no_trailing_hardbreak(attrs);
600610
for arm in arms {

‎compiler/rustc_builtin_macros/src/assert/context.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
245245
ExprKind::Let(_, local_expr, _, _) => {
246246
self.manage_cond_expr(local_expr);
247247
}
248-
ExprKind::Match(local_expr, _) => {
248+
ExprKind::Match(local_expr, ..) => {
249249
self.manage_cond_expr(local_expr);
250250
}
251251
ExprKind::MethodCall(call) => {

‎compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn cs_partial_cmp(
132132
// Reference: https://github.com/rust-lang/rust/pull/103659#issuecomment-1328126354
133133

134134
if !tag_then_data
135-
&& let ExprKind::Match(_, arms) = &mut expr1.kind
135+
&& let ExprKind::Match(_, arms, _) = &mut expr1.kind
136136
&& let Some(last) = arms.last_mut()
137137
&& let PatKind::Wild = last.pat.kind
138138
{

‎compiler/rustc_builtin_macros/src/deriving/debug.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::deriving::generic::ty::*;
22
use crate::deriving::generic::*;
33
use crate::deriving::path_std;
44

5-
use ast::EnumDef;
6-
use rustc_ast::{self as ast, MetaItem};
5+
use rustc_ast::{self as ast, EnumDef, MetaItem};
76
use rustc_expand::base::{Annotatable, ExtCtxt};
87
use rustc_span::symbol::{sym, Ident, Symbol};
98
use rustc_span::Span;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /