Skip to content

Commit a144613

Browse files
committed
if let guard stabilize
1 parent 48aee7e commit a144613

File tree

141 files changed

+512
-766
lines changed

Some content is hidden

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

141 files changed

+512
-766
lines changed

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(bootstrap, feature(if_let_guard))]
910
#![doc(
1011
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1112
test(attr(deny(warnings)))
@@ -14,7 +15,6 @@
1415
#![feature(array_windows)]
1516
#![feature(associated_type_defaults)]
1617
#![feature(box_patterns)]
17-
#![feature(if_let_guard)]
1818
#![feature(macro_metavar_expr)]
1919
#![feature(rustdoc_internals)]
2020
#![recursion_limit = "256"]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
3333
// tidy-alphabetical-start
3434
#![allow(internal_features)]
35+
#![cfg_attr(bootstrap, feature(if_let_guard))]
3536
#![doc(rust_logo)]
3637
#![feature(box_patterns)]
37-
#![feature(if_let_guard)]
38+
#![feature(exact_size_is_empty)]
3839
#![feature(rustdoc_internals)]
3940
// tidy-alphabetical-end
4041

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
464464
}
465465
};
466466
}
467-
gate_all!(
468-
if_let_guard,
469-
"`if let` guards are experimental",
470-
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
471-
);
472467
gate_all!(
473468
async_trait_bounds,
474469
"`async` trait bounds are unstable",

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
// tidy-alphabetical-start
66
#![allow(internal_features)]
7+
#![cfg_attr(bootstrap, feature(if_let_guard))]
78
#![doc(rust_logo)]
89
#![feature(box_patterns)]
9-
#![feature(if_let_guard)]
1010
#![feature(iter_is_partitioned)]
1111
#![feature(rustdoc_internals)]
1212
// tidy-alphabetical-end

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
5+
#![cfg_attr(bootstrap, feature(if_let_guard))]
56
#![doc(rust_logo)]
67
#![feature(assert_matches)]
78
#![feature(box_patterns)]
89
#![feature(file_buffered)]
9-
#![feature(if_let_guard)]
1010
#![feature(negative_impls)]
1111
#![feature(never_type)]
1212
#![feature(rustc_attrs)]

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
#![allow(internal_features)]
66
#![allow(rustc::diagnostic_outside_of_impl)]
77
#![allow(rustc::untranslatable_diagnostic)]
8+
#![cfg_attr(bootstrap, feature(if_let_guard))]
9+
#![cfg_attr(not(bootstrap), feature(autodiff))]
810
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
911
#![doc(rust_logo)]
1012
#![feature(assert_matches)]
1113
#![feature(autodiff)]
1214
#![feature(box_patterns)]
1315
#![feature(decl_macro)]
14-
#![feature(if_let_guard)]
1516
#![feature(proc_macro_internals)]
1617
#![feature(proc_macro_quote)]
1718
#![feature(rustdoc_internals)]

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(bootstrap, feature(if_let_guard))]
910
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1011
#![doc(rust_logo)]
1112
#![feature(assert_matches)]
1213
#![feature(extern_types)]
1314
#![feature(file_buffered)]
14-
#![feature(if_let_guard)]
1515
#![feature(impl_trait_in_assoc_type)]
1616
#![feature(iter_intersperse)]
1717
#![feature(rustdoc_internals)]

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#![allow(internal_features)]
33
#![allow(rustc::diagnostic_outside_of_impl)]
44
#![allow(rustc::untranslatable_diagnostic)]
5+
#![cfg_attr(bootstrap, feature(if_let_guard))]
56
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
67
#![doc(rust_logo)]
78
#![feature(assert_matches)]
89
#![feature(box_patterns)]
910
#![feature(file_buffered)]
10-
#![feature(if_let_guard)]
1111
#![feature(negative_impls)]
1212
#![feature(rustdoc_internals)]
1313
#![feature(string_from_utf8_lossy_owned)]

compiler/rustc_const_eval/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// tidy-alphabetical-start
22
#![allow(internal_features)]
33
#![allow(rustc::diagnostic_outside_of_impl)]
4+
#![cfg_attr(bootstrap, feature(if_let_guard))]
45
#![doc(rust_logo)]
56
#![feature(assert_matches)]
67
#![feature(box_patterns)]
78
#![feature(decl_macro)]
8-
#![feature(if_let_guard)]
99
#![feature(never_type)]
1010
#![feature(rustdoc_internals)]
1111
#![feature(slice_ptr_get)]

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![allow(rustc::diagnostic_outside_of_impl)]
99
#![allow(rustc::direct_use_of_rustc_type_ir)]
1010
#![allow(rustc::untranslatable_diagnostic)]
11+
#![cfg_attr(bootstrap, feature(if_let_guard))]
1112
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1213
#![doc(rust_logo)]
1314
#![feature(array_windows)]

compiler/rustc_expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// tidy-alphabetical-start
22
#![allow(internal_features)]
33
#![allow(rustc::diagnostic_outside_of_impl)]
4+
#![cfg_attr(bootstrap, feature(if_let_guard))]
45
#![doc(rust_logo)]
56
#![feature(array_windows)]
67
#![feature(associated_type_defaults)]
7-
#![feature(if_let_guard)]
88
#![feature(macro_metavar_expr)]
99
#![feature(proc_macro_diagnostic)]
1010
#![feature(proc_macro_internals)]

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ declare_features! (
236236
(accepted, i128_type, "1.26.0", Some(35118)),
237237
/// Allows the use of `if let` expressions.
238238
(accepted, if_let, "1.0.0", None),
239+
/// Allows `if let` guard in match arms.
240+
(accepted, if_let_guard, "CURRENT_RUSTC_VERSION", Some(51114)),
239241
/// Rescoping temporaries in `if let` to align with Rust 2024.
240242
(accepted, if_let_rescope, "1.84.0", Some(124085)),
241243
/// Allows top level or-patterns (`p | q`) in `if let` and `while let`.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ declare_features! (
532532
(incomplete, guard_patterns, "1.85.0", Some(129967)),
533533
/// Allows using `..=X` as a patterns in slices.
534534
(unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)),
535-
/// Allows `if let` guard in match arms.
536-
(unstable, if_let_guard, "1.47.0", Some(51114)),
537535
/// Allows `impl Trait` to be used inside associated types (RFC 2515).
538536
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
539537
/// Allows `impl Trait` in bindings (`let`).

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ This API is completely unstable and subject to change.
5959
#![allow(internal_features)]
6060
#![allow(rustc::diagnostic_outside_of_impl)]
6161
#![allow(rustc::untranslatable_diagnostic)]
62+
#![cfg_attr(bootstrap, feature(if_let_guard))]
6263
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
6364
#![doc(rust_logo)]
6465
#![feature(assert_matches)]
6566
#![feature(debug_closure_helpers)]
6667
#![feature(gen_blocks)]
67-
#![feature(if_let_guard)]
68+
#![feature(iter_from_coroutine)]
6869
#![feature(iter_intersperse)]
6970
#![feature(never_type)]
7071
#![feature(rustdoc_internals)]

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// tidy-alphabetical-start
22
#![allow(rustc::diagnostic_outside_of_impl)]
33
#![allow(rustc::untranslatable_diagnostic)]
4+
#![cfg_attr(bootstrap, feature(if_let_guard))]
5+
#![feature(array_windows)]
46
#![feature(assert_matches)]
57
#![feature(box_patterns)]
6-
#![feature(if_let_guard)]
78
#![feature(iter_intersperse)]
89
#![feature(never_type)]
910
// tidy-alphabetical-end

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
2222
// tidy-alphabetical-start
2323
#![allow(internal_features)]
24+
#![cfg_attr(bootstrap, feature(if_let_guard))]
2425
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2526
#![doc(rust_logo)]
2627
#![feature(array_windows)]
2728
#![feature(assert_matches)]
2829
#![feature(box_patterns)]
29-
#![feature(if_let_guard)]
3030
#![feature(iter_order_by)]
3131
#![feature(rustc_attrs)]
3232
#![feature(rustdoc_internals)]

compiler/rustc_macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// tidy-alphabetical-start
22
#![allow(rustc::default_hash_types)]
3-
#![feature(if_let_guard)]
3+
#![cfg_attr(bootstrap, feature(if_let_guard))]
44
#![feature(never_type)]
55
#![feature(proc_macro_diagnostic)]
66
#![feature(proc_macro_tracked_env)]

compiler/rustc_metadata/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// tidy-alphabetical-start
22
#![allow(internal_features)]
3+
#![cfg_attr(bootstrap, feature(if_let_guard))]
34
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
45
#![doc(rust_logo)]
56
#![feature(decl_macro)]
67
#![feature(error_iter)]
78
#![feature(file_buffered)]
89
#![feature(gen_blocks)]
9-
#![feature(if_let_guard)]
1010
#![feature(macro_metavar_expr)]
1111
#![feature(min_specialization)]
1212
#![feature(never_type)]

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![allow(rustc::diagnostic_outside_of_impl)]
3030
#![allow(rustc::direct_use_of_rustc_type_ir)]
3131
#![allow(rustc::untranslatable_diagnostic)]
32+
#![cfg_attr(bootstrap, feature(if_let_guard))]
3233
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3334
#![doc(rust_logo)]
3435
#![feature(allocator_api)]
@@ -45,7 +46,6 @@
4546
#![feature(extern_types)]
4647
#![feature(file_buffered)]
4748
#![feature(gen_blocks)]
48-
#![feature(if_let_guard)]
4949
#![feature(intra_doc_pointers)]
5050
#![feature(min_specialization)]
5151
#![feature(negative_impls)]

compiler/rustc_mir_build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// tidy-alphabetical-start
44
#![allow(rustc::diagnostic_outside_of_impl)]
55
#![allow(rustc::untranslatable_diagnostic)]
6+
#![cfg_attr(bootstrap, feature(if_let_guard))]
67
#![feature(assert_matches)]
78
#![feature(box_patterns)]
8-
#![feature(if_let_guard)]
99
#![feature(try_blocks)]
1010
// tidy-alphabetical-end
1111

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// tidy-alphabetical-start
2+
#![cfg_attr(bootstrap, feature(if_let_guard))]
23
#![feature(array_windows)]
34
#![feature(assert_matches)]
45
#![feature(box_patterns)]
56
#![feature(const_type_name)]
67
#![feature(cow_is_borrowed)]
78
#![feature(file_buffered)]
8-
#![feature(if_let_guard)]
99
#![feature(impl_trait_in_assoc_type)]
1010
#![feature(try_blocks)]
1111
#![feature(yeet_expr)]

compiler/rustc_monomorphize/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// tidy-alphabetical-start
2+
#![cfg_attr(bootstrap, feature(if_let_guard))]
23
#![feature(array_windows)]
34
#![feature(file_buffered)]
4-
#![feature(if_let_guard)]
55
#![feature(impl_trait_in_assoc_type)]
66
#![feature(once_cell_get_mut)]
77
// tidy-alphabetical-end

compiler/rustc_parse/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#![allow(internal_features)]
55
#![allow(rustc::diagnostic_outside_of_impl)]
66
#![allow(rustc::untranslatable_diagnostic)]
7+
#![cfg_attr(bootstrap, feature(if_let_guard))]
78
#![feature(assert_matches)]
89
#![feature(box_patterns)]
910
#![feature(debug_closure_helpers)]
10-
#![feature(if_let_guard)]
1111
#![feature(iter_intersperse)]
1212
#![recursion_limit = "256"]
1313
// tidy-alphabetical-end

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,33 +3434,15 @@ impl<'a> Parser<'a> {
34343434
}
34353435

34363436
fn parse_match_arm_guard(&mut self) -> PResult<'a, Option<P<Expr>>> {
3437-
// Used to check the `if_let_guard` feature mostly by scanning
3438-
// `&&` tokens.
3439-
fn has_let_expr(expr: &Expr) -> bool {
3440-
match &expr.kind {
3441-
ExprKind::Binary(BinOp { node: BinOpKind::And, .. }, lhs, rhs) => {
3442-
let lhs_rslt = has_let_expr(lhs);
3443-
let rhs_rslt = has_let_expr(rhs);
3444-
lhs_rslt || rhs_rslt
3445-
}
3446-
ExprKind::Let(..) => true,
3447-
_ => false,
3448-
}
3449-
}
34503437
if !self.eat_keyword(exp!(If)) {
34513438
// No match arm guard present.
34523439
return Ok(None);
34533440
}
34543441

3455-
let if_span = self.prev_token.span;
34563442
let mut cond = self.parse_match_guard_condition()?;
34573443

34583444
CondChecker::new(self, LetChainsPolicy::AlwaysAllowed).visit_expr(&mut cond);
34593445

3460-
if has_let_expr(&cond) {
3461-
let span = if_span.to(cond.span);
3462-
self.psess.gated_spans.gate(sym::if_let_guard, span);
3463-
}
34643446
Ok(Some(cond))
34653447
}
34663448

compiler/rustc_resolve/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#![allow(internal_features)]
1111
#![allow(rustc::diagnostic_outside_of_impl)]
1212
#![allow(rustc::untranslatable_diagnostic)]
13+
#![cfg_attr(bootstrap, feature(if_let_guard))]
1314
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1415
#![doc(rust_logo)]
1516
#![feature(assert_matches)]
1617
#![feature(box_patterns)]
17-
#![feature(if_let_guard)]
1818
#![feature(iter_intersperse)]
1919
#![feature(rustc_attrs)]
2020
#![feature(rustdoc_internals)]

compiler/rustc_span/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
1818
// tidy-alphabetical-start
1919
#![allow(internal_features)]
20+
#![cfg_attr(bootstrap, feature(if_let_guard))]
2021
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2122
#![doc(rust_logo)]
2223
#![feature(array_windows)]
2324
#![feature(cfg_select)]
2425
#![feature(core_io_borrowed_buf)]
25-
#![feature(if_let_guard)]
2626
#![feature(map_try_insert)]
2727
#![feature(negative_impls)]
2828
#![feature(read_buf)]

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
#![allow(internal_features)]
1515
#![allow(rustc::diagnostic_outside_of_impl)]
1616
#![allow(rustc::untranslatable_diagnostic)]
17+
#![cfg_attr(bootstrap, feature(if_let_guard))]
1718
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1819
#![doc(rust_logo)]
1920
#![feature(assert_matches)]
2021
#![feature(associated_type_defaults)]
2122
#![feature(box_patterns)]
22-
#![feature(if_let_guard)]
23+
#![feature(cfg_version)]
2324
#![feature(iter_intersperse)]
2425
#![feature(iterator_try_reduce)]
2526
#![feature(never_type)]

compiler/rustc_ty_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(bootstrap, feature(if_let_guard))]
910
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1011
#![doc(rust_logo)]
1112
#![feature(assert_matches)]
1213
#![feature(associated_type_defaults)]
1314
#![feature(box_patterns)]
14-
#![feature(if_let_guard)]
1515
#![feature(iterator_try_collect)]
1616
#![feature(never_type)]
1717
#![feature(rustdoc_internals)]

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
#![feature(f128)]
155155
#![feature(freeze_impls)]
156156
#![feature(fundamental)]
157-
#![feature(if_let_guard)]
158157
#![feature(intra_doc_pointers)]
159158
#![feature(intrinsics)]
160159
#![feature(lang_items)]

library/std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@
294294
#![feature(f128)]
295295
#![feature(ffi_const)]
296296
#![feature(formatting_options)]
297-
#![feature(if_let_guard)]
298297
#![feature(intra_doc_pointers)]
299298
#![feature(iter_advance_by)]
300299
#![feature(iter_next_chunk)]

0 commit comments

Comments
 (0)