Add tests for #58319 and #65131

This commit is contained in:
Ryan Levick 2020-03-20 13:24:35 +01:00
parent f4c675c476
commit 5444aded02
3 changed files with 651 additions and 0 deletions

View File

@ -0,0 +1,621 @@
// run-pass
fn main() {}
#[derive(Clone)]
pub struct Little;
#[derive(Clone)]
pub struct Big(
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
Little,
);

View File

@ -0,0 +1,18 @@
fn get_pair(_a: &mut u32, _b: &mut u32) {}
macro_rules! x10 {
($($t:tt)*) => {
$($t)* $($t)* $($t)* $($t)* $($t)*
$($t)* $($t)* $($t)* $($t)* $($t)*
}
}
#[allow(unused_assignments)]
fn main() {
let mut x = 1;
get_pair(&mut x, &mut x);
//~^ ERROR: cannot borrow `x` as mutable more than once at a time
x10! { x10!{ x10!{ if x > 0 { x += 2 } else { x += 1 } } } }
}

View File

@ -0,0 +1,12 @@
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/issue-65131.rs:14:22
|
LL | get_pair(&mut x, &mut x);
| -------- ------ ^^^^^^ second mutable borrow occurs here
| | |
| | first mutable borrow occurs here
| first borrow later used by call
error: aborting due to previous error
For more information about this error, try `rustc --explain E0499`.