Wf check closure's args while borrow checking its parent#153027
Wf check closure's args while borrow checking its parent#153027ShoyuVanilla wants to merge 1 commit intorust-lang:mainfrom
Conversation
| // for it, we might fail with the type test for it, which contains the opaque type | ||
| // and therefore `'b` as well. The problem is that if the normalized opaque type doesn't | ||
| // mentions `'b`, we have no local free region constrained by it, and end up | ||
| // emitting a borrowck error instead of propagating the closure requirements. |
There was a problem hiding this comment.
Filtering external bounds here regresses this
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Do not add outlives implied bounds that contains external regions/params only
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (484ac15): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (secondary 0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 481.498s -> 479.757s (-0.36%) |
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
This doesn't feel correct. I think I should rather add implied bounds as before and directly propagate them again as requirements. |
|
🗑️ Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
hmm, I do feel like only having implied bounds involving the late-bound things from the closure signature seems correct to me 🤔 |
Yeah, only keeping bounds that involve late-bound params feels right to me, too. But more precisely, I’m currently leaning toward I'm a bit more inclined to: adding all the implied bounds as before, but gathering the implied bounds don't involve the late bounds and throwing them as propagated closure requirements to the parent body. I don't have a solid logical basis for this yet 😅, but:
|
|
Added a bit messy experimental PoC commit: 96312b1 😅 |
This comment has been minimized.
This comment has been minimized.
|
#153027 (comment) I think this should allow more code as propagating requirements from closures doesn't propagate them perfectly, so having more knowledge about the external regions inside of the closure is useful to make it easier to only propagate the correct things. Looking at your impl, is there a reason we can't lazily go over the
Though separately, another fix would be to require the closure signature to be well-formed in the parent, would it? It's fine for the closure to assume that its signature is entirely wf if the parent body just explicitly checks that the signature is wf |
Not really. I was just doing quick PoC with a messy implementation and it ICEd 😅
Yeah, this sounds like a better fix 👍 |
96312b1 to
c23ddc5
Compare
cf603e6 to
b909428
Compare
|
@bors try @rust-timer queue @craterbot check |
|
Error occurred while parsing comment: Invalid command argument |
This comment has been minimized.
This comment has been minimized.
Wf check closure's args while borrow checking its parent
|
@rust-timer queue |
This comment has been minimized.
This comment has been minimized.
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
Oh, it tries to use the previous artifact instead of waiting for the current one 😅 |
|
🗑️ Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
💥 Test timed out after |
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Wf check closure's args while borrow checking its parent
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (c86ec27): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.0%, secondary -1.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 4.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 486.952s -> 486.921s (-0.01%) |
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
View all comments
Fixes #151637
The actuall cause wasn't that the closure's return type is not being wf checked.
For example, the following code is errored out as intended:
The problem was that we are adding implied bound
T: 'staticeven when borrowck-ing the closures.