Skip to content

Commit

Permalink
Update tests/ui/pattern/issue-115599.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
zachs18 committed Jul 26, 2024
1 parent b9186d5 commit 0466b06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions tests/ui/pattern/issue-115599.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const CONST_STRING: String = String::new();
//! Test that a type with derived (Partial)Eq, and thus Structural(Partial)Eq
//! that is a newtype over a type without Structural(Partial)Eq correctly errors.
// `String` in the stdlib no longer derives these traits, so make our own here.
#[derive(PartialEq, Eq, PartialOrd, Ord)]
struct String(Vec<u8>);

const CONST_STRING: String = String(Vec::new());

fn main() {
let empty_str = String::from("");
let empty_str = String(Vec::from(&[]));
if let CONST_STRING = empty_str {}
//~^ ERROR to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
}
4 changes: 2 additions & 2 deletions tests/ui/pattern/issue-115599.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: to use a constant of type `String` in a pattern, `String` must be annotated with `#[derive(PartialEq)]`
--> $DIR/issue-115599.rs:5:12
error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
--> $DIR/issue-115599.rs:12:12
|
LL | if let CONST_STRING = empty_str {}
| ^^^^^^^^^^^^
Expand Down

0 comments on commit 0466b06

Please sign in to comment.