Repository navigation
Conversation
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
This doesn't feel 100% sufficient and don't have the capacity to fully dive into this myself rn, started a zulip thread about it https://rust-lang.zulipchat.com/#narrow/channel/618216-t-types.2Fcall-for-participation/topic/yeet.20.27empty.20in.20region.20handling/with/621318591 |
| ty::ReVar(_) => (alt_span, "revar", region.to_string()), | ||
|
|
||
| ty::ReBound(..) => { | ||
| bug!("unexpected region for DescriptionCtx: {:?}", region); |
There was a problem hiding this comment.
any idea why we have ReVar/ReErases now? I kinda lost track of this.
There was a problem hiding this comment.
added separate handling for ReVar and ReErased because they represent different kinds of regions... so thought differentiating those would be better...
There was a problem hiding this comment.
So nothing blows up if we don't change them? Better keep them as is then. We want them to fail loud.
There was a problem hiding this comment.
This actually the upstream panics when it gets a ReErased region... so keeping it for now
There was a problem hiding this comment.
what code triggers the panic? some ui test?
There was a problem hiding this comment.
Oh, this is annoying. It has never been actually called before because it's a fallback for try_report_nice_region_error. And the diagnostics type must outlive [reerased] is confusing.
Would you like to investigate why try_report_trait_placeholder_mismatch doesn't work and try to make it work so that this fallback doesn't get triggered? The error kind we handle here is RegionResolutionError::UpperBoundUniverseConflict if I'm not mistaken.
There was a problem hiding this comment.
Yeah I think the blocker is that RelateParamBound doesn't carry the TypeTrace/ValuePairs data that try_report_trait_placeholder_mismatch needs.. it's (Span, Ty, Option) a completely different shape. we can't just add a match arm..
That's a separate, larger task with its own design and review. [This issue is truly annoying while working on this we just encountered 3 more]
There was a problem hiding this comment.
I guess we have to create a new diagnostics on our own then. Are you interested in doing that? 😃
It probably amounts to adding a new method try_report_placeholder_leak in fn try_report(), which would handle RegionResolutionError::UpperBoundUniverseConflict and emit a custom error.
The wording is likely similiar to TypeError::RegionsPlaceholderMismatch, plus regions' spans.
There was a problem hiding this comment.
yeah i will give it a try..
There was a problem hiding this comment.
Thanks! Feel free to ask if anything's unclear.
| ty::ReVar(_) => (alt_span, "revar", region.to_string()), | ||
|
|
||
| ty::ReBound(..) => { | ||
| bug!("unexpected region for DescriptionCtx: {:?}", region); |
There was a problem hiding this comment.
So nothing blows up if we don't change them? Better keep them as is then. We want them to fail loud.
|
Reminder, once the PR becomes ready for a review, use |
| // Regression test for https://github.com/rust-lang/rust/issues/161864 | ||
| //@ revisions: current next | ||
| //[next] compile-flags: -Znext-solver=coherence | ||
| //@ compile-flags: -Znext-solver |
There was a problem hiding this comment.
| // Regression test for https://github.com/rust-lang/rust/issues/161864 | |
| //@ revisions: current next | |
| //[next] compile-flags: -Znext-solver=coherence | |
| //@ compile-flags: -Znext-solver | |
| //@ revisions: current next | |
| //@[next] compile-flags: -Znext-solver | |
| // Regression test for https://github.com/rust-lang/rust/issues/161864 | |
| // We used to allow placeholders to outlive `'empty` in any universe, | |
| // which can be exploited to extend lifetimes. | |
| // `'empty` is a misleading name because the region can cover function body | |
| // for the callee. |
|
r? me so I don't forget about this. |
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Requested reviewer is already assigned to this pull request. Please choose another assignee. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@adwinwhite sorry for the ping. I have updated the patch; I just added a new diagnostic handler and I think this is working fine, and some of the other tests also fell into the case, so I had to change those to make it all green. |
There was a problem hiding this comment.
Going through most of the diagnostics changes, it seems that they're indeed placeholder leak errors.
The thing is that our new message is kinda confusing to users. So either we find a way to filter these new cases so they get reported as before, or we improve the wording of the new reporting here. I mildly lean towards the first option, if that's possible.
Sorry, this isn't very actionable. But it should be possible to distinguish the unsoundness case from these newly affected tests since they don't run into ICE?
| let mut diag = self | ||
| .tcx() | ||
| .dcx() | ||
| .struct_span_err(span, "higher-ranked lifetime error: lifetime outlives placeholder"); |
There was a problem hiding this comment.
Users shouldn't need to know what's an placeholder?
We use "one type is more general than the other" in higher ranked error sometimes. Not sure it can apply in all the cases here.
| | | ||
| LL | where for<'a> &'a T: Mirror<Image=U> | ||
| | ^^^^^^^ | ||
| = note: outer lifetimes cannot depend on placeholders declared in a higher universe |
There was a problem hiding this comment.
It seems that the old note has more useful info, not much better though.
…s handler cant handle
View all comments
stop skipping the check in
lexical_region_resolve/mod.rsand actually validate Empty lifetimes..follow-up - make
note_and_explain.rshandleReVarandReErasedso it prints a normal error message instead of exploding.. - (added ui-test and .stderr)fixes: #161864
r? @lcnr