Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #81553

Closed
wants to merge 28 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
77a9e3e
combine: stop eagerly evaluating consts
lcnr Jan 24, 2021
a398994
Account for existing `_` field pattern when suggesting `..`
estebank Jan 27, 2021
063b427
Bump rustfmt version
Mark-Simulacrum Jan 9, 2021
ada714d
Optimize udiv_1e19() function
Kogia-sima Jan 28, 2021
d1727ed
Add lint for 2229 migrations
arora-aman Dec 28, 2020
2c651eb
Process mentioned upvars for analysis first pass after ExprUseVisitor
arora-aman Nov 21, 2020
36352d2
Migrations first pass
arora-aman Dec 15, 2020
d30a5bf
Tests for 2229 lint
arora-aman Dec 30, 2020
9ac023d
Mark the lint doc as compile_fail
arora-aman Jan 3, 2021
f106e18
PR fixup
arora-aman Jan 19, 2021
11abaa1
New migration
arora-aman Jan 26, 2021
b421cd5
Restrict precision of captures with `capture_disjoint_fields` set
arora-aman Dec 4, 2020
3488082
Compute mutability of closure captures
arora-aman Dec 2, 2020
1373f98
Test cases for handling mutable references
arora-aman Dec 13, 2020
0897db5
Test for restricting capture precision
arora-aman Dec 14, 2020
604cbdc
Fix unused 'mut' warning for capture's root variable
arora-aman Dec 16, 2020
c748f32
Fix incorrect use mut diagnostics
arora-aman Dec 13, 2020
ffd5327
Add fixme for precise path diagnostics
arora-aman Jan 12, 2021
fadf03e
Fix typos
arora-aman Jan 29, 2021
0f4bab2
Fixme for closure origin when reborrow is implemented
arora-aman Jan 29, 2021
56c2736
Replace predecessor with range in collections documentation
KamilaBorowska Jan 30, 2021
755be93
Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakis
m-ou-se Jan 30, 2021
16a4bb2
Rollup merge of #80629 - sexxi-goose:migrations_1, r=nikomatsakis
m-ou-se Jan 30, 2021
813739a
Rollup merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
m-ou-se Jan 30, 2021
1d117ab
Rollup merge of #81351 - lcnr:big-money-big-prices, r=oli-obk
m-ou-se Jan 30, 2021
ec066b3
Rollup merge of #81422 - estebank:dotdot_sugg, r=davidtwco
m-ou-se Jan 30, 2021
e3d9523
Rollup merge of #81484 - Kogia-sima:perf/optimize-udiv_1e19, r=nagisa
m-ou-se Jan 30, 2021
0330456
Rollup merge of #81550 - xfix:replace-mention-of-predecessor, r=jonas…
m-ou-se Jan 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/by_value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Test that we handle derferences properly when only some of the captures are being moved with
// `capture_disjoint_fields` enabled.


#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| NOTE: `#[warn(incomplete_features)]` on by default
//~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
#![feature(rustc_attrs)]

#[derive(Debug, Default)]
struct SomeLargeType;
struct MuchLargerType([SomeLargeType; 32]);

// Ensure that we don't capture any derefs when moving captures into the closures,
// i.e. only data from the enclosing stack is moved.
fn big_box() {
let s = MuchLargerType(Default::default());
let b = Box::new(s);
let t = (b, 10);

let c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
|| {
//~^ First Pass analysis includes:
//~| Min Capture analysis includes:
let p = t.0.0;
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
println!("{} {:?}", t.1, p);
//~^ NOTE: Capturing t[(1, 0)] -> ImmBorrow
//~| NOTE: Min Capture t[(1, 0)] -> ImmBorrow
};

c();
}

fn main() {
big_box();
}
67 changes: 67 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/by_value.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
error[E0658]: attributes on expressions are experimental
--> $DIR/by_value.rs:22:13
|
LL | let c = #[rustc_capture_analysis]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable

warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/by_value.rs:5:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

error: First Pass analysis includes:
--> $DIR/by_value.rs:25:5
|
LL | / || {
LL | |
LL | |
LL | | let p = t.0.0;
... |
LL | |
LL | | };
| |_____^
|
note: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
--> $DIR/by_value.rs:28:17
|
LL | let p = t.0.0;
| ^^^^^
note: Capturing t[(1, 0)] -> ImmBorrow
--> $DIR/by_value.rs:31:29
|
LL | println!("{} {:?}", t.1, p);
| ^^^

error: Min Capture analysis includes:
--> $DIR/by_value.rs:25:5
|
LL | / || {
LL | |
LL | |
LL | | let p = t.0.0;
... |
LL | |
LL | | };
| |_____^
|
note: Min Capture t[(0, 0)] -> ByValue
--> $DIR/by_value.rs:28:17
|
LL | let p = t.0.0;
| ^^^^^
note: Min Capture t[(1, 0)] -> ImmBorrow
--> $DIR/by_value.rs:31:29
|
LL | println!("{} {:?}", t.1, p);
| ^^^

error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.
72 changes: 72 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/move_closure.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Test that move closures drop derefs with `capture_disjoint_fields` enabled.

