Skip to content

Commit cf71582

Browse files
committed
Use // revisions in the dropck-eyepatch tests instead of relying on compare-mode=nll.
NLL has increased precision in its analysis of drop order, and we want the test annotations to deliberately reflect this by having fewer ERROR annotations for NLL than for AST-borrowck. The best way to get this effect is via `// revisions`. As a drive-by, also added uses of all the borrows just to make it clear that NLL isn't somehow sidestepping things by using shorter borrows than you might have otherwise expected. (Of course, the added uses do not make all that much difference since the relevant types all declare `impl Drop` and thus those drops have implicit uses anyway.)
1 parent c25319f commit cf71582

6 files changed

+60
-51
lines changed

src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr renamed to src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LL | }
3232
= note: values in a scope are dropped in the opposite order they are created
3333

3434
error[E0597]: `c_shortest` does not live long enough
35-
--> $DIR/dropck-eyepatch-extern-crate.rs:49:20
35+
--> $DIR/dropck-eyepatch-extern-crate.rs:50:20
3636
|
3737
LL | dr = Dr("dr", &c_shortest);
3838
| ^^^^^^^^^^ borrowed value does not live long enough

src/test/ui/dropck/dropck-eyepatch-extern-crate.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// The behavior of AST-borrowck and NLL explcitly differ here due to
2+
// NLL's increased precision; so we use revisions and do not worry
3+
// about the --compare-mode=nll on this test.
4+
5+
// revisions: ast nll
6+
//[ast]compile-flags: -Z borrowck=ast
7+
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
8+
9+
// ignore-compare-mode-nll
1010

1111
// aux-build:dropck_eyepatch_extern_crate.rs
1212

@@ -39,29 +39,32 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
3939

4040
// Error: destructor order imprecisely modelled
4141
dt = Dt("dt", &c);
42-
//~^ ERROR `c` does not live long enough
42+
//[ast]~^ ERROR `c` does not live long enough
4343
dr = Dr("dr", &c);
44-
//~^ ERROR `c` does not live long enough
44+
//[ast]~^ ERROR `c` does not live long enough
4545

4646
// Error: `c_shortest` dies too soon for the references in dtors to be valid.
4747
dt = Dt("dt", &c_shortest);
48-
//~^ ERROR `c_shortest` does not live long enough
48+
//[ast]~^ ERROR `c_shortest` does not live long enough
49+
//[nll]~^^ ERROR `c_shortest` does not live long enough
4950
dr = Dr("dr", &c_shortest);
50-
//~^ ERROR `c_shortest` does not live long enough
51-
51+
//[ast]~^ ERROR `c_shortest` does not live long enough
5252
// No error: Drop impl asserts .1 (A and &'a _) are not accessed
5353
pt = Pt("pt", &c_shortest, &c_long);
5454
pr = Pr("pr", &c_shortest, &c_long);
5555

5656
// Error: Drop impl's assertion does not apply to `B` nor `&'b _`
5757
pt = Pt("pt", &c_long, &c_shortest);
58-
//~^ ERROR `c_shortest` does not live long enough
58+
//[ast]~^ ERROR `c_shortest` does not live long enough
5959
pr = Pr("pr", &c_long, &c_shortest);
60-
//~^ ERROR `c_shortest` does not live long enough
60+
//[ast]~^ ERROR `c_shortest` does not live long enough
6161

6262
// No error: St and Sr have no destructor.
6363
st = St("st", &c_shortest);
6464
sr = Sr("sr", &c_shortest);
6565

6666
println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
67+
use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1);
6768
}
69+
70+
fn use_imm<T>(_: &T) { }

src/test/ui/dropck/dropck-eyepatch-reorder.stderr renamed to src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LL | }
3232
= note: values in a scope are dropped in the opposite order they are created
3333

3434
error[E0597]: `c_shortest` does not live long enough
35-
--> $DIR/dropck-eyepatch-reorder.rs:66:20
35+
--> $DIR/dropck-eyepatch-reorder.rs:67:20
3636
|
3737
LL | dr = Dr("dr", &c_shortest);
3838
| ^^^^^^^^^^ borrowed value does not live long enough

src/test/ui/dropck/dropck-eyepatch-reorder.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// The behavior of AST-borrowck and NLL explcitly differ here due to
2+
// NLL's increased precision; so we use revisions and do not worry
3+
// about the --compare-mode=nll on this test.
4+
5+
// revisions: ast nll
6+
//[ast]compile-flags: -Z borrowck=ast
7+
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
8+
9+
// ignore-compare-mode-nll
1010

1111
#![feature(dropck_eyepatch, rustc_attrs)]
1212

@@ -56,29 +56,32 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
5656

5757
// Error: destructor order imprecisely modelled
5858
dt = Dt("dt", &c);
59-
//~^ ERROR `c` does not live long enough
59+
//[ast]~^ ERROR `c` does not live long enough
6060
dr = Dr("dr", &c);
61-
//~^ ERROR `c` does not live long enough
61+
//[ast]~^ ERROR `c` does not live long enough
6262

6363
// Error: `c_shortest` dies too soon for the references in dtors to be valid.
6464
dt = Dt("dt", &c_shortest);
65-
//~^ ERROR `c_shortest` does not live long enough
65+
//[ast]~^ ERROR `c_shortest` does not live long enough
66+
//[nll]~^^ ERROR `c_shortest` does not live long enough
6667
dr = Dr("dr", &c_shortest);
67-
//~^ ERROR `c_shortest` does not live long enough
68-
68+
//[ast]~^ ERROR `c_shortest` does not live long enough
6969
// No error: Drop impl asserts .1 (A and &'a _) are not accessed
7070
pt = Pt("pt", &c_shortest, &c_long);
7171
pr = Pr("pr", &c_shortest, &c_long);
7272

7373
// Error: Drop impl's assertion does not apply to `B` nor `&'b _`
7474
pt = Pt("pt", &c_long, &c_shortest);
75-
//~^ ERROR `c_shortest` does not live long enough
75+
//[ast]~^ ERROR `c_shortest` does not live long enough
7676
pr = Pr("pr", &c_long, &c_shortest);
77-
//~^ ERROR `c_shortest` does not live long enough
77+
//[ast]~^ ERROR `c_shortest` does not live long enough
7878

7979
// No error: St and Sr have no destructor.
8080
st = St("st", &c_shortest);
8181
sr = Sr("sr", &c_shortest);
8282

8383
println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
84+
use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1);
8485
}
86+
87+
fn use_imm<T>(_: &T) { }

src/test/ui/dropck/dropck-eyepatch.stderr renamed to src/test/ui/dropck/dropck-eyepatch.ast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LL | }
3232
= note: values in a scope are dropped in the opposite order they are created
3333

3434
error[E0597]: `c_shortest` does not live long enough
35-
--> $DIR/dropck-eyepatch.rs:89:20
35+
--> $DIR/dropck-eyepatch.rs:90:20
3636
|
3737
LL | dr = Dr("dr", &c_shortest);
3838
| ^^^^^^^^^^ borrowed value does not live long enough

src/test/ui/dropck/dropck-eyepatch.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
// The behavior of AST-borrowck and NLL explcitly differ here due to
2+
// NLL's increased precision; so we use revisions and do not worry
3+
// about the --compare-mode=nll on this test.
4+
5+
// revisions: ast nll
6+
//[ast]compile-flags: -Z borrowck=ast
7+
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
8+
9+
// ignore-compare-mode-nll
1010

1111
#![feature(dropck_eyepatch, rustc_attrs)]
1212

@@ -79,30 +79,33 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
7979

8080
// Error: destructor order imprecisely modelled
8181
dt = Dt("dt", &c);
82-
//~^ ERROR `c` does not live long enough
82+
//[ast]~^ ERROR `c` does not live long enough
8383
dr = Dr("dr", &c);
84-
//~^ ERROR `c` does not live long enough
84+
//[ast]~^ ERROR `c` does not live long enough
8585

8686
// Error: `c_shortest` dies too soon for the references in dtors to be valid.
8787
dt = Dt("dt", &c_shortest);
88-
//~^ ERROR `c_shortest` does not live long enough
88+
//[ast]~^ ERROR `c_shortest` does not live long enough
89+
//[nll]~^^ ERROR `c_shortest` does not live long enough
8990
dr = Dr("dr", &c_shortest);
90-
//~^ ERROR `c_shortest` does not live long enough
91-
91+
//[ast]~^ ERROR `c_shortest` does not live long enough
9292

9393
// No error: Drop impl asserts .1 (A and &'a _) are not accessed
9494
pt = Pt("pt", &c_shortest, &c_long);
9595
pr = Pr("pr", &c_shortest, &c_long);
9696

9797
// Error: Drop impl's assertion does not apply to `B` nor `&'b _`
9898
pt = Pt("pt", &c_long, &c_shortest);
99-
//~^ ERROR `c_shortest` does not live long enough
99+
//[ast]~^ ERROR `c_shortest` does not live long enough
100100
pr = Pr("pr", &c_long, &c_shortest);
101-
//~^ ERROR `c_shortest` does not live long enough
101+
//[ast]~^ ERROR `c_shortest` does not live long enough
102102

103103
// No error: St and Sr have no destructor.
104104
st = St("st", &c_shortest);
105105
sr = Sr("sr", &c_shortest);
106106

107107
println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
108+
use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1);
108109
}
110+
111+
fn use_imm<T>(_: &T) { }

0 commit comments

Comments
 (0)