-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 repeat lifetime names from outer binder in print #102514
Conversation
f6486a6
to
1042b65
Compare
1042b65
to
a8f17e3
Compare
*self | ||
.region_map | ||
.entry(br) | ||
.or_insert_with(|| name(None, self.current_index, br)) |
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.
is that the issue why we're not printing the binder in the src/test/ui/where-clauses/higher-ranked-fn-type.rs
test?
We have both a late-bound region with name 'b
and index 0 and a placeholder with name 'b
and index 0.
I am not too confident in this code and ideally we stop printing placeholders as if they were bound regions.
@jackh726 do you have an idea how this should work or any expectations for how difficult it is to remove the placeholder hack all-together
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.
Seems like the reason this isn't printed is that we skip the binder in the error reporting code?!
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, we shouldn't do that. Either map_bound
or replace with placeholders. Skipping binders is incorrect for errors as well i think
@@ -2086,7 +2093,9 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { | |||
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { | |||
let name = &mut self.name; | |||
let region = match *r { | |||
ty::ReLateBound(_, br) => *self.region_map.entry(br).or_insert_with(|| name(br)), | |||
ty::ReLateBound(db, br) => { |
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.
that's weird, why is this not
ty::ReLateBound(db, br) => { | |
ty::ReLateBound(db, br) if db == self.current_index => { |
we shouldn't replace late-bound regions of inner binders.
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.
(ah, that's whatyou're currently doing inside of name
. i think it's better to do this here instead)
Its actually crazy because I half-fixed this completely independently locally, when working on something else. I don't think we should stop printing placeholders as bound vars. They're sort of an "internal detail" of how we solve higher-ranked bounds. What instead would you want to show the user? The lifetime name must come from somewhere. |
@@ -4,7 +4,7 @@ error: higher-ranked lifetime error | |||
LL | foo(&10); | |||
| ^^^^^^^^ | |||
| | |||
= note: could not prove `for<'b, 'a> &'b (): 'a` | |||
= note: could not prove `for<'b> &'b (): '_` |
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.
With the proposed change we don't create names for all anonymous late-bound vars.
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, this is what I did locally. Kind of weird. I guess it makes more sense to do what you had before.
d262260
to
e83dcf4
Compare
Haven't thought too deeply about this, but: Ideally we only show placeholders to users after already introducing the binder somewhere. E.g. if they are part of the trace of a selection error, we should start with the higher ranked obligation which uses |
0972678
to
048e637
Compare
I think this is a good start. @bors r+ |
…h726 Don't repeat lifetime names from outer binder in print Fixes rust-lang#102392 Fixes rust-lang#102414 r? `@lcnr`
…h726 Don't repeat lifetime names from outer binder in print Fixes rust-lang#102392 Fixes rust-lang#102414 r? ``@lcnr``
Rollup of 8 pull requests Successful merges: - rust-lang#99818 (don't ICE when normalizing closure input tys) - rust-lang#102514 (Don't repeat lifetime names from outer binder in print) - rust-lang#102661 (rustdoc: Document effect of fundamental types) - rust-lang#102782 (Add regression test for rust-lang#102124) - rust-lang#102790 (Fix llvm-tblgen for cross compiling) - rust-lang#102807 (Document `rust-docs-json` component) - rust-lang#102812 (Remove empty core::lazy and std::lazy) - rust-lang#102818 (Clean up rustdoc highlight.rs imports a bit) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #102392
Fixes #102414
r? @lcnr