diff options
Diffstat (limited to 'tests/ui/borrowck')
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs new file mode 100644 index 00000000000..98f9cdbdef7 --- /dev/null +++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs @@ -0,0 +1,15 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12041 + +use std::sync::mpsc::channel; +use std::thread; + +fn main() { + let (tx, rx) = channel(); + let _t = thread::spawn(move|| -> () { + loop { + let tx = tx; + //~^ ERROR: use of moved value: `tx` + tx.send(1); + } + }); +} diff --git a/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr b/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr new file mode 100644 index 00000000000..627dd193dad --- /dev/null +++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `tx` + --> $DIR/moved-value-in-thread-loop-12041.rs:10:22 + | +LL | let tx = tx; + | ^^ value moved here, in previous iteration of loop + | + = note: move occurs because `tx` has type `std::sync::mpsc::Sender<i32>`, which does not implement the `Copy` trait + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/borrowck/refcell-borrow-comparison-12033.rs b/tests/ui/borrowck/refcell-borrow-comparison-12033.rs new file mode 100644 index 00000000000..de22cedd5b9 --- /dev/null +++ b/tests/ui/borrowck/refcell-borrow-comparison-12033.rs @@ -0,0 +1,9 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12033 + +//@ run-pass +use std::cell::RefCell; + +fn main() { + let x = RefCell::new(0); + if *x.borrow() == 0 {} else {} +} diff --git a/tests/ui/borrowck/string-literal-match-patterns-11869.rs b/tests/ui/borrowck/string-literal-match-patterns-11869.rs new file mode 100644 index 00000000000..4c159e457cf --- /dev/null +++ b/tests/ui/borrowck/string-literal-match-patterns-11869.rs @@ -0,0 +1,18 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11869 + +//@ check-pass +#![allow(dead_code)] + +struct A { + a: String +} + +fn borrow<'a>(binding: &'a A) -> &'a str { + match &*binding.a { + "in" => "in_", + "ref" => "ref_", + ident => ident + } +} + +fn main() {} |
