From 3aaa3941fd62fb4aeea559eafe8a6aa6472eb87d Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 21 Apr 2024 15:43:43 -0300 Subject: Move some tests --- tests/ui/expr/issue-22933-1.rs | 23 +++++++++++++++++++++++ tests/ui/expr/issue-22933-2.rs | 8 ++++++++ tests/ui/expr/issue-22933-2.stderr | 15 +++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 tests/ui/expr/issue-22933-1.rs create mode 100644 tests/ui/expr/issue-22933-2.rs create mode 100644 tests/ui/expr/issue-22933-2.stderr (limited to 'tests/ui/expr') diff --git a/tests/ui/expr/issue-22933-1.rs b/tests/ui/expr/issue-22933-1.rs new file mode 100644 index 00000000000..8f1f5a5048a --- /dev/null +++ b/tests/ui/expr/issue-22933-1.rs @@ -0,0 +1,23 @@ +//@ check-pass + +struct CNFParser { + token: char, +} + +impl CNFParser { + fn is_whitespace(c: char) -> bool { + c == ' ' || c == '\n' + } + + fn consume_whitespace(&mut self) { + self.consume_while(&(CNFParser::is_whitespace)) + } + + fn consume_while(&mut self, p: &dyn Fn(char) -> bool) { + while p(self.token) { + return + } + } +} + +fn main() {} diff --git a/tests/ui/expr/issue-22933-2.rs b/tests/ui/expr/issue-22933-2.rs new file mode 100644 index 00000000000..dfd84b9a79d --- /dev/null +++ b/tests/ui/expr/issue-22933-2.rs @@ -0,0 +1,8 @@ +enum Delicious { + Pie = 0x1, + Apple = 0x2, + ApplePie = Delicious::Apple as isize | Delicious::PIE as isize, + //~^ ERROR no variant or associated item named `PIE` found +} + +fn main() {} diff --git a/tests/ui/expr/issue-22933-2.stderr b/tests/ui/expr/issue-22933-2.stderr new file mode 100644 index 00000000000..8cda8598f3c --- /dev/null +++ b/tests/ui/expr/issue-22933-2.stderr @@ -0,0 +1,15 @@ +error[E0599]: no variant or associated item named `PIE` found for enum `Delicious` in the current scope + --> $DIR/issue-22933-2.rs:4:55 + | +LL | enum Delicious { + | -------------- variant or associated item `PIE` not found for this enum +... +LL | ApplePie = Delicious::Apple as isize | Delicious::PIE as isize, + | ^^^ + | | + | variant or associated item not found in `Delicious` + | help: there is a variant with a similar name: `Pie` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. -- cgit 1.4.1-3-g733a5