Auto merge of #49836 - nikomatsakis:nll-facts-prep, r=pnkfelix
prep work for using timely dataflow with NLL Two major changes: **Two-phase borrows are overhauled.** We no longer have two bits per borrow. Instead, we track -- for each borrow -- an (optional) "activation point". Then, for each point P where the borrow is in scope, we check where P falls relative to the activation point. If P is between the reservation point and the activation point, then this is the "reservation" phase of the borrow, else the borrow is considered active. This is simpler and means that the dataflow doesn't have to care about 2-phase at all, at last not yet. **We no longer support using the MIR borrow checker without NLL.** It is going to be increasingly untenable to support lexical mode as we go forward, I think, and also of increasingly little value. This also exposed a few bugs in NLL mode due to increased testing. r? @pnkfelix cc @bobtwinkles
This commit is contained in:
commit
881a7cd86e
145 changed files with 1149 additions and 1136 deletions
|
|
@ -26,10 +26,12 @@ fn foo(a: &mut i32) {
|
|||
inside_closure(a)
|
||||
};
|
||||
outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
//[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
//[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
|
||||
|
||||
outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
//[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
//[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
|
||||
|
||||
drop(bar);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
// ignore-sparc
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir -Z nll
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ fn a() {
|
|||
let mut x = 3;
|
||||
let c1 = || x = 4;
|
||||
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
|
||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn b() {
|
||||
|
|
@ -37,6 +38,7 @@ fn b() {
|
|||
let c1 = || set(&mut x);
|
||||
let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x`
|
||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn c() {
|
||||
|
|
@ -44,6 +46,7 @@ fn c() {
|
|||
let c1 = || set(&mut x);
|
||||
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
|
||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn d() {
|
||||
|
|
@ -51,6 +54,7 @@ fn d() {
|
|||
let c2 = || x * 5;
|
||||
x = 5; //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||
drop(c2);
|
||||
}
|
||||
|
||||
fn e() {
|
||||
|
|
@ -58,6 +62,7 @@ fn e() {
|
|||
let c1 = || get(&x);
|
||||
x = 5; //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn f() {
|
||||
|
|
@ -65,6 +70,7 @@ fn f() {
|
|||
let c1 = || get(&*x);
|
||||
*x = 5; //[ast]~ ERROR cannot assign to `*x`
|
||||
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn g() {
|
||||
|
|
@ -76,6 +82,7 @@ fn g() {
|
|||
let c1 = || get(&*x.f);
|
||||
*x.f = 5; //[ast]~ ERROR cannot assign to `*x.f`
|
||||
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn h() {
|
||||
|
|
@ -87,6 +94,7 @@ fn h() {
|
|||
let c1 = || get(&*x.f);
|
||||
let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable
|
||||
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
|
||||
drop(c1);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -49,83 +49,93 @@ fn main() {
|
|||
// Local and field from struct
|
||||
{
|
||||
let mut f = Foo { x: 22 };
|
||||
let _x = f.x();
|
||||
let x = f.x();
|
||||
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Local and field from tuple-struct
|
||||
{
|
||||
let mut g = Bar(22);
|
||||
let _0 = g.x();
|
||||
let x = g.x();
|
||||
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Local and field from tuple
|
||||
{
|
||||
let mut h = (22, 23);
|
||||
let _0 = &mut h.0;
|
||||
let x = &mut h.0;
|
||||
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Local and field from enum
|
||||
{
|
||||
let mut e = Baz::X(2);
|
||||
let _e0 = e.x();
|
||||
let x = e.x();
|
||||
match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed
|
||||
Baz::X(value) => value
|
||||
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||
};
|
||||
drop(x);
|
||||
}
|
||||
// Local and field from union
|
||||
unsafe {
|
||||
let mut u = U { b: 0 };
|
||||
let _ra = &mut u.a;
|
||||
let x = &mut u.a;
|
||||
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Deref and field from struct
|
||||
{
|
||||
let mut f = Box::new(Foo { x: 22 });
|
||||
let _x = f.x();
|
||||
let x = f.x();
|
||||
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Deref and field from tuple-struct
|
||||
{
|
||||
let mut g = Box::new(Bar(22));
|
||||
let _0 = g.x();
|
||||
let x = g.x();
|
||||
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Deref and field from tuple
|
||||
{
|
||||
let mut h = Box::new((22, 23));
|
||||
let _0 = &mut h.0;
|
||||
let x = &mut h.0;
|
||||
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Deref and field from enum
|
||||
{
|
||||
let mut e = Box::new(Baz::X(3));
|
||||
let _e0 = e.x();
|
||||
let x = e.x();
|
||||
match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed
|
||||
Baz::X(value) => value
|
||||
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||
};
|
||||
drop(x);
|
||||
}
|
||||
// Deref and field from union
|
||||
unsafe {
|
||||
let mut u = Box::new(U { b: 0 });
|
||||
let _ra = &mut u.a;
|
||||
let x = &mut u.a;
|
||||
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Constant index
|
||||
{
|
||||
let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let _v = &mut v;
|
||||
let x = &mut v;
|
||||
match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
|
||||
&[x, _, .., _, _] => println!("{}", x),
|
||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
|
|
@ -150,11 +160,12 @@ fn main() {
|
|||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
drop(x);
|
||||
}
|
||||
// Subslices
|
||||
{
|
||||
let mut v = &[1, 2, 3, 4, 5];
|
||||
let _v = &mut v;
|
||||
let x = &mut v;
|
||||
match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
|
||||
&[x..] => println!("{:?}", x),
|
||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
|
|
@ -179,13 +190,14 @@ fn main() {
|
|||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
drop(x);
|
||||
}
|
||||
// Downcasted field
|
||||
{
|
||||
enum E<X> { A(X), B { x: X } }
|
||||
|
||||
let mut e = E::A(3);
|
||||
let _e = &mut e;
|
||||
let x = &mut e;
|
||||
match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed
|
||||
E::A(ref ax) =>
|
||||
//[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable
|
||||
|
|
@ -197,13 +209,14 @@ fn main() {
|
|||
//[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable
|
||||
println!("e.bx: {:?}", bx),
|
||||
}
|
||||
drop(x);
|
||||
}
|
||||
// Field in field
|
||||
{
|
||||
struct F { x: u32, y: u32 };
|
||||
struct S { x: F, y: (u32, u32), };
|
||||
let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) };
|
||||
let _s = &mut s;
|
||||
let x = &mut s;
|
||||
match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed
|
||||
S { y: (ref y0, _), .. } =>
|
||||
//[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable
|
||||
|
|
@ -218,6 +231,7 @@ fn main() {
|
|||
println!("x0: {:?}", x0),
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
drop(x);
|
||||
}
|
||||
// Field of ref
|
||||
{
|
||||
|
|
@ -231,6 +245,7 @@ fn main() {
|
|||
let p: &'a u8 = &*block.current;
|
||||
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||
// No errors in AST because of issue rust#38899
|
||||
drop(x);
|
||||
}
|
||||
}
|
||||
// Field of ptr
|
||||
|
|
@ -245,29 +260,32 @@ fn main() {
|
|||
let p : *const u8 = &*(*block).current;
|
||||
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||
// No errors in AST because of issue rust#38899
|
||||
drop(x);
|
||||
}
|
||||
}
|
||||
// Field of index
|
||||
{
|
||||
struct F {x: u32, y: u32};
|
||||
let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}];
|
||||
let _v = &mut v;
|
||||
let x = &mut v;
|
||||
v[0].y;
|
||||
//[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed
|
||||
//[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed
|
||||
//[mir]~| ERROR cannot use `*v` because it was mutably borrowed
|
||||
drop(x);
|
||||
}
|
||||
// Field of constant index
|
||||
{
|
||||
struct F {x: u32, y: u32};
|
||||
let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}];
|
||||
let _v = &mut v;
|
||||
let x = &mut v;
|
||||
match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
|
||||
&[_, F {x: ref xf, ..}] => println!("{}", xf),
|
||||
//[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
|
||||
// No errors in AST
|
||||
_ => panic!("other case")
|
||||
}
|
||||
drop(x);
|
||||
}
|
||||
// Field from upvar
|
||||
{
|
||||
|
|
@ -281,13 +299,15 @@ fn main() {
|
|||
}
|
||||
// Field from upvar nested
|
||||
{
|
||||
// FIXME(#49824) -- the free region error below should probably not be there
|
||||
let mut x = 0;
|
||||
|| {
|
||||
|| {
|
||||
let y = &mut x;
|
||||
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
|
||||
//[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
|
||||
*y = 1;
|
||||
|| { //[mir]~ ERROR free region `` does not outlive
|
||||
let y = &mut x;
|
||||
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
|
||||
//[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
|
||||
*y = 1;
|
||||
drop(y);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@
|
|||
|
||||
fn main() {
|
||||
let mut _a = 3;
|
||||
let _b = &mut _a;
|
||||
let b = &mut _a;
|
||||
{
|
||||
let _c = &*_b;
|
||||
let c = &*b;
|
||||
_a = 4; //[ast]~ ERROR cannot assign to `_a`
|
||||
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
|
||||
drop(c);
|
||||
}
|
||||
drop(b);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ fn separate_arms() {
|
|||
// fact no outstanding loan of x!
|
||||
x = Some(0);
|
||||
}
|
||||
Some(ref __isize) => {
|
||||
Some(ref r) => {
|
||||
x = Some(1); //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||
drop(r);
|
||||
}
|
||||
}
|
||||
x.clone(); // just to prevent liveness warnings
|
||||
|
|
|
|||
|
|
@ -25,16 +25,18 @@ fn match_enum() {
|
|||
Foo::A(x) => x //[ast]~ ERROR [E0503]
|
||||
//[mir]~^ ERROR [E0503]
|
||||
};
|
||||
drop(p);
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
let mut x = 1;
|
||||
let _x = &mut x;
|
||||
let r = &mut x;
|
||||
let _ = match x { //[mir]~ ERROR [E0503]
|
||||
x => x + 1, //[ast]~ ERROR [E0503]
|
||||
//[mir]~^ ERROR [E0503]
|
||||
y => y + 2, //[ast]~ ERROR [E0503]
|
||||
//[mir]~^ ERROR [E0503]
|
||||
};
|
||||
drop(r);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
|
||||
fn main() {
|
||||
let mut x = 1;
|
||||
let mut addr;
|
||||
let mut addr = vec![];
|
||||
loop {
|
||||
match 1 {
|
||||
1 => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
||||
1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
|
||||
//[mir]~^ ERROR [E0499]
|
||||
2 => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
||||
2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
|
||||
//[mir]~^ ERROR [E0499]
|
||||
_ => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
||||
_ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
|
||||
//[mir]~^ ERROR [E0499]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,5 @@ fn main() {
|
|||
s[2] = 20;
|
||||
//[ast]~^ ERROR cannot assign to immutable indexed content
|
||||
//[mir]~^^ ERROR cannot assign to immutable item
|
||||
drop(rs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ fn main() {
|
|||
Some(ref i) => {
|
||||
// But on this branch, `i` is an outstanding borrow
|
||||
x = Some(*i+1); //[ast]~ ERROR cannot assign to `x`
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||
drop(i);
|
||||
}
|
||||
}
|
||||
x.clone(); // just to prevent liveness warnings
|
||||
|
|
|
|||
|
|
@ -25,82 +25,98 @@ fn main() {
|
|||
{
|
||||
let ra = &u.a;
|
||||
let ra2 = &u.a; // OK
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let ra = &u.a;
|
||||
let a = u.a; // OK
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let ra = &u.a;
|
||||
let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
|
||||
//[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let ra = &u.a;
|
||||
u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `u.a` because it is borrowed
|
||||
drop(ra);
|
||||
}
|
||||
// Imm borrow, other field
|
||||
{
|
||||
let ra = &u.a;
|
||||
let rb = &u.b; // OK
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let ra = &u.a;
|
||||
let b = u.b; // OK
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let ra = &u.a;
|
||||
let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`)
|
||||
//[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let ra = &u.a;
|
||||
u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `u.b` because it is borrowed
|
||||
drop(ra);
|
||||
}
|
||||
// Mut borrow, same field
|
||||
{
|
||||
let rma = &mut u.a;
|
||||
let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
|
||||
//[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
|
||||
drop(rma);
|
||||
}
|
||||
{
|
||||
let ra = &mut u.a;
|
||||
let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let rma = &mut u.a;
|
||||
let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time
|
||||
//[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time
|
||||
drop(rma);
|
||||
}
|
||||
{
|
||||
let rma = &mut u.a;
|
||||
u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `u.a` because it is borrowed
|
||||
drop(rma);
|
||||
}
|
||||
// Mut borrow, other field
|
||||
{
|
||||
let rma = &mut u.a;
|
||||
let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`)
|
||||
//[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable
|
||||
drop(rma);
|
||||
}
|
||||
{
|
||||
let ra = &mut u.a;
|
||||
let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed
|
||||
//[mir]~^ ERROR cannot use `u.b` because it was mutably borrowed
|
||||
|
||||
drop(ra);
|
||||
}
|
||||
{
|
||||
let rma = &mut u.a;
|
||||
let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time
|
||||
//[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time
|
||||
drop(rma);
|
||||
}
|
||||
{
|
||||
let rma = &mut u.a;
|
||||
u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `u.b` because it is borrowed
|
||||
drop(rma);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
34
src/test/compile-fail/borrowck/two-phase-across-loop.rs
Normal file
34
src/test/compile-fail/borrowck/two-phase-across-loop.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that a borrow which starts as a 2-phase borrow and gets
|
||||
// carried around a loop winds up conflicting with itself.
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
struct Foo { x: String }
|
||||
|
||||
impl Foo {
|
||||
fn get_string(&mut self) -> &str {
|
||||
&self.x
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut foo = Foo { x: format!("Hello, world") };
|
||||
let mut strings = vec![];
|
||||
|
||||
loop {
|
||||
strings.push(foo.get_string()); //~ ERROR cannot borrow `foo` as mutable
|
||||
if strings.len() > 2 { break; }
|
||||
}
|
||||
|
||||
println!("{:?}", strings);
|
||||
}
|
||||
|
|
@ -13,10 +13,9 @@
|
|||
// revisions: nll_target
|
||||
|
||||
// The following revisions are disabled due to missing support from two-phase beyond autorefs
|
||||
//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
|
||||
//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll
|
||||
//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
|
||||
|
||||
//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is an important corner case pointed out by Niko: one is
|
||||
// allowed to initiate a shared borrow during a reservation, but it
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@
|
|||
// revisions: nll_target
|
||||
|
||||
// The following revisions are disabled due to missing support for two_phase_beyond_autoref
|
||||
//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref
|
||||
//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref -Z nll
|
||||
//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref
|
||||
|
||||
|
||||
//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is the second counter-example from Niko's blog post
|
||||
// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/
|
||||
|
|
@ -44,9 +42,8 @@ fn main() {
|
|||
|
||||
/*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used)
|
||||
|
||||
/*4*/ let k = i; //[lxl_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503]
|
||||
//[nll_beyond]~^ ERROR cannot use `i` because it was mutably borrowed [E0503]
|
||||
//[nll_target]~^^ ERROR cannot use `i` because it was mutably borrowed [E0503]
|
||||
/*4*/ let k = i; //[nll_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503]
|
||||
//[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503]
|
||||
|
||||
/*5*/ *p += 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: lxl nll
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
// compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is the third counter-example from Niko's blog post
|
||||
// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/
|
||||
|
|
@ -26,8 +24,7 @@ fn main() {
|
|||
vec.get({
|
||||
|
||||
vec.push(2);
|
||||
//[lxl]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
//[nll]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
//~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
|
||||
0
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: ast lxl nll
|
||||
// revisions: ast nll
|
||||
//[ast]compile-flags:
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll -Z two-phase-beyond-autoref
|
||||
//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
|
||||
// the above revision is disabled until two-phase-beyond-autoref support is better
|
||||
|
||||
// This is a test checking that when we limit two-phase borrows to
|
||||
|
|
@ -69,44 +68,38 @@ fn overloaded_call_traits() {
|
|||
|
||||
fn twice_ten_sm<F: FnMut(i32) -> i32>(f: &mut F) {
|
||||
f(f(10));
|
||||
//[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[nll]~^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[g2p]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[ast]~^^^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
}
|
||||
fn twice_ten_si<F: Fn(i32) -> i32>(f: &mut F) {
|
||||
f(f(10));
|
||||
}
|
||||
fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
|
||||
f(f(10));
|
||||
//[lxl]~^ ERROR use of moved value: `*f`
|
||||
//[nll]~^^ ERROR use of moved value: `*f`
|
||||
//[g2p]~^^^ ERROR use of moved value: `*f`
|
||||
//[ast]~^^^^ ERROR use of moved value: `*f`
|
||||
//[nll]~^ ERROR use of moved value: `*f`
|
||||
//[g2p]~^^ ERROR use of moved value: `*f`
|
||||
//[ast]~^^^ ERROR use of moved value: `*f`
|
||||
}
|
||||
|
||||
fn twice_ten_om(f: &mut FnMut(i32) -> i32) {
|
||||
f(f(10));
|
||||
//[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[nll]~^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[g2p]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[ast]~^^^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
}
|
||||
fn twice_ten_oi(f: &mut Fn(i32) -> i32) {
|
||||
f(f(10));
|
||||
}
|
||||
fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) {
|
||||
f(f(10));
|
||||
//[lxl]~^ ERROR cannot move a value of type
|
||||
//[lxl]~^^ ERROR cannot move a value of type
|
||||
//[lxl]~^^^ ERROR use of moved value: `*f`
|
||||
//[nll]~^^^^ ERROR cannot move a value of type
|
||||
//[nll]~^^^^^ ERROR cannot move a value of type
|
||||
//[nll]~^^^^^^ ERROR use of moved value: `*f`
|
||||
//[g2p]~^^^^^^^ ERROR cannot move a value of type
|
||||
//[g2p]~^^^^^^^^ ERROR cannot move a value of type
|
||||
//[g2p]~^^^^^^^^^ ERROR use of moved value: `*f`
|
||||
//[ast]~^^^^^^^^^^ ERROR use of moved value: `*f`
|
||||
//[nll]~^ ERROR cannot move a value of type
|
||||
//[nll]~^^ ERROR cannot move a value of type
|
||||
//[nll]~^^^ ERROR use of moved value: `*f`
|
||||
//[g2p]~^^^^ ERROR cannot move a value of type
|
||||
//[g2p]~^^^^^ ERROR cannot move a value of type
|
||||
//[g2p]~^^^^^^ ERROR use of moved value: `*f`
|
||||
//[ast]~^^^^^^^ ERROR use of moved value: `*f`
|
||||
}
|
||||
|
||||
twice_ten_sm(&mut |x| x + 1);
|
||||
|
|
@ -144,10 +137,9 @@ fn coerce_unsized() {
|
|||
|
||||
// This is not okay.
|
||||
double_access(&mut a, &a);
|
||||
//[lxl]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[nll]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[g2p]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[ast]~^^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[ast]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
|
||||
// But this is okay.
|
||||
a.m(a.i(10));
|
||||
|
|
@ -173,16 +165,14 @@ impl IndexMut<i32> for I {
|
|||
fn coerce_index_op() {
|
||||
let mut i = I(10);
|
||||
i[i[3]] = 4;
|
||||
//[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[ast]~^^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
|
||||
i[3] = i[4];
|
||||
|
||||
i[i[3]] = i[4];
|
||||
//[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[ast]~^^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: lxl nll
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
// compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is similar to two-phase-reservation-sharing-interference.rs
|
||||
// in that it shows a reservation that overlaps with a shared borrow.
|
||||
|
|
@ -26,12 +24,11 @@
|
|||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { //[nll]~ ERROR compilation successful
|
||||
fn main() { //~ ERROR compilation successful
|
||||
let mut v = vec![0, 1, 2];
|
||||
let shared = &v;
|
||||
|
||||
v.push(shared.len());
|
||||
//[lxl]~^ ERROR cannot borrow `v` as mutable because it is also borrowed as immutable [E0502]
|
||||
|
||||
assert_eq!(v, [0, 1, 2, 3]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,15 +10,13 @@
|
|||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// revisions: lxl_beyond nll_beyond nll_target
|
||||
// revisions: nll_beyond nll_target
|
||||
|
||||
// The following revisions are disabled due to missing support from two-phase beyond autorefs
|
||||
//[lxl_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
|
||||
//[lxl_beyond] should-fail
|
||||
//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll
|
||||
//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
|
||||
//[nll_beyond] should-fail
|
||||
|
||||
//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is a corner case that the current implementation is (probably)
|
||||
// treating more conservatively than is necessary. But it also does
|
||||
|
|
@ -46,9 +44,8 @@ fn main() {
|
|||
// with the shared borrow. But in the current implementation,
|
||||
// its an error.
|
||||
delay = &mut vec;
|
||||
//[lxl_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
//[nll_beyond]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
//[nll_target]~^^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
//[nll_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
//[nll_target]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
||||
|
||||
shared[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: lxl nll
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
// cmpile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is the first counter-example from Niko's blog post
|
||||
// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/
|
||||
|
|
@ -22,8 +20,7 @@ fn main() {
|
|||
v[0].push_str({
|
||||
|
||||
v.push(format!("foo"));
|
||||
//[lxl]~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499]
|
||||
//[nll]~^^ ERROR cannot borrow `v` as mutable more than once at a time [E0499]
|
||||
//~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499]
|
||||
|
||||
"World!"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ fn double_mut_borrow<T>(x: &mut Box<T>) {
|
|||
let z = borrow_mut(x);
|
||||
//[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time
|
||||
//[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time
|
||||
drop((y, z));
|
||||
}
|
||||
|
||||
fn double_imm_borrow(x: &mut Box<i32>) {
|
||||
|
|
@ -30,6 +31,7 @@ fn double_imm_borrow(x: &mut Box<i32>) {
|
|||
**x += 1;
|
||||
//[ast]~^ ERROR cannot assign to `**x` because it is borrowed
|
||||
//[mir]~^^ ERROR cannot assign to `**x` because it is borrowed
|
||||
drop((y, z));
|
||||
}
|
||||
|
||||
fn double_mut_borrow2<T>(x: &mut Box<T>) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ fn call_repeatedly<F>(f: F)
|
|||
f.call(&x);
|
||||
f.call(&x);
|
||||
x = 5;
|
||||
drop(y);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
// FIXME(#49821) -- No tip about using a let binding
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -24,10 +26,9 @@ fn main() {
|
|||
//[ast]~| NOTE temporary value does not live long enough
|
||||
//[ast]~| NOTE consider using a `let` binding to increase its lifetime
|
||||
//[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
|
||||
//[mir]~| NOTE temporary value dropped here while still borrowed
|
||||
//[mir]~| NOTE temporary value does not live long enough
|
||||
//[mir]~| NOTE consider using a `let` binding to increase its lifetime
|
||||
//[mir]~| NOTE temporary value only lives until here
|
||||
println!("{}", val);
|
||||
//[mir]~^ borrow later used here
|
||||
}
|
||||
//[ast]~^ NOTE temporary value needs to live until here
|
||||
//[mir]~^^ NOTE temporary value needs to live until here
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z borrowck=mir -Z nll
|
||||
// compile-flags: -Z borrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ fn bar<'a, 'b>() -> fn(&'a u32, &'b u32) -> &'a u32 {
|
|||
let g: fn(_, _) -> _ = |_x, y| y;
|
||||
//~^ ERROR free region `'b` does not outlive free region `'a`
|
||||
g
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z borrowck=mir -Z nll
|
||||
// compile-flags: -Zborrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ fn bar<'a>(x: &'a u32) -> &'static u32 {
|
|||
// The MIR type checker must therefore relate `'?0` to `'?1` and `'?2`
|
||||
// as part of checking the `ReifyFnPointer`.
|
||||
let f: fn(_) -> _ = foo;
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
//~| ERROR free region `'a` does not outlive free region `'static`
|
||||
f(x)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z borrowck=mir -Z nll
|
||||
// compile-flags: -Zborrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
|
|||
// Here the NLL checker must relate the types in `f` to the types
|
||||
// in `g`. These are related via the `UnsafeFnPointer` cast.
|
||||
let g: unsafe fn(_) -> _ = f;
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
//~| ERROR free region `'a` does not outlive free region `'static`
|
||||
unsafe { g(input) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z borrowck=mir -Z nll
|
||||
// compile-flags: -Z borrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(dyn_trait)]
|
||||
|
|
@ -18,7 +18,7 @@ use std::fmt::Debug;
|
|||
fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
|
||||
//~^ ERROR free region `'a` does not outlive free region `'static`
|
||||
x
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,6 @@ fn main() {
|
|||
// check borrowing is detected successfully
|
||||
let &mut ref x = foo;
|
||||
*foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `*foo` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `*foo` because it is borrowed
|
||||
drop(x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
// compile-flags:-Zborrowck=compare -Znll
|
||||
// compile-flags:-Zborrowck=compare
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
// compile-flags:-Zborrowck=compare -Znll
|
||||
// compile-flags:-Zborrowck=compare
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
//revisions: ast mir
|
||||
//[mir] compile-flags: -Z borrowck=mir -Z nll
|
||||
//[mir] compile-flags: -Z borrowck=mir
|
||||
|
||||
#![allow(unused_assignments)]
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||
// including) the call to `use_x`. The `else` branch is not included.
|
||||
|
||||
// compile-flags:-Zborrowck=compare -Znll
|
||||
// compile-flags:-Zborrowck=compare
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||
// including) the call to `use_x`. The `else` branch is not included.
|
||||
|
||||
// compile-flags:-Zborrowck=compare -Znll
|
||||
// compile-flags:-Zborrowck=compare
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z borrowck=mir -Z nll
|
||||
// compile-flags: -Zborrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ where
|
|||
fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
foo(x, y)
|
||||
//~^ ERROR lifetime mismatch [E0623]
|
||||
//~| WARNING not reporting region error due to -Znll
|
||||
//~| WARNING not reporting region error due to nll
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z borrowck=mir -Z nll
|
||||
// compile-flags: -Z borrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ struct Foo<'a: 'b, 'b> {
|
|||
fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) {
|
||||
Foo { x, y };
|
||||
//~^ ERROR lifetime mismatch [E0623]
|
||||
//~| WARNING not reporting region error due to -Znll
|
||||
//~| WARNING not reporting region error due to nll
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ fn main() {
|
|||
match (&a1,) {
|
||||
(&ref b0,) => {
|
||||
a1 = &f; //[ast]~ ERROR cannot assign
|
||||
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed
|
||||
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed
|
||||
drop(b0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// revisions: ll nll
|
||||
//[nll] compile-flags: -Znll -Zborrowck=mir
|
||||
//[nll] compile-flags:-Zborrowck=mir
|
||||
|
||||
fn static_id<'a,'b>(t: &'a ()) -> &'static ()
|
||||
where 'a: 'static { t }
|
||||
|
|
@ -17,16 +17,16 @@ fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
|
|||
where 'a: 'b, 'b: 'static { t }
|
||||
fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
|
||||
t //[ll]~ ERROR E0312
|
||||
//[nll]~^ WARNING not reporting region error due to -Znll
|
||||
//[nll]~^ WARNING not reporting region error due to nll
|
||||
//[nll]~| ERROR free region `'a` does not outlive free region `'static`
|
||||
}
|
||||
|
||||
fn error(u: &(), v: &()) {
|
||||
static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]
|
||||
//[nll]~^ WARNING not reporting region error due to -Znll
|
||||
//[nll]~^ WARNING not reporting region error due to nll
|
||||
//[nll]~| ERROR explicit lifetime required in the type of `u` [E0621]
|
||||
static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
|
||||
//[nll]~^ WARNING not reporting region error due to -Znll
|
||||
//[nll]~^ WARNING not reporting region error due to nll
|
||||
//[nll]~| ERROR explicit lifetime required in the type of `v` [E0621]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-Znll
|
||||
// compile-flags:-Zborrowck=mir
|
||||
|
||||
fn can_panic() -> Box<usize> {
|
||||
Box::new(44)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-Znll
|
||||
// compile-flags:-Zborrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-Znll
|
||||
// compile-flags:-Zborrowck=mir
|
||||
|
||||
fn cond() -> bool { false }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
// suitable variables and that we setup the outlives relationship
|
||||
// between R0 and R1 properly.
|
||||
|
||||
// compile-flags:-Znll -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
// ignore-tidy-linelength
|
||||
|
||||
#![allow(warnings)]
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// in the type of `r_a` must outlive the region (`R7`) that appears in
|
||||
// the type of `r_b`
|
||||
|
||||
// compile-flags:-Znll -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||
// including) the call to `use_x`. The `else` branch is not included.
|
||||
|
||||
// compile-flags:-Znll -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
// but only at a particular point, and hence they wind up including
|
||||
// distinct regions.
|
||||
|
||||
// compile-flags:-Znll -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||
// including) the call to `use_x`. The `else` branch is not included.
|
||||
|
||||
// compile-flags:-Znll -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: lxl nll
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
// compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// This is the "goto example" for why we want two phase borrows.
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// revisions: normal nll
|
||||
//[nll] compile-flags: -Znll -Zborrowck=mir
|
||||
//[nll] compile-flags:-Zborrowck=mir
|
||||
|
||||
#![feature(fn_traits,
|
||||
step_trait,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ fn a() {
|
|||
let c1 = to_fn_mut(|| x = 4);
|
||||
let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
//~| ERROR cannot borrow `x` as mutable more than once
|
||||
drop((c1, c2));
|
||||
}
|
||||
|
||||
fn set(x: &mut isize) {
|
||||
|
|
@ -34,6 +35,7 @@ fn b() {
|
|||
let c1 = to_fn_mut(|| set(&mut x));
|
||||
let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
//~| ERROR cannot borrow `x` as mutable more than once
|
||||
drop((c1, c2));
|
||||
}
|
||||
|
||||
fn c() {
|
||||
|
|
@ -41,6 +43,7 @@ fn c() {
|
|||
let c1 = to_fn_mut(|| x = 5);
|
||||
let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
//~| ERROR cannot borrow `x` as mutable more than once
|
||||
drop((c1, c2));
|
||||
}
|
||||
|
||||
fn d() {
|
||||
|
|
@ -49,6 +52,7 @@ fn d() {
|
|||
let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
|
||||
//~^ ERROR cannot borrow `x` as mutable more than once
|
||||
//~| ERROR cannot borrow `x` as mutable more than once
|
||||
drop((c1, c2));
|
||||
}
|
||||
|
||||
fn g() {
|
||||
|
|
@ -61,6 +65,7 @@ fn g() {
|
|||
let c2 = to_fn_mut(|| set(&mut *x.f));
|
||||
//~^ ERROR cannot borrow `x` as mutable more than once
|
||||
//~| ERROR cannot borrow `x` as mutable more than once
|
||||
drop((c1, c2));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable mo
|
|||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:35:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:36:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| set(&mut x));
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -24,12 +24,12 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta
|
|||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:42:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:44:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 5);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -39,12 +39,12 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta
|
|||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:49:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:52:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 5);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -59,7 +59,7 @@ LL | }
|
|||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:61:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:65:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -85,11 +85,11 @@ LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable mo
|
|||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
LL | drop((c1, c2));
|
||||
| -- borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:35:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:36:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| set(&mut x));
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -100,11 +100,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta
|
|||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
LL | drop((c1, c2));
|
||||
| -- borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:42:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:44:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 5);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -115,11 +115,11 @@ LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as muta
|
|||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
LL | drop((c1, c2));
|
||||
| -- borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:49:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:52:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 5);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -130,11 +130,11 @@ LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nes
|
|||
| |
|
||||
| second mutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
LL | drop((c1, c2));
|
||||
| -- borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:61:24
|
||||
--> $DIR/borrowck-closures-two-mut.rs:65:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
|
|
@ -145,8 +145,8 @@ LL | let c2 = to_fn_mut(|| set(&mut *x.f));
|
|||
| |
|
||||
| second mutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
LL | drop((c1, c2));
|
||||
| -- borrow later used here
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: lxl nll
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
// compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// run-pass
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: lxl nll
|
||||
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
|
||||
// compile-flags: -Z borrowck=mir -Z two-phase-borrows
|
||||
|
||||
// run-pass
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ fn main() {
|
|||
*y.pointer += 1;
|
||||
//~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
|
||||
//~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]
|
||||
//~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506]
|
||||
*z.pointer += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,22 @@ LL | let z = copy_borrowed_ptr(&mut y);
|
|||
| ------ borrow of `y` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ use of borrowed `y`
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
|
||||
--> $DIR/issue-45697-1.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `*y.pointer` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0503, E0506.
|
||||
For more information about an error, try `rustc --explain E0503`.
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ fn main() {
|
|||
*y.pointer += 1;
|
||||
//~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
|
||||
//~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]
|
||||
//~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506]
|
||||
*z.pointer += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,22 @@ LL | let z = copy_borrowed_ptr(&mut y);
|
|||
| ------ borrow of `y` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ use of borrowed `y`
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
|
||||
--> $DIR/issue-45697.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `*y.pointer` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0503, E0506.
|
||||
For more information about an error, try `rustc --explain E0503`.
|
||||
|
|
|
|||
|
|
@ -12,13 +12,16 @@ LL | }
|
|||
error[E0597]: `z` does not live long enough (Mir)
|
||||
--> $DIR/issue-46471-1.rs:16:9
|
||||
|
|
||||
LL | &mut z
|
||||
| ^^^^^^ borrowed value does not live long enough
|
||||
LL | };
|
||||
| - `z` dropped here while still borrowed
|
||||
...
|
||||
LL | }
|
||||
| - borrowed value needs to live until here
|
||||
LL | let y = {
|
||||
| _____________-
|
||||
LL | | let mut z = 0;
|
||||
LL | | &mut z
|
||||
| | ^^^^^^ borrowed value does not live long enough
|
||||
LL | | };
|
||||
| | -
|
||||
| | |
|
||||
| |_____borrowed value only lives until here
|
||||
| borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
// that appear free in its type (hence, we see it before the closure's
|
||||
// "external requirements" report).
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ fn test() {
|
|||
let y = 22;
|
||||
let mut closure = expect_sig(|p, y| *p = y);
|
||||
//~^ ERROR does not outlive free region
|
||||
//~| WARNING not reporting region error due to -Znll
|
||||
//~| WARNING not reporting region error due to nll
|
||||
closure(&mut p, &y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/escape-argument-callee.rs:36:50
|
||||
|
|
||||
LL | let mut closure = expect_sig(|p, y| *p = y);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
// basically checking that the MIR type checker correctly enforces the
|
||||
// closure signature.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
// except that the closure does so via a second closure.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// `'b`. This relationship is propagated to the closure creator,
|
||||
// which reports an error.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// Test where we fail to approximate due to demanding a postdom
|
||||
// relationship between our upper bounds.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell
|
|||
|_outlives1, _outlives2, _outlives3, x, y| {
|
||||
// Only works if 'x: 'y:
|
||||
let p = x.get();
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR does not outlive free region
|
||||
demand_y(x, y, p)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-approximated-fail-no-postdom.rs:55:21
|
||||
|
|
||||
LL | let p = x.get();
|
||||
|
|
@ -16,7 +16,7 @@ note: No external requirements
|
|||
LL | / |_outlives1, _outlives2, _outlives3, x, y| {
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | let p = x.get();
|
||||
LL | | //~^ WARN not reporting region error due to -Znll
|
||||
LL | | //~^ WARN not reporting region error due to nll
|
||||
LL | | //~| ERROR does not outlive free region
|
||||
LL | | demand_y(x, y, p)
|
||||
LL | | },
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
// Note: the use of `Cell` here is to introduce invariance. One less
|
||||
// variable.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
|||
//~^ ERROR lifetime mismatch
|
||||
|
||||
// Only works if 'x: 'y:
|
||||
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-approximated-ref.rs:57:9
|
||||
|
|
||||
LL | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
note: External requirements
|
||||
|
|
@ -12,7 +12,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x,
|
|||
LL | | //~^ ERROR lifetime mismatch
|
||||
LL | |
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// where `'x` is bound in closure type but `'a` is free. This forces
|
||||
// us to approximate `'x` one way or the other.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ fn case1() {
|
|||
let a = 0;
|
||||
let cell = Cell::new(&a);
|
||||
foo(cell, |cell_a, cell_x| {
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
|
||||
//~^ ERROR does not outlive free region
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:31:5
|
||||
|
|
||||
LL | foo(cell, |cell_a, cell_x| {
|
||||
|
|
@ -15,7 +15,7 @@ note: No external requirements
|
|||
|
|
||||
LL | foo(cell, |cell_a, cell_x| {
|
||||
| _______________^
|
||||
LL | | //~^ WARNING not reporting region error due to -Znll
|
||||
LL | | //~^ WARNING not reporting region error due to nll
|
||||
LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
|
||||
LL | | //~^ ERROR does not outlive free region
|
||||
LL | | })
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
// FIXME(#45827) Because of shortcomings in the MIR type checker,
|
||||
// these errors are not (yet) reported.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
|||
//~^ ERROR does not outlive free region
|
||||
|
||||
// Only works if 'x: 'y:
|
||||
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:49:9
|
||||
|
|
||||
LL | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
note: External requirements
|
||||
|
|
@ -12,7 +12,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
|||
LL | | //~^ ERROR does not outlive free region
|
||||
LL | |
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
|
|
@ -31,7 +31,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
|||
LL | | //~^ ERROR does not outlive free region
|
||||
LL | |
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
// FIXME(#45827) Because of shortcomings in the MIR type checker,
|
||||
// these errors are not (yet) reported.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
|||
//~^ ERROR does not outlive free region
|
||||
// Only works if 'x: 'y:
|
||||
demand_y(x, y, x.get())
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:51:9
|
||||
|
|
||||
LL | demand_y(x, y, x.get())
|
||||
|
|
@ -12,7 +12,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x,
|
|||
LL | | //~^ ERROR does not outlive free region
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get())
|
||||
LL | | //~^ WARNING not reporting region error due to -Znll
|
||||
LL | | //~^ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
|
|
@ -31,7 +31,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x,
|
|||
LL | | //~^ ERROR does not outlive free region
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get())
|
||||
LL | | //~^ WARNING not reporting region error due to -Znll
|
||||
LL | | //~^ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
// relationships. In the 'main' variant, there are a number of
|
||||
// anonymous regions as well.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
|||
//~^ ERROR lifetime mismatch
|
||||
|
||||
// Only works if 'x: 'y:
|
||||
demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-approximated-val.rs:50:9
|
||||
|
|
||||
LL | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
note: External requirements
|
||||
|
|
@ -12,7 +12,7 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y|
|
|||
LL | | //~^ ERROR lifetime mismatch
|
||||
LL | |
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to -Znll
|
||||
LL | | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// need to propagate; but in fact we do because identity of free
|
||||
// regions is erased.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// compile-pass
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-despite-same-free-region.rs:54:21
|
||||
|
|
||||
LL | let p = x.get();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
// as it knows of no relationships between `'x` and any
|
||||
// non-higher-ranked regions.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
|||
establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
||||
// Only works if 'x: 'y:
|
||||
demand_y(x, y, x.get())
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR does not outlive free region
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:9
|
||||
|
|
||||
LL | demand_y(x, y, x.get())
|
||||
|
|
@ -17,7 +17,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
|||
| _______________________________________________^
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get())
|
||||
LL | | //~^ WARN not reporting region error due to -Znll
|
||||
LL | | //~^ WARN not reporting region error due to nll
|
||||
LL | | //~| ERROR does not outlive free region
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
// as it only knows of regions that `'x` is outlived by, and none that
|
||||
// `'x` outlives.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
|||
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
|
||||
// Only works if 'x: 'y:
|
||||
demand_y(x, y, x.get())
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR does not outlive free region
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:9
|
||||
|
|
||||
LL | demand_y(x, y, x.get())
|
||||
|
|
@ -17,7 +17,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x,
|
|||
| _______________________________________________^
|
||||
LL | | // Only works if 'x: 'y:
|
||||
LL | | demand_y(x, y, x.get())
|
||||
LL | | //~^ WARN not reporting region error due to -Znll
|
||||
LL | | //~^ WARN not reporting region error due to nll
|
||||
LL | | //~| ERROR does not outlive free region
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
// the same `'a` for which it implements `Trait`, which can only be the `'a`
|
||||
// from the function definition.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
|
|
@ -53,7 +53,7 @@ where
|
|||
// The latter does not hold.
|
||||
|
||||
require(value);
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/propagate-from-trait-match.rs:55:9
|
||||
|
|
||||
LL | require(value);
|
||||
|
|
@ -13,7 +13,7 @@ LL | | //~^ ERROR the parameter type `T` may not live long enough
|
|||
LL | |
|
||||
LL | | // This function call requires that
|
||||
... |
|
||||
LL | | //~^ WARNING not reporting region error due to -Znll
|
||||
LL | | //~^ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
|
|
@ -35,7 +35,7 @@ LL | | //~^ ERROR the parameter type `T` may not live long enough
|
|||
LL | |
|
||||
LL | | // This function call requires that
|
||||
... |
|
||||
LL | | //~^ WARNING not reporting region error due to -Znll
|
||||
LL | | //~^ WARNING not reporting region error due to nll
|
||||
LL | | });
|
||||
| |_____^
|
||||
|
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
// a variety of errors from the older, AST-based machinery (notably
|
||||
// borrowck), and then we get the NLL error at the end.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
fn foo(x: &u32) -> &'static u32 {
|
||||
&*x
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR explicit lifetime required in the type of `x`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:19:5
|
||||
|
|
||||
LL | &*x
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
// a variety of errors from the older, AST-based machinery (notably
|
||||
// borrowck), and then we get the NLL error at the end.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
fn foo<'a>(x: &'a u32) -> &'static u32 {
|
||||
&*x
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR does not outlive free region
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
|
||||
|
|
||||
LL | &*x
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
// a variety of errors from the older, AST-based machinery (notably
|
||||
// borrowck), and then we get the NLL error at the end.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
|
||||
&*x
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
|
||||
|
|
||||
LL | &*x
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// Basic test for free regions in the NLL code. This test does not
|
||||
// report an error because of the (implied) bound that `'b: 'a`.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// compile-pass
|
||||
|
||||
#![allow(warnings)]
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@
|
|||
// the first, but actually returns the second. This should fail within
|
||||
// the closure.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_regions]
|
||||
fn test() {
|
||||
expect_sig(|a, b| b); // ought to return `a`
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~^ WARN not reporting region error due to nll
|
||||
//~| ERROR does not outlive free region
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
warning: not reporting region error due to nll
|
||||
--> $DIR/return-wrong-bound-region.rs:21:23
|
||||
|
|
||||
LL | expect_sig(|a, b| b); // ought to return `a`
|
||||
|
|
@ -26,7 +26,7 @@ note: No external requirements
|
|||
|
|
||||
LL | / fn test() {
|
||||
LL | | expect_sig(|a, b| b); // ought to return `a`
|
||||
LL | | //~^ WARN not reporting region error due to -Znll
|
||||
LL | | //~^ WARN not reporting region error due to nll
|
||||
LL | | //~| ERROR does not outlive free region
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// Test that MIR borrowck and NLL analysis can handle constants of
|
||||
// arbitrary types without ICEs.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
// compile-pass
|
||||
|
||||
const HI: &str = "hi";
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||
// including) the call to `use_x`. The `else` branch is not included.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir
|
||||
// compile-flags:-Zborrowck=mir
|
||||
// compile-pass
|
||||
|
||||
#![allow(warnings)]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// because of destructor. (Note that the stderr also identifies this
|
||||
// destructor in the error message.)
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir
|
||||
// compile-flags:-Zborrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// a variety of errors from the older, AST-based machinery (notably
|
||||
// borrowck), and then we get the NLL error at the end.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=compare
|
||||
// compile-flags:-Zborrowck=compare
|
||||
|
||||
struct Map {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir
|
||||
|
||||
|
||||
#![allow(warnings)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll
|
||||
// compile-flags: -Z emit-end-regions -Zborrowck=mir
|
||||
// compile-pass
|
||||
|
||||
#![allow(warnings)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll
|
||||
//compile-flags: -Z emit-end-regions -Zborrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir
|
||||
// compile-flags:-Zborrowck=mir
|
||||
// compile-pass
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
// compile-flags:-Zborrowck=mir -Zverbose
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ impl<'a, T> Foo<'a> for T { }
|
|||
|
||||
fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
||||
x
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~^ WARNING not reporting region error due to nll
|
||||
//~| ERROR explicit lifetime required in the type of `x` [E0621]
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue