diff --git a/tests/ui/pattern/issue-115599.rs b/tests/ui/pattern/issue-115599.rs index 1521d728d9561..a015ccf70fccc 100644 --- a/tests/ui/pattern/issue-115599.rs +++ b/tests/ui/pattern/issue-115599.rs @@ -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); + +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` in a pattern, `Vec` must be annotated with `#[derive(PartialEq)]` } diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr index 96bcb3051eb72..97f069deb4ac5 100644 --- a/tests/ui/pattern/issue-115599.stderr +++ b/tests/ui/pattern/issue-115599.stderr @@ -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` in a pattern, `Vec` must be annotated with `#[derive(PartialEq)]` + --> $DIR/issue-115599.rs:12:12 | LL | if let CONST_STRING = empty_str {} | ^^^^^^^^^^^^