-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Normalize capture place tys to prevent ICE
#152165
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
Open
JohnTitor
wants to merge
9
commits into
rust-lang:main
Choose a base branch
from
JohnTitor:issue-151579
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+143
−50
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b7d6767
Normalize capture place `ty`s to prevent ICE
JohnTitor 0d9f020
call `try_structurally_resolve_type` before emitting diag
JohnTitor 1d395f1
Deeply normalize on next solver
JohnTitor a8c0441
improve normalization way
JohnTitor 52cf4ba
Move normalization forward up
JohnTitor 82b09a1
Normalize the whole `Place`
JohnTitor a4e7e0c
deeply normalize only on next solver
JohnTitor d79fe52
Remove comment about ExprUseVisitor
JohnTitor dddbf96
simplify `normalize_capture_place`
JohnTitor 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 was deleted.
Oops, something went wrong.
12 changes: 11 additions & 1 deletion
12
tests/crashes/120811.rs → ...closure-capture-hrtb-gat-no-ice-120811.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
30 changes: 30 additions & 0 deletions
30
tests/ui/traits/next-solver/normalize-capture-place-151579.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,30 @@ | ||
| // Regression test for #151579 | ||
| //@ compile-flags: -Znext-solver=globally | ||
| //@ edition:2018 | ||
|
|
||
| #![deny(rust_2021_incompatible_closure_captures)] | ||
|
|
||
| struct Dummy; | ||
|
|
||
| trait Trait { | ||
| type Assoc; | ||
| } | ||
|
|
||
| impl Trait for Dummy { | ||
| type Assoc = (*mut i32,); | ||
| } | ||
|
|
||
| struct SyncPointer(<Dummy as Trait>::Assoc); | ||
| unsafe impl Sync for SyncPointer {} | ||
|
|
||
| fn test_assoc_capture(a: SyncPointer) { | ||
| let _ = move || { | ||
| //~^ ERROR: changes to closure capture | ||
| let _x = a.0.0; | ||
| }; | ||
| } | ||
|
|
||
| fn main() { | ||
| let ptr = SyncPointer((std::ptr::null_mut(),)); | ||
| test_assoc_capture(ptr); | ||
| } |
23 changes: 23 additions & 0 deletions
23
tests/ui/traits/next-solver/normalize-capture-place-151579.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,23 @@ | ||
| error: changes to closure capture in Rust 2021 will affect which traits the closure implements | ||
| --> $DIR/normalize-capture-place-151579.rs:21:13 | ||
| | | ||
| LL | let _ = move || { | ||
| | ^^^^^^^ in Rust 2018, this closure implements `Sync` as `a` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `a` is not fully captured and `a.0.0` does not implement `Sync` | ||
| LL | | ||
| LL | let _x = a.0.0; | ||
| | ----- in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0.0` | ||
| | | ||
| = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/disjoint-capture-in-closures.html> | ||
| note: the lint level is defined here | ||
| --> $DIR/normalize-capture-place-151579.rs:5:9 | ||
| | | ||
| LL | #![deny(rust_2021_incompatible_closure_captures)] | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| help: add a dummy let to cause `a` to be fully captured | ||
| | | ||
| LL ~ let _ = move || { | ||
| LL + let _ = &a; | ||
| | | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
&mut Placeinstead of taking by value and returning it again?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, addressed in dddbf96