diff options
| author | bors <bors@rust-lang.org> | 2024-03-17 13:55:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-17 13:55:27 +0000 |
| commit | 35dfc67d94c47a6c6ae28c46e7dc1c547f772485 (patch) | |
| tree | df9c31ba64bbd80451d693aa160a6131ee1464b1 /tests | |
| parent | a0c20d52e0e83f0bdd5c4f24295def8b276de314 (diff) | |
| parent | 12137462b45d9b3287155e80883ae9251a6cea55 (diff) | |
| download | rust-35dfc67d94c47a6c6ae28c46e7dc1c547f772485.tar.gz rust-35dfc67d94c47a6c6ae28c46e7dc1c547f772485.zip | |
Auto merge of #122637 - matthiaskrgr:rollup-bczj5bp, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #121236 (Don't show suggestion if slice pattern is not top-level) - #121787 (run change tracker even when config parse fails) - #122633 (avoid unnecessary collect()) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs | 20 | ||||
| -rw-r--r-- | tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr | 23 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs new file mode 100644 index 00000000000..135535cd00a --- /dev/null +++ b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs @@ -0,0 +1,20 @@ +pub struct Struct { + a: Vec<Struct>, +} + +impl Struct { + pub fn test(&self) { + if let [Struct { a: [] }] = &self.a { + //~^ ERROR expected an array or slice + //~| ERROR expected an array or slice + println!("matches!") + } + + if let [Struct { a: [] }] = &self.a[..] { + //~^ ERROR expected an array or slice + println!("matches!") + } + } +} + +fn main() {} diff --git a/tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr new file mode 100644 index 00000000000..c28d67604da --- /dev/null +++ b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr @@ -0,0 +1,23 @@ +error[E0529]: expected an array or slice, found `Vec<Struct>` + --> $DIR/suppress-consider-slicing-issue-120605.rs:7:16 + | +LL | if let [Struct { a: [] }] = &self.a { + | ^^^^^^^^^^^^^^^^^^ ------- help: consider slicing here: `&self.a[..]` + | | + | pattern cannot match with input type `Vec<Struct>` + +error[E0529]: expected an array or slice, found `Vec<Struct>` + --> $DIR/suppress-consider-slicing-issue-120605.rs:7:29 + | +LL | if let [Struct { a: [] }] = &self.a { + | ^^ pattern cannot match with input type `Vec<Struct>` + +error[E0529]: expected an array or slice, found `Vec<Struct>` + --> $DIR/suppress-consider-slicing-issue-120605.rs:13:29 + | +LL | if let [Struct { a: [] }] = &self.a[..] { + | ^^ pattern cannot match with input type `Vec<Struct>` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0529`. |
