-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #127369 - Jules-Bertholet:match-ergonomics-2021, r=Na…
…drieril Match ergonomics 2024: align with RFC again - `&` matches `&mut` on old editions - Add some more tests r? ``@Nadrieril`` cc #123076 ``@rustbot`` label A-edition-2024 A-patterns
- Loading branch information
Showing
9 changed files
with
142 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 7 additions & 29 deletions
36
tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2021.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,15 @@ | ||
//@ run-pass | ||
//@ edition: 2021 | ||
//@ revisions: classic structural both | ||
#![allow(incomplete_features)] | ||
#![feature(ref_pat_eat_one_layer_2024)] | ||
#![cfg_attr(any(classic, both), feature(ref_pat_eat_one_layer_2024))] | ||
#![cfg_attr(any(structural, both), feature(ref_pat_eat_one_layer_2024_structural))] | ||
|
||
pub fn main() { | ||
if let Some(Some(&x)) = &Some(&Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(Some(&x)) = &Some(Some(&0)) { | ||
if let &Some(Some(x)) = &Some(&mut Some(0)) { | ||
let _: &u32 = x; | ||
//~^ ERROR: mismatched types | ||
} | ||
if let Some(Some(&&x)) = &Some(Some(&0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(&Some(x)) = &Some(Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(Some(&x)) = &Some(&Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(&Some(&mut x)) = &mut Some(&Some(0)) { | ||
//~^ ERROR: mismatched types | ||
if let Some(&x) = Some(&mut 0) { | ||
let _: u32 = x; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2021_fail.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//@ edition: 2021 | ||
#![allow(incomplete_features)] | ||
#![feature(ref_pat_eat_one_layer_2024)] | ||
pub fn main() { | ||
if let Some(Some(&x)) = &Some(&Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(Some(&x)) = &Some(Some(&0)) { | ||
let _: &u32 = x; | ||
//~^ ERROR: mismatched types | ||
} | ||
if let Some(Some(&&x)) = &Some(Some(&0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(&Some(x)) = &Some(Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(Some(&x)) = &Some(&Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
if let Some(&Some(&mut x)) = &mut Some(&Some(0)) { | ||
//~^ ERROR: mismatched types | ||
let _: u32 = x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters