Skip to content

Commit 11320a1

Browse files
committed
revert ability use let chains in if let guard, fixed tests
1 parent d5eb84e commit 11320a1

File tree

11 files changed

+119
-41
lines changed

11 files changed

+119
-41
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,20 +3405,14 @@ impl<'a> Parser<'a> {
34053405
}
34063406

34073407
fn parse_match_arm_guard(&mut self) -> PResult<'a, Option<P<Expr>>> {
3408-
// Used to check the `if_let_guard` feature mostly by scanning
3409-
// `&&` tokens.
34103408
if !self.eat_keyword(exp!(If)) {
34113409
// No match arm guard present.
34123410
return Ok(None);
34133411
}
34143412

34153413
let mut cond = self.parse_match_guard_condition()?;
34163414

3417-
CondChecker::new(
3418-
self,
3419-
LetChainsPolicy::EditionDependent { current_edition: Edition::Edition2024 },
3420-
)
3421-
.visit_expr(&mut cond);
3415+
CondChecker::new(self, LetChainsPolicy::AlwaysAllowed).visit_expr(&mut cond);
34223416

34233417
Ok(Some(cond))
34243418
}

library/core/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
#![feature(cfg_ub_checks)]
145145
#![feature(const_precise_live_drops)]
146146
#![feature(const_trait_impl)]
147-
#![feature(core_float_math)]
148147
#![feature(decl_macro)]
149148
#![feature(deprecated_suggestion)]
150149
#![feature(doc_cfg)]
@@ -182,7 +181,6 @@
182181
#![feature(transparent_unions)]
183182
#![feature(try_blocks)]
184183
#![feature(unboxed_closures)]
185-
#![feature(unsigned_signed_diff)]
186184
#![feature(unsized_fn_params)]
187185
#![feature(with_negative_coherence)]
188186
// tidy-alphabetical-end

