Skip to content

Commit 6fe74d9

Browse files
committed
if let stabilization PR
1 parent 1973872 commit 6fe74d9

File tree

69 files changed

+677
-92
lines changed

Some content is hidden

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

69 files changed

+677
-92
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
#![cfg_attr(bootstrap, feature(let_chains))]
1011
#![doc(
1112
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
@@ -15,7 +16,6 @@
1516
#![feature(array_windows)]
1617
#![feature(associated_type_defaults)]
1718
#![feature(box_patterns)]
18-
#![feature(if_let_guard)]
1919
#![feature(negative_impls)]
2020
#![feature(never_type)]
2121
#![feature(rustdoc_internals)]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
3333
// tidy-alphabetical-start
3434
#![allow(internal_features)]
35+
#![cfg_attr(bootstrap, feature(if_let_guard))]
3536
#![cfg_attr(bootstrap, feature(let_chains))]
3637
#![doc(rust_logo)]
3738
#![feature(assert_matches)]
3839
#![feature(box_patterns)]
3940
#![feature(exact_size_is_empty)]
40-
#![feature(if_let_guard)]
4141
#![feature(rustdoc_internals)]
4242
// tidy-alphabetical-end
4343

compiler/rustc_ast_passes/src/lib.rs

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

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
5+
#![cfg_attr(bootstrap, feature(if_let_guard))]
56
#![cfg_attr(bootstrap, feature(let_chains))]
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(never_type)]
1313
#![feature(rustc_attrs)]

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +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))]
89
#![cfg_attr(bootstrap, feature(let_chains))]
910
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1011
#![doc(rust_logo)]
1112
#![feature(assert_matches)]
1213
#![feature(autodiff)]
1314
#![feature(box_patterns)]
1415
#![feature(decl_macro)]
15-
#![feature(if_let_guard)]
1616
#![feature(proc_macro_internals)]
1717
#![feature(proc_macro_quote)]
1818
#![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,14 +6,14 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(bootstrap, feature(if_let_guard))]
910
#![cfg_attr(bootstrap, feature(let_chains))]
1011
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1112
#![doc(rust_logo)]
1213
#![feature(assert_matches)]
1314
#![feature(exact_size_is_empty)]
1415
#![feature(extern_types)]
1516
#![feature(file_buffered)]
16-
#![feature(if_let_guard)]
1717
#![feature(impl_trait_in_assoc_type)]
1818
#![feature(iter_intersperse)]
1919
#![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,13 +2,13 @@
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
#![cfg_attr(bootstrap, feature(let_chains))]
67
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
78
#![doc(rust_logo)]
89
#![feature(assert_matches)]
910
#![feature(box_patterns)]
1011
#![feature(file_buffered)]
11-
#![feature(if_let_guard)]
1212
#![feature(negative_impls)]
1313
#![feature(rustdoc_internals)]
1414
#![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,12 +1,12 @@
11
// tidy-alphabetical-start
22
#![allow(internal_features)]
33
#![allow(rustc::diagnostic_outside_of_impl)]
4+
#![cfg_attr(bootstrap, feature(if_let_guard))]
45
#![cfg_attr(bootstrap, feature(let_chains))]
56
#![doc(rust_logo)]
67
#![feature(assert_matches)]
78
#![feature(box_patterns)]
89
#![feature(decl_macro)]
9-
#![feature(if_let_guard)]
1010
#![feature(never_type)]
1111
#![feature(rustdoc_internals)]
1212
#![feature(slice_ptr_get)]

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![allow(internal_features)]
88
#![allow(rustc::diagnostic_outside_of_impl)]
99
#![allow(rustc::untranslatable_diagnostic)]
10+
#![cfg_attr(bootstrap, feature(if_let_guard))]
1011
#![cfg_attr(bootstrap, feature(let_chains))]
1112
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1213
#![doc(rust_logo)]
@@ -17,7 +18,6 @@
1718
#![feature(box_patterns)]
1819
#![feature(default_field_values)]
1920
#![feature(error_reporter)]
20-
#![feature(if_let_guard)]
2121
#![feature(negative_impls)]
2222
#![feature(never_type)]
2323
#![feature(rustc_attrs)]

