-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Update E0088 to new format #36208
Update E0088 to new format #36208
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jonathandturner (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. |
count(lifetimes.len())); | ||
match lifetime_defs.len() { | ||
0 => err.span_label(span, &format!("unexpected lifetime parameter")), | ||
_ => err.span_label(span, &format!("{} lifetime parameters expected", |
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.
Now that we handle multiple cases, can you add to the unit test to check for these new cases?
Thanks for the PR! Looks like we'll need to test for some of your new cases. After that I think we're probably good to go. |
@jonathandturner I'm not much of a rust expert, but does the second case make sense? I can't think of a code to trigger this, perhaps you can point me in some useful direction? |
You could try an example that tests against two different functions, one with a lifetime and one without. Something like:
|
@jonathandturner That was also my first guess, but |
@yossi-k - looks like you're right. When I try it with functions, the lifetime parameters seem to be ignored. If I try it with traits, I just get a different error message:
It may not be possible to invoke the code path. If that's the case, it may make sense to always say "unexpected lifetime parameters" in the label |
@jonathandturner So considering that it doesn't seem possible to actually provide a lifetime parameter to a function, and providing lifetimes to other things (such as traits) is covered by a whole different set of errors (e.g. E0107), is this code segment actually needed? |
@yossi-k - you could try taking it out and running the unit test suite again and see what happens. If all of the errors are still caught by E0107, you might be right. And it would help us simplify things. |
@jonathandturner All tests seem to pass, so I'm guessing we're okay. |
@yossi-k - unfortunately, you can't safely merge multiple spans together, since spans can come from macros and might give you a broken span as a result. |
@jonathandturner What should I do in this case? Only reference one lifetime parameter, perhaps each individually or maybe just the entire function call? |
@yossi-k - I just added a way to safely merge spans to CodeMap. It's a new method called |
@yossi-k - after working some with @GuillaumeGomez, I think a better solution than merging spans would be to instead point at the argument when it's unexpected. You can see an example on E0050 |
@jonathandturner: It hasn't been updated yet. :p |
@GuillaumeGomez - moved it from a comment to the issue text. Should be updated now |
Closing due to inactivity, but feel free to resubmit with a rebase! |
Update E0088 to new error format Fixes rust-lang#35226 which is part of rust-lang#35233. Is based on rust-lang#36208 from @yossi-k. r? @jonathandturner
@jonathandturner You should've asked a rustc developer 😭. This (through #37835) introduced a regression which I only found because I was rewriting lifetime elision and I had to update this check. Thankfully it's only propagated to beta so we can just backport a fix, but this is scary that it just happened. What's confusing here is the distinction between early-bound and late-bound Late-bound lifetimes, explicitly expressed by For some historical reason or another, we ended up mapping lifetimes passed to a path to only the early-bound lifetimes and have no mechanism for "downgrading" late- to early-bound for paths with lifetimes. To wrap it up, this is the test I used (errors on 1.14 stable, incorrectly passes on beta/nightly): fn foo<'a: 'b, 'b: 'a>() {}
fn main() {
foo::<'static>();
} cc @rust-lang/compiler @rust-lang/lang |
That's just an implementation artifact, methinks. |
@eddyb - you're commenting on a closed PR, I assume you meant the merged one? Glad we could catch it in time. Looking at it now, definitely an oversight on my part. Clearly they changed the logic rather than just changing the message. |
E0088/E0090 fix This fixes an issue reported by @eddyb (#36208 (comment)) where the check for "too few lifetime parameters" was removed in one of the error message PRs. I also removed the span shrinking from E0088, as early bound lifetimes give you a confusing underline in some cases. r=eddyb
E0088/E0090 fix This fixes an issue reported by @eddyb (#36208 (comment)) where the check for "too few lifetime parameters" was removed in one of the error message PRs. I also removed the span shrinking from E0088, as early bound lifetimes give you a confusing underline in some cases. r=eddyb
Fixes #35226.
Part of #35233.
r? @jonathandturner