-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #96122 - TaKO8Ki:fix-invalid-error-for-suggestion-to-…
…add-slice-in-pattern-matching, r=nagisa Fix an invalid error for a suggestion to add a slice in pattern-matching closes #96103
- Loading branch information
Showing
3 changed files
with
96 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
35 changes: 35 additions & 0 deletions
35
src/test/ui/suggestions/pattern-struct-with-slice-vec-field.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,35 @@ | ||
use std::ops::Deref; | ||
|
||
struct Foo { | ||
v: Vec<u32>, | ||
} | ||
|
||
struct Bar { | ||
v: Vec<u32>, | ||
} | ||
|
||
impl Deref for Bar { | ||
type Target = Vec<u32>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.v | ||
} | ||
} | ||
|
||
fn f(foo: &Foo) { | ||
match foo { | ||
Foo { v: [1, 2] } => {} | ||
//~^ ERROR expected an array or slice, found `Vec<u32> | ||
_ => {} | ||
} | ||
} | ||
|
||
fn bar(bar: &Bar) { | ||
match bar { | ||
Bar { v: [1, 2] } => {} | ||
//~^ ERROR expected an array or slice, found `Vec<u32> | ||
_ => {} | ||
} | ||
} | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr
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,15 @@ | ||
error[E0529]: expected an array or slice, found `Vec<u32>` | ||
--> $DIR/pattern-struct-with-slice-vec-field.rs:21:18 | ||
| | ||
LL | Foo { v: [1, 2] } => {} | ||
| ^^^^^^ pattern cannot match with input type `Vec<u32>` | ||
|
||
error[E0529]: expected an array or slice, found `Vec<u32>` | ||
--> $DIR/pattern-struct-with-slice-vec-field.rs:29:18 | ||
| | ||
LL | Bar { v: [1, 2] } => {} | ||
| ^^^^^^ pattern cannot match with input type `Vec<u32>` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0529`. |