Skip to content

Commit cf71d83

Browse files
committed
add tests
1 parent b8115b8 commit cf71d83

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![feature(capture_disjoint_fields)]
2+
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
3+
//~| NOTE: `#[warn(incomplete_features)]` on by default
4+
//~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
5+
#![feature(rustc_attrs)]
6+
7+
#[derive(Debug)]
8+
struct Child {
9+
c: String,
10+
d: String,
11+
}
12+
13+
#[derive(Debug)]
14+
struct Parent {
15+
b: Child,
16+
}
17+
18+
fn main() {
19+
let mut a = Parent { b: Child {c: String::new(), d: String::new()} };
20+
21+
let c = #[rustc_capture_analysis]
22+
//~^ ERROR: attributes on expressions are experimental
23+
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
24+
|| {
25+
//~^ First Pass analysis includes:
26+
//~| Min Capture analysis includes:
27+
let _x = a.b.c;
28+
//~^ NOTE: Capturing a[(0, 0),(0, 0)] -> ByValue
29+
//~| NOTE: a[(0, 0)] captured as ByValue here
30+
println!("{:?}", a.b);
31+
//~^ NOTE: Capturing a[(0, 0)] -> ImmBorrow
32+
//~| NOTE: Min Capture a[(0, 0)] -> ByValue
33+
//~| NOTE: a[(0, 0)] used here
34+
};
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
error[E0658]: attributes on expressions are experimental
2+
--> $DIR/capture-analysis-3.rs:21:13
3+
|
4+
LL | let c = #[rustc_capture_analysis]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
8+
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
9+
10+
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
11+
--> $DIR/capture-analysis-3.rs:1:12
12+
|
13+
LL | #![feature(capture_disjoint_fields)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: `#[warn(incomplete_features)]` on by default
17+
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
18+
19+
error: First Pass analysis includes:
20+
--> $DIR/capture-analysis-3.rs:24:5
21+
|
22+
LL | / || {
23+
LL | |
24+
LL | |
25+
LL | | let _x = a.b.c;
26+
... |
27+
LL | |
28+
LL | | };
29+
| |_____^
30+
|
31+
note: Capturing a[(0, 0),(0, 0)] -> ByValue
32+
--> $DIR/capture-analysis-3.rs:27:18
33+
|
34+
LL | let _x = a.b.c;
35+
| ^^^^^
36+
note: Capturing a[(0, 0)] -> ImmBorrow
37+
--> $DIR/capture-analysis-3.rs:30:26
38+
|
39+
LL | println!("{:?}", a.b);
40+
| ^^^
41+
42+
error: Min Capture analysis includes:
43+
--> $DIR/capture-analysis-3.rs:24:5
44+
|
45+
LL | / || {
46+
LL | |
47+
LL | |
48+
LL | | let _x = a.b.c;
49+
... |
50+
LL | |
51+
LL | | };
52+
| |_____^
53+
|
54+
note: Min Capture a[(0, 0)] -> ByValue
55+
--> $DIR/capture-analysis-3.rs:27:18
56+
|
57+
LL | let _x = a.b.c;
58+
| ^^^^^ a[(0, 0)] captured as ByValue here
59+
...
60+
LL | println!("{:?}", a.b);
61+
| ^^^ a[(0, 0)] used here
62+
63+
error: aborting due to 3 previous errors; 1 warning emitted
64+
65+
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![feature(capture_disjoint_fields)]
2+
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
3+
//~| NOTE: `#[warn(incomplete_features)]` on by default
4+
//~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
5+
#![feature(rustc_attrs)]
6+
7+
#[derive(Debug)]
8+
struct Child {
9+
c: String,
10+
d: String,
11+
}
12+
13+
#[derive(Debug)]
14+
struct Parent {
15+
b: Child,
16+
}
17+
18+
fn main() {
19+
let mut a = Parent { b: Child {c: String::new(), d: String::new()} };
20+
21+
let c = #[rustc_capture_analysis]
22+
//~^ ERROR: attributes on expressions are experimental
23+
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
24+
|| {
25+
//~^ First Pass analysis includes:
26+
//~| Min Capture analysis includes:
27+
let _x = a.b;
28+
//~^ NOTE: Capturing a[(0, 0)] -> ByValue
29+
//~| NOTE: Min Capture a[(0, 0)] -> ByValue
30+
println!("{:?}", a.b.c);
31+
//~^ NOTE: Capturing a[(0, 0),(0, 0)] -> ImmBorrow
32+
};
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
error[E0658]: attributes on expressions are experimental
2+
--> $DIR/capture-analysis-4.rs:21:13
3+
|
4+
LL | let c = #[rustc_capture_analysis]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
8+
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
9+
10+
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
11+
--> $DIR/capture-analysis-4.rs:1:12
12+
|
13+
LL | #![feature(capture_disjoint_fields)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: `#[warn(incomplete_features)]` on by default
17+
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
18+
19+
error: First Pass analysis includes:
20+
--> $DIR/capture-analysis-4.rs:24:5
21+
|
22+
LL | / || {
23+
LL | |
24+
LL | |
25+
LL | | let _x = a.b;
26+
... |
27+
LL | |
28+
LL | | };
29+
| |_____^
30+
|
31+
note: Capturing a[(0, 0)] -> ByValue
32+
--> $DIR/capture-analysis-4.rs:27:18
33+
|
34+
LL | let _x = a.b;
35+
| ^^^
36+
note: Capturing a[(0, 0),(0, 0)] -> ImmBorrow
37+
--> $DIR/capture-analysis-4.rs:30:26
38+
|
39+
LL | println!("{:?}", a.b.c);
40+
| ^^^^^
41+
42+
error: Min Capture analysis includes:
43+
--> $DIR/capture-analysis-4.rs:24:5
44+
|
45+
LL | / || {
46+
LL | |
47+
LL | |
48+
LL | | let _x = a.b;
49+
... |
50+
LL | |
51+
LL | | };
52+
| |_____^
53+
|
54+
note: Min Capture a[(0, 0)] -> ByValue
55+
--> $DIR/capture-analysis-4.rs:27:18
56+
|
57+
LL | let _x = a.b;
58+
| ^^^
59+
60+
error: aborting due to 3 previous errors; 1 warning emitted
61+
62+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)