#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| NOTE: `#[warn(incomplete_features)]` on by default
//~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
#![feature(rustc_attrs)]

// Test we truncate derefs properly
fn simple_ref() {
let mut s = 10;
let ref_s = &mut s;

let mut c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
move || {
//~^ ERROR: First Pass analysis includes:
//~| ERROR: Min Capture analysis includes:
*ref_s += 10;
//~^ NOTE: Capturing ref_s[Deref] -> ByValue
//~| NOTE: Min Capture ref_s[] -> ByValue
};
c();
}

// Test we truncate derefs properly
fn struct_contains_ref_to_another_struct() {
struct S(String);
struct T<'a>(&'a mut S);

let mut s = S("s".into());
let t = T(&mut s);

let mut c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
move || {
//~^ ERROR: First Pass analysis includes:
//~| ERROR: Min Capture analysis includes:
t.0.0 = "new s".into();
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
};

c();
}

// Test that we don't reduce precision when there is nothing deref.
fn no_ref() {
struct S(String);
struct T(S);

let t = T(S("s".into()));
let mut c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
move || {
//~^ ERROR: First Pass analysis includes:
//~| ERROR: Min Capture analysis includes:
t.0.0 = "new S".into();
//~^ NOTE: Capturing t[(0, 0),(0, 0)] -> ByValue
//~| NOTE: Min Capture t[(0, 0),(0, 0)] -> ByValue
};
c();
}

fn main() {
simple_ref();
struct_contains_ref_to_another_struct();
no_ref();
}
147 changes: 147 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/move_closure.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
error[E0658]: attributes on expressions are experimental
--> $DIR/move_closure.rs:14:17
|
LL | let mut c = #[rustc_capture_analysis]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable

error[E0658]: attributes on expressions are experimental
--> $DIR/move_closure.rs:35:17
|
LL | let mut c = #[rustc_capture_analysis]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable

error[E0658]: attributes on expressions are experimental
--> $DIR/move_closure.rs:55:17
|
LL | let mut c = #[rustc_capture_analysis]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable

warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/move_closure.rs:3:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

error: First Pass analysis includes:
--> $DIR/move_closure.rs:17:5
|
LL | / move || {
LL | |
LL | |
LL | | *ref_s += 10;
LL | |
LL | |
LL | | };
| |_____^
|
note: Capturing ref_s[Deref] -> ByValue
--> $DIR/move_closure.rs:20:9
|
LL | *ref_s += 10;
| ^^^^^^

error: Min Capture analysis includes:
--> $DIR/move_closure.rs:17:5
|
LL | / move || {
LL | |
LL | |
LL | | *ref_s += 10;
LL | |
LL | |
LL | | };
| |_____^
|
note: Min Capture ref_s[] -> ByValue
--> $DIR/move_closure.rs:20:9
|
LL | *ref_s += 10;
| ^^^^^^

error: First Pass analysis includes:
--> $DIR/move_closure.rs:38:5
|
LL | / move || {
LL | |
LL | |
LL | | t.0.0 = "new s".into();
LL | |
LL | |
LL | | };
| |_____^
|
note: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
--> $DIR/move_closure.rs:41:9
|
LL | t.0.0 = "new s".into();
| ^^^^^

error: Min Capture analysis includes:
--> $DIR/move_closure.rs:38:5
|
LL | / move || {
LL | |
LL | |
LL | | t.0.0 = "new s".into();
LL | |
LL | |
LL | | };
| |_____^
|
note: Min Capture t[(0, 0)] -> ByValue
--> $DIR/move_closure.rs:41:9
|
LL | t.0.0 = "new s".into();
| ^^^^^

error: First Pass analysis includes:
--> $DIR/move_closure.rs:58:5
|
LL | / move || {
LL | |
LL | |
LL | | t.0.0 = "new S".into();
LL | |
LL | |
LL | | };
| |_____^
|
note: Capturing t[(0, 0),(0, 0)] -> ByValue
--> $DIR/move_closure.rs:61:9
|
LL | t.0.0 = "new S".into();
| ^^^^^

error: Min Capture analysis includes:
--> $DIR/move_closure.rs:58:5
|
LL | / move || {
LL | |
LL | |
LL | | t.0.0 = "new S".into();
LL | |
LL | |
LL | | };
| |_____^
|
note: Min Capture t[(0, 0),(0, 0)] -> ByValue
--> $DIR/move_closure.rs:61:9
|
LL | t.0.0 = "new S".into();
| ^^^^^

error: aborting due to 9 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.
28 changes: 28 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/run_pass/by_value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// run-pass

// Test that ByValue captures compile sucessefully especially when the captures are
// derefenced within the closure.

#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete

#[derive(Debug, Default)]
struct SomeLargeType;
struct MuchLargerType([SomeLargeType; 32]);

fn big_box() {
let s = MuchLargerType(Default::default());
let b = Box::new(s);
let t = (b, 10);

let c = || {
let p = t.0.0;
println!("{} {:?}", t.1, p);
};

c();
}

fn main() {
big_box();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/by_value.rs:6:12
|
LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

warning: 1 warning emitted

Loading