library/std/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@
326326
#![feature(try_blocks)]
327327
#![feature(try_trait_v2)]
328328
#![feature(type_alias_impl_trait)]
329+
#![feature(unsigned_signed_diff)]
329330
// tidy-alphabetical-end
330331
//
331332
// Library features (core):
@@ -373,7 +374,6 @@
373374
#![feature(sync_unsafe_cell)]
374375
#![feature(temporary_niche_types)]
375376
#![feature(ub_checks)]
376-
#![feature(unsigned_signed_diff)]
377377
#![feature(used_with_arg)]
378378
// tidy-alphabetical-end
379379
//
@@ -723,7 +723,6 @@ pub use core::todo;
723723
// Re-export built-in macros defined through core.
724724
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
725725
#[allow(deprecated)]
726-
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
727726
pub use core::{
728727
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
729728
env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,82 @@
11
error: cannot borrow value as mutable more than once at a time
2-
--> $DIR/conflicting_bindings.rs:5:9
2+
--> $DIR/conflicting_bindings.rs:9:9
33
|
44
LL | let ref mut y @ ref mut z = x;
55
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
66
| |
77
| value is mutably borrowed by `y` here
88

99
error: cannot borrow value as mutable more than once at a time
10-
--> $DIR/conflicting_bindings.rs:7:14
10+
--> $DIR/conflicting_bindings.rs:11:14
1111
|
1212
LL | let Some(ref mut y @ ref mut z) = x else { return };
1313
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
1414
| |
1515
| value is mutably borrowed by `y` here
1616

1717
error: cannot borrow value as mutable more than once at a time
18-
--> $DIR/conflicting_bindings.rs:9:17
18+
--> $DIR/conflicting_bindings.rs:13:17
1919
|
2020
LL | if let Some(ref mut y @ ref mut z) = x {}
2121
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
2222
| |
2323
| value is mutably borrowed by `y` here
2424

2525
error: cannot borrow value as mutable more than once at a time
26-
--> $DIR/conflicting_bindings.rs:11:17
26+
--> $DIR/conflicting_bindings.rs:15:17
2727
|
2828
LL | if let Some(ref mut y @ ref mut z) = x && true {}
2929
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
3030
| |
3131
| value is mutably borrowed by `y` here
3232

3333
error: cannot borrow value as mutable more than once at a time
34-
--> $DIR/conflicting_bindings.rs:13:43
34+
--> $DIR/conflicting_bindings.rs:17:43
3535
|
3636
LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && true {}
3737
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
3838
| |
3939
| value is mutably borrowed by `y` here
4040

4141
error: cannot borrow value as mutable more than once at a time
42-
--> $DIR/conflicting_bindings.rs:15:20
42+
--> $DIR/conflicting_bindings.rs:19:20
4343
|
4444
LL | while let Some(ref mut y @ ref mut z) = x {}
4545
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
4646
| |
4747
| value is mutably borrowed by `y` here
4848

4949
error: cannot borrow value as mutable more than once at a time
50-
--> $DIR/conflicting_bindings.rs:17:20
50+
--> $DIR/conflicting_bindings.rs:21:20
5151
|
5252
LL | while let Some(ref mut y @ ref mut z) = x && true {}
5353
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
5454
| |
5555
| value is mutably borrowed by `y` here
5656

5757
error: cannot borrow value as mutable more than once at a time
58-
--> $DIR/conflicting_bindings.rs:20:9
58+
--> $DIR/conflicting_bindings.rs:24:9
5959
|
6060
LL | ref mut y @ ref mut z => {}
6161
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
6262
| |
6363
| value is mutably borrowed by `y` here
6464

6565
error: cannot borrow value as mutable more than once at a time
66-
--> $DIR/conflicting_bindings.rs:23:24
66+
--> $DIR/conflicting_bindings.rs:27:24
6767
|
6868
LL | () if let Some(ref mut y @ ref mut z) = x => {}
6969
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
7070
| |
7171
| value is mutably borrowed by `y` here
7272

73-
error: aborting due to 9 previous errors
73+
error: cannot borrow value as mutable more than once at a time
74+
--> $DIR/conflicting_bindings.rs:31:51
75+
|
76+
LL | () if let Some(()) = Some(()) && let Some(ref mut y @ ref mut z) = x && true => {}
77+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
78+
| |
79+
| value is mutably borrowed by `y` here
80+
81+
error: aborting due to 10 previous errors
7482

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
error: cannot borrow value as mutable more than once at a time
2+
--> $DIR/conflicting_bindings.rs:9:9
3+
|
4+
LL | let ref mut y @ ref mut z = x;
5+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
6+
| |
7+
| value is mutably borrowed by `y` here
8+
9+
error: cannot borrow value as mutable more than once at a time
10+
--> $DIR/conflicting_bindings.rs:11:14
11+
|
12+
LL | let Some(ref mut y @ ref mut z) = x else { return };
13+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
14+
| |
15+
| value is mutably borrowed by `y` here
16+
17+
error: cannot borrow value as mutable more than once at a time
18+
--> $DIR/conflicting_bindings.rs:13:17
19+
|
20+
LL | if let Some(ref mut y @ ref mut z) = x {}
21+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
22+
| |
23+
| value is mutably borrowed by `y` here
24+
25+
error: cannot borrow value as mutable more than once at a time
26+
--> $DIR/conflicting_bindings.rs:15:17
27+
|
28+
LL | if let Some(ref mut y @ ref mut z) = x && true {}
29+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
30+
| |
31+
| value is mutably borrowed by `y` here
32+
33+
error: cannot borrow value as mutable more than once at a time
34+
--> $DIR/conflicting_bindings.rs:17:43
35+
|
36+
LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && true {}
37+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
38+
| |
39+
| value is mutably borrowed by `y` here
40+
41+
error: cannot borrow value as mutable more than once at a time
42+
--> $DIR/conflicting_bindings.rs:19:20
43+
|
44+
LL | while let Some(ref mut y @ ref mut z) = x {}
45+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
46+
| |
47+
| value is mutably borrowed by `y` here
48+
49+
error: cannot borrow value as mutable more than once at a time
50+
--> $DIR/conflicting_bindings.rs:21:20
51+
|
52+
LL | while let Some(ref mut y @ ref mut z) = x && true {}
53+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
54+
| |
55+
| value is mutably borrowed by `y` here
56+
57+
error: cannot borrow value as mutable more than once at a time
58+
--> $DIR/conflicting_bindings.rs:24:9
59+
|
60+
LL | ref mut y @ ref mut z => {}
61+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
62+
| |
63+
| value is mutably borrowed by `y` here
64+
65+
error: cannot borrow value as mutable more than once at a time
66+
--> $DIR/conflicting_bindings.rs:27:24
67+
|
68+
LL | () if let Some(ref mut y @ ref mut z) = x => {}
69+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
70+
| |
71+
| value is mutably borrowed by `y` here
72+
73+
error: cannot borrow value as mutable more than once at a time
74+
--> $DIR/conflicting_bindings.rs:31:51
75+
|
76+
LL | () if let Some(()) = Some(()) && let Some(ref mut y @ ref mut z) = x && true => {}
77+
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here
78+
| |
79+
| value is mutably borrowed by `y` here
80+
81+
error: aborting due to 10 previous errors
82+

tests/ui/pattern/usefulness/conflicting_bindings.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#![feature(let_chains)]
1+
//@revisions: edition2021 edition2024
2+
//@[edition2021] edition:2021
3+
//@[edition2024] edition:2024
4+
5+
#![cfg_attr(edition2021, feature(let_chains))]
26

37
fn main() {
48
let mut x = Some(String::new());
@@ -23,4 +27,9 @@ fn main() {
2327
() if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once
2428
_ => {}
2529
}
30+
match () {
31+
() if let Some(()) = Some(()) && let Some(ref mut y @ ref mut z) = x && true => {}
32+
//~^ ERROR: mutable more than once
33+
_ => {}
34+
}
2635
}

tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
//@[edition2021] edition:2021
55
//@[edition2024] edition:2024
66

7-
#![feature(let_chains)]
8-
97
macro_rules! m {
108
(pattern $i:ident) => { Some($i) };
119
(expression $e:expr) => { $e };

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//@[edition2021] edition:2021
66
//@[edition2024] edition:2024
77

8-
#![feature(let_chains)]
98
#![allow(irrefutable_let_patterns)]
109

1110
fn lhs_let(opt: Option<bool>) {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#[rustfmt::skip]
1+
// https://github.com/rust-lang/rust/issues/93150
2+
//@ run-pass
3+
24
fn main() {
35
match true {
46
_ if let true = true && true => {}
5-
//~^ ERROR `let` expressions in this position are unstable
67
_ => {}
78
}
89
}

tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//@ run-pass
2+
//@revisions: edition2021 edition2024
3+
//@[edition2021] edition:2021
4+
//@[edition2024] edition:2024
25

3-
#![feature(let_chains)]
6+
#![cfg_attr(edition2021, feature(let_chains))]
47

58
fn check_if_let(opt: Option<Option<Option<i32>>>, value: i32) -> bool {
69
if let Some(first) = opt

0 commit comments

Comments
 (0)