-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Don't carry MIR location in ConstraintCategory::CallArgument
#103641
Merged
Merged
Changes from 1 commit
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 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 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 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 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 @@ | ||
// edition:2021 | ||
|
||
struct StructA { | ||
b: StructB, | ||
} | ||
|
||
async fn spawn_blocking<T>(f: impl (Fn() -> T) + Send + Sync + 'static) -> T { | ||
todo!() | ||
} | ||
|
||
impl StructA { | ||
async fn foo(&self) { | ||
let bar = self.b.bar().await; | ||
spawn_blocking(move || { | ||
//~^ ERROR borrowed data escapes outside of associated function | ||
self.b; | ||
//~^ ERROR cannot move out of `self.b`, as `self` is a captured variable in an `Fn` closure | ||
}) | ||
.await; | ||
} | ||
} | ||
|
||
struct StructB {} | ||
|
||
impl StructB { | ||
async fn bar(&self) -> Option<u8> { | ||
None | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains 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,35 @@ | ||
error[E0507]: cannot move out of `self.b`, as `self` is a captured variable in an `Fn` closure | ||
--> $DIR/issue-103624.rs:16:13 | ||
| | ||
LL | async fn foo(&self) { | ||
| ----- captured outer variable | ||
LL | let bar = self.b.bar().await; | ||
LL | spawn_blocking(move || { | ||
| ------- captured by this `Fn` closure | ||
LL | | ||
LL | self.b; | ||
| ^^^^^^ move occurs because `self.b` has type `StructB`, which does not implement the `Copy` trait | ||
|
||
error[E0521]: borrowed data escapes outside of associated function | ||
--> $DIR/issue-103624.rs:14:9 | ||
| | ||
LL | async fn foo(&self) { | ||
| ----- | ||
| | | ||
| `self` is a reference that is only valid in the associated function body | ||
| let's call the lifetime of this reference `'1` | ||
LL | let bar = self.b.bar().await; | ||
LL | / spawn_blocking(move || { | ||
LL | | | ||
LL | | self.b; | ||
LL | | | ||
LL | | }) | ||
| | ^ | ||
| | | | ||
| |__________`self` escapes the associated function body here | ||
| argument requires that `'1` must outlive `'static` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0507, E0521. | ||
For more information about an error, try `rustc --explain E0507`. |
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 does erasing regions change diagnostics?
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.
Actually, good question -- I have no idea. My first suspicion when I put this PR up was due to the
Ord
implementation onConstraintCategory
and something about the sorting of constraints inbest_blame_constraint
, but I can look into it further.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.
Yeah, it's because we're not sorting by
variance_info
, but only the constraint:rust/compiler/rustc_borrowck/src/region_infer/mod.rs
Line 2230 in 0da281b
And we have several constraints that differ only in variant info:
-- so erasing regions probably causes hashes to change which causes the order constraints get ordered out to change.
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.
The differing
variance_info
causes this error message to change slightly in the note, as seen above. I think it's harmless imo. Same with all these other errors changing slightly.