forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Use hir::Place instead of Symbol in closure_kind_origin #36
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ui/closures/2229_closure_analysis/diagnostics/closure-origin-multi-variant-diagnostics.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #![feature(capture_disjoint_fields)] | ||
| //~^ WARNING: the feature `capture_disjoint_fields` is incomplete | ||
| //~| `#[warn(incomplete_features)]` on by default | ||
| //~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488> | ||
|
|
||
| // Check that precise paths are being reported back in the error message. | ||
|
|
||
|
|
||
| enum MultiVariant { | ||
| Point(i32, i32), | ||
| Meta(i32) | ||
| } | ||
|
|
||
| fn main() { | ||
| let mut point = MultiVariant::Point(10, -10,); | ||
|
|
||
| let mut meta = MultiVariant::Meta(1); | ||
|
|
||
| let c = || { | ||
| if let MultiVariant::Point(ref mut x, _) = point { | ||
| *x += 1; | ||
| } | ||
|
|
||
| if let MultiVariant::Meta(ref mut v) = meta { | ||
| *v += 1; | ||
| } | ||
| }; | ||
|
|
||
| let a = c; | ||
| let b = c; //~ ERROR use of moved value: `c` [E0382] | ||
| } |
26 changes: 26 additions & 0 deletions
26
...losures/2229_closure_analysis/diagnostics/closure-origin-multi-variant-diagnostics.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes | ||
| --> $DIR/closure-origin-multi-variant-diagnostics.rs:1: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[E0382]: use of moved value: `c` | ||
| --> $DIR/closure-origin-multi-variant-diagnostics.rs:30:13 | ||
| | | ||
| LL | let a = c; | ||
| | - value moved here | ||
| LL | let b = c; | ||
| | ^ value used here after move | ||
| | | ||
| note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `point.0` out of its environment | ||
| --> $DIR/closure-origin-multi-variant-diagnostics.rs:20:52 | ||
| | | ||
| LL | if let MultiVariant::Point(ref mut x, _) = point { | ||
| | ^^^^^ | ||
|
|
||
| error: aborting due to previous error; 1 warning emitted | ||
|
|
||
| For more information about this error, try `rustc --explain E0382`. |
26 changes: 26 additions & 0 deletions
26
...i/closures/2229_closure_analysis/diagnostics/closure-origin-single-variant-diagnostics.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #![feature(capture_disjoint_fields)] | ||
| //~^ WARNING: the feature `capture_disjoint_fields` is incomplete | ||
| //~| `#[warn(incomplete_features)]` on by default | ||
| //~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488> | ||
|
|
||
| // Check that precise paths are being reported back in the error message. | ||
|
|
||
| enum SingleVariant { | ||
| Point(i32, i32), | ||
| } | ||
|
|
||
| fn main() { | ||
| let mut point = SingleVariant::Point(10, -10); | ||
|
|
||
| let c = || { | ||
| // FIXME(project-rfc-2229#24): Change this to be a destructure pattern | ||
| // once this is fixed, to remove the warning. | ||
| if let SingleVariant::Point(ref mut x, _) = point { | ||
| //~^ WARNING: irrefutable if-let pattern | ||
| *x += 1; | ||
| } | ||
| }; | ||
|
|
||
| let b = c; | ||
| let a = c; //~ ERROR use of moved value: `c` [E0382] | ||
| } |
37 changes: 37 additions & 0 deletions
37
...osures/2229_closure_analysis/diagnostics/closure-origin-single-variant-diagnostics.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes | ||
| --> $DIR/closure-origin-single-variant-diagnostics.rs:1: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: irrefutable if-let pattern | ||
| --> $DIR/closure-origin-single-variant-diagnostics.rs:18:9 | ||
| | | ||
| LL | / if let SingleVariant::Point(ref mut x, _) = point { | ||
| LL | | | ||
| LL | | *x += 1; | ||
| LL | | } | ||
| | |_________^ | ||
| | | ||
| = note: `#[warn(irrefutable_let_patterns)]` on by default | ||
|
|
||
| error[E0382]: use of moved value: `c` | ||
| --> $DIR/closure-origin-single-variant-diagnostics.rs:25:13 | ||
| | | ||
| LL | let b = c; | ||
| | - value moved here | ||
| LL | let a = c; | ||
| | ^ value used here after move | ||
| | | ||
| note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `point.0` out of its environment | ||
| --> $DIR/closure-origin-single-variant-diagnostics.rs:18:53 | ||
| | | ||
| LL | if let SingleVariant::Point(ref mut x, _) = point { | ||
| | ^^^^^ | ||
|
|
||
| error: aborting due to previous error; 2 warnings emitted | ||
|
|
||
| For more information about this error, try `rustc --explain E0382`. |
25 changes: 25 additions & 0 deletions
25
src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-struct-diagnostics.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #![feature(capture_disjoint_fields)] | ||
| //~^ WARNING: the feature `capture_disjoint_fields` is incomplete | ||
| //~| `#[warn(incomplete_features)]` on by default | ||
| //~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488> | ||
|
|
||
| // Check that precise paths are being reported back in the error message. | ||
|
|
||
| struct Y { | ||
| y: X | ||
| } | ||
|
|
||
| struct X { | ||
| a: u32, | ||
| b: u32, | ||
| } | ||
|
|
||
| fn main() { | ||
| let mut x = Y { y: X { a: 5, b: 0 } }; | ||
| let hello = || { | ||
| x.y.a += 1; | ||
| }; | ||
|
|
||
| let b = hello; | ||
| let c = hello; //~ ERROR use of moved value: `hello` [E0382] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.