diff options
Diffstat (limited to 'tests/ui/pattern')
7 files changed, 80 insertions, 4 deletions
diff --git a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr index 21d09ec44c4..6d430184628 100644 --- a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr +++ b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr @@ -6,6 +6,7 @@ LL | const EMPTY: Vec<()> = Vec::new(); ... LL | EMPTY => {} | ^^^^^ constant of non-structural type + | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns diff --git a/tests/ui/pattern/deref-patterns/recursion-limit.stderr b/tests/ui/pattern/deref-patterns/recursion-limit.stderr index 9a83d1eb5a4..f6aa92b23ad 100644 --- a/tests/ui/pattern/deref-patterns/recursion-limit.stderr +++ b/tests/ui/pattern/deref-patterns/recursion-limit.stderr @@ -10,7 +10,13 @@ error[E0277]: the trait bound `Cyclic: DerefPure` is not satisfied --> $DIR/recursion-limit.rs:18:9 | LL | () => {} - | ^^ the trait `DerefPure` is not implemented for `Cyclic` + | ^^ unsatisfied trait bound + | +help: the trait `DerefPure` is not implemented for `Cyclic` + --> $DIR/recursion-limit.rs:8:1 + | +LL | struct Cyclic; + | ^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr index 983ce27865c..0b1e8ef4978 100644 --- a/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr +++ b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr @@ -2,7 +2,13 @@ error[E0277]: the trait bound `MyPointer: DerefPure` is not satisfied --> $DIR/unsatisfied-bounds.rs:17:9 | LL | () => {} - | ^^ the trait `DerefPure` is not implemented for `MyPointer` + | ^^ unsatisfied trait bound + | +help: the trait `DerefPure` is not implemented for `MyPointer` + --> $DIR/unsatisfied-bounds.rs:4:1 + | +LL | struct MyPointer; + | ^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr index 69d10728ccd..ed465ea0bba 100644 --- a/tests/ui/pattern/issue-115599.stderr +++ b/tests/ui/pattern/issue-115599.stderr @@ -6,6 +6,7 @@ LL | const CONST_STRING: String = String::new(); ... LL | if let CONST_STRING = empty_str {} | ^^^^^^^^^^^^ constant of non-structural type + | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<u8>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns diff --git a/tests/ui/pattern/match-with-at-binding-8391.rs b/tests/ui/pattern/match-with-at-binding-8391.rs new file mode 100644 index 00000000000..bc4e7be7989 --- /dev/null +++ b/tests/ui/pattern/match-with-at-binding-8391.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/8391 +//@ run-pass + +fn main() { + let x = match Some(1) { + ref _y @ Some(_) => 1, + None => 2, + }; + assert_eq!(x, 1); +} diff --git a/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs b/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs new file mode 100644 index 00000000000..1a67caf021c --- /dev/null +++ b/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs @@ -0,0 +1,52 @@ +// https://github.com/rust-lang/rust/issues/8860 +//@ run-pass +// FIXME(static_mut_refs): this could use an atomic +#![allow(static_mut_refs)] +#![allow(dead_code)] + +static mut DROP: isize = 0; +static mut DROP_S: isize = 0; +static mut DROP_T: isize = 0; + +struct S; +impl Drop for S { + fn drop(&mut self) { + unsafe { + DROP_S += 1; + DROP += 1; + } + } +} +fn f(ref _s: S) {} + +struct T { i: isize } +impl Drop for T { + fn drop(&mut self) { + unsafe { + DROP_T += 1; + DROP += 1; + } + } +} +fn g(ref _t: T) {} + +fn do_test() { + let s = S; + f(s); + unsafe { + assert_eq!(1, DROP); + assert_eq!(1, DROP_S); + } + let t = T { i: 1 }; + g(t); + unsafe { assert_eq!(1, DROP_T); } +} + +fn main() { + do_test(); + unsafe { + assert_eq!(2, DROP); + assert_eq!(1, DROP_S); + assert_eq!(1, DROP_T); + } +} diff --git a/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr b/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr index f7fd4a4cc29..9580bab2b4f 100644 --- a/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr +++ b/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr @@ -4,7 +4,7 @@ warning: struct `Foo` is never constructed LL | struct Foo; | ^^^ | - = note: `#[warn(dead_code)]` on by default + = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default warning: unused closure that must be used --> $DIR/skipped-ref-pats-issue-125058.rs:11:5 @@ -18,7 +18,7 @@ LL | | }; | |_____^ | = note: closures are lazy and do nothing unless called - = note: `#[warn(unused_must_use)]` on by default + = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default warning: 2 warnings emitted |