compiler/rustc_expand/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
#![cfg_attr(bootstrap, feature(let_chains))]
56
#![doc(rust_logo)]
67
#![feature(array_windows)]
78
#![feature(associated_type_defaults)]
8-
#![feature(if_let_guard)]
99
#![feature(macro_metavar_expr)]
1010
#![feature(map_try_insert)]
1111
#![feature(proc_macro_diagnostic)]

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ declare_features! (
232232
(accepted, i128_type, "1.26.0", Some(35118)),
233233
/// Allows the use of `if let` expressions.
234234
(accepted, if_let, "1.0.0", None),
235+
/// Allows `if let` guard in match arms.
236+
(accepted, if_let_guard, "CURRENT_RUSTC_VERSION", Some(51114)),
235237
/// Rescoping temporaries in `if let` to align with Rust 2024.
236238
(accepted, if_let_rescope, "1.84.0", Some(124085)),
237239
/// 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
@@ -531,8 +531,6 @@ declare_features! (
531531
(incomplete, guard_patterns, "1.85.0", Some(129967)),
532532
/// Allows using `..=X` as a patterns in slices.
533533
(unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)),
534-
/// Allows `if let` guard in match arms.
535-
(unstable, if_let_guard, "1.47.0", Some(51114)),
536534
/// Allows `impl Trait` to be used inside associated types (RFC 2515).
537535
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
538536
/// Allows `impl Trait` in bindings (`let`).

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +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
#![cfg_attr(bootstrap, feature(let_chains))]
6364
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
6465
#![doc(rust_logo)]
6566
#![feature(assert_matches)]
6667
#![feature(coroutines)]
6768
#![feature(debug_closure_helpers)]
68-
#![feature(if_let_guard)]
6969
#![feature(iter_from_coroutine)]
7070
#![feature(iter_intersperse)]
7171
#![feature(never_type)]

compiler/rustc_hir_typeck/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(rustc::diagnostic_outside_of_impl)]
33
#![allow(rustc::untranslatable_diagnostic)]
4+
#![cfg_attr(bootstrap, feature(if_let_guard))]
45
#![cfg_attr(bootstrap, feature(let_chains))]
56
#![feature(array_windows)]
67
#![feature(box_patterns)]
7-
#![feature(if_let_guard)]
88
#![feature(iter_intersperse)]
99
#![feature(never_type)]
1010
#![feature(try_blocks)]

compiler/rustc_lint/src/lib.rs

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

compiler/rustc_macros/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
22
#![allow(rustc::default_hash_types)]
3+
#![cfg_attr(bootstrap, feature(if_let_guard))]
34
#![cfg_attr(bootstrap, feature(let_chains))]
4-
#![feature(if_let_guard)]
55
#![feature(never_type)]
66
#![feature(proc_macro_diagnostic)]
77
#![feature(proc_macro_span)]

compiler/rustc_metadata/src/lib.rs

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

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#![allow(internal_features)]
2929
#![allow(rustc::diagnostic_outside_of_impl)]
3030
#![allow(rustc::untranslatable_diagnostic)]
31+
#![cfg_attr(bootstrap, feature(if_let_guard))]
3132
#![cfg_attr(bootstrap, feature(let_chains))]
3233
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3334
#![doc(rust_logo)]
@@ -45,7 +46,6 @@
4546
#![feature(discriminant_kind)]
4647
#![feature(extern_types)]
4748
#![feature(file_buffered)]
48-
#![feature(if_let_guard)]
4949
#![feature(intra_doc_pointers)]
5050
#![feature(iter_from_coroutine)]
5151
#![feature(min_specialization)]

compiler/rustc_mir_build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
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
#![cfg_attr(bootstrap, feature(let_chains))]
78
#![feature(assert_matches)]
89
#![feature(box_patterns)]
9-
#![feature(if_let_guard)]
1010
#![feature(try_blocks)]
1111
// tidy-alphabetical-end
1212

compiler/rustc_mir_transform/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
2+
#![cfg_attr(bootstrap, feature(if_let_guard))]
23
#![cfg_attr(bootstrap, feature(let_chains))]
34
#![feature(array_windows)]
45
#![feature(assert_matches)]
56
#![feature(box_patterns)]
67
#![feature(const_type_name)]
78
#![feature(cow_is_borrowed)]
89
#![feature(file_buffered)]
9-
#![feature(if_let_guard)]
1010
#![feature(impl_trait_in_assoc_type)]
1111
#![feature(map_try_insert)]
1212
#![feature(never_type)]

compiler/rustc_monomorphize/src/lib.rs

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

compiler/rustc_parse/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
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
#![cfg_attr(bootstrap, feature(let_chains))]
89
#![feature(assert_matches)]
910
#![feature(box_patterns)]
1011
#![feature(debug_closure_helpers)]
11-
#![feature(if_let_guard)]
1212
#![feature(iter_intersperse)]
1313
#![feature(string_from_utf8_lossy_owned)]
1414
#![recursion_limit = "256"]

compiler/rustc_resolve/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
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
#![cfg_attr(bootstrap, feature(let_chains))]
1415
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1516
#![doc(rust_logo)]
1617
#![feature(assert_matches)]
1718
#![feature(box_patterns)]
18-
#![feature(if_let_guard)]
1919
#![feature(iter_intersperse)]
2020
#![feature(rustc_attrs)]
2121
#![feature(rustdoc_internals)]

compiler/rustc_span/src/lib.rs

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

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
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
#![cfg_attr(bootstrap, feature(let_chains))]
1819
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1920
#![doc(rust_logo)]
2021
#![feature(assert_matches)]
2122
#![feature(associated_type_defaults)]
2223
#![feature(box_patterns)]
2324
#![feature(cfg_version)]
24-
#![feature(if_let_guard)]
2525
#![feature(iter_intersperse)]
2626
#![feature(iterator_try_reduce)]
2727
#![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,13 +6,13 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(bootstrap, feature(if_let_guard))]
910
#![cfg_attr(bootstrap, feature(let_chains))]
1011
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1112
#![doc(rust_logo)]
1213
#![feature(assert_matches)]
1314
#![feature(associated_type_defaults)]
1415
#![feature(box_patterns)]
15-
#![feature(if_let_guard)]
1616
#![feature(iterator_try_collect)]
1717
#![feature(never_type)]
1818
#![feature(rustdoc_internals)]

tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Ensure if let guards can be used in constant expressions.
2+
23
//@ build-pass
4+
//@revisions: edition2021 edition2024
5+
//@[edition2021] edition:2021
6+
//@[edition2024] edition:2024
37

48
#![feature(if_let_guard)]
59

tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// For let guards temporaries live until the end of the arm.
44

55
//@ run-pass
6+
//@revisions: edition2021 edition2024
7+
//@[edition2021] edition:2021
8+
//@[edition2024] edition:2024
69

710
#![feature(if_let_guard)]
811
#![allow(irrefutable_let_patterns)]
@@ -49,11 +52,7 @@ fn main() {
4952
if_guard(2);
5053
if_let_guard(1);
5154
if_let_guard(2);
52-
let expected = [
53-
1, 2, !2, 3, !3, !1,
54-
1, 2, !2, 3, !3, !1,
55-
1, 2, 3, !3, !2, !1,
56-
1, 2, 3, !3, !2, !1,
57-
];
55+
let expected =
56+
[1, 2, !2, 3, !3, !1, 1, 2, !2, 3, !3, !1, 1, 2, 3, !3, !2, !1, 1, 2, 3, !3, !2, !1];
5857
assert_eq!(*A.lock().unwrap(), expected);
5958
}

tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// regression test for #118593
33

44
//@ check-pass
5+
//@revisions: edition2021 edition2024
6+
//@[edition2021] edition:2021
7+
//@[edition2024] edition:2024
58

69
#![feature(if_let_guard)]
710
#![feature(let_chains)]

0 commit comments

Comments
 (0)