-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Do not check outlives when explicit bound contains escaping regions #53736
Conversation
This makes the code similar to the handling of `ty::Ref` in `src/librustc/ty/wf.rs`, except checking for non-escaping-regions somewhere down the call chain instead of at the root. Fixes rust-lang#53548
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Ping from triage @nikomatsakis / @rust-lang/compiler: This PR requires your review. |
@nikomatsakis If you feel that there should be a I'm currently assuming the change is likely not-too-bad because it's similar to the handling of |
@Ekleog sorry I've not gotten back to you here :( let me add this to my to-do list. I took a look a few times but it's hard to remember the full context here. |
Ping from triage @nikomatsakis / @rust-lang/compiler: This PR requires your review. |
☔ The latest upstream changes (presumably #55330) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @pnkfelix |
Wow I/we really failed to address this fast enough:
Still the bug persists, as demonstrated on this playpen. |
(ah the current code calls a |
Also here is a more reduced test case (play) which still needs generators (and #![feature(async_await, futures_api, generators)]
// A trait with 'static bound
trait Trait: 'static {}
// The actual reproducer, requires that Trait is 'static and a trait
// object to it is captured in a closure for successful reproduction.
async fn foo(b: Box<Trait + 'static>) -> () {
let _bar = move || { b; () };
yield
}
pub fn main() {} |
Also, the example I just gave will actually ICE a debug-build of Lines 788 to 792 in 0195812
This lends credence to the idea that the proposed check, or something like it, may belong in: Lines 493 to 503 in 0195812
But I want to review RFC 1214 and the comment above this code carefully before approving/implementing such a change. The comment in particular says that the region bound in a trait object is a so-called "master bound" that implies that bounds from other traits are all met. So ... it seems plausible to sidestep pushing new obligations in this case ... but on the other hand, the interaction with generators troubles me. There may be some constraint imposed by generators that I am overlooking in my naive review of the stack trace and debug log. |
If I understand the debug logs correctly, the place we are ICE'ing on debug builds is when we attempt to evaluate a predicate as follows:
where And then we are ICE'ing because that witness holds escaping bound variables. Is that a sign of a bug elsewhere? Should the witness have escaping bound variables in this scenario? |
For example, another potential route for "fixing" the bug here might be to change this code here: rust/src/librustc_typeck/check/generator_interior.rs Lines 121 to 129 in 0195812
so that, as a special case, it does not replace (i don't understand what the generator_interior code is doing though, so its possible that replacing with Update: I didn't read the debug log carefully enough. The suggestion in this comment on its own would not resolve this issue, because we have already lost the |
The code that does the I'm still not clear on whether it needs to do its replacement so aggressively. Ignoring |
Potentially useful info: even this suffices to reproduce the ICE in the debug build of #![feature(async_await, futures_api, generators)]
// A trait with 'static bound
trait MyTrait: 'static {}
async fn foo(b: Box<MyTrait + 'static>) -> () {
let _bar = b;
yield
}
pub fn main() {} |
Wait a minute, what is this: rust/src/librustc_typeck/astconv.rs Lines 102 to 105 in 0195812
That is: should I not even be seeing Update: ARGH well these combinations of hacks are actively impeding the utility of debug logs: rust/src/librustc/util/ppaux.rs Lines 609 to 614 in 0195812
Update 2: Okay, one quick hack later to use unique numbers at each Lines 523 to 526 in 0195812
which is entirely unsurprising in hindsight, but good to confirm. |
Triage; @Ekleog Hello, have you been able to get back to this PR? |
@Aaronepower Not yet, sorry. I've had to move a bit to other things, will try to come back to it when I find some time… but likely not in the month to come, even though I was more hopeful when reading @pnkfelix's comments :/ If someone wants to take this over, by all means feel free! Otherwise I'll try to do it hopefully some time next year. |
@Ekleog Okay I'm going to close this PR. Feel free to reopen it once you are able to! Anyone who wants to continue should open a new PR referencing this one. |
This makes the code similar to the handling of
ty::Ref
insrc/librustc/ty/wf.rs
, except checking for non-escaping-regionssomewhere down the call chain instead of at the root.
Fixes #53548
Note: I have literally 0 confidence that this fix is actually correct, as I don't really understand all the surrounding code. However, it appears to break no test, and to pass the added test, equivalent to the one in #53548. Maybe the root cause of the issue is somewhere else, though.
Hope this helps! :)