-
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
Get rid of check_opaque_type_well_formed
#132757
Conversation
|
||
fn define<'a, 'b>() -> Opaque<'a, 'b> | ||
where | ||
'a: 'b, | ||
{ | ||
|| {} | ||
//~^ ERROR lifetime bound not satisfied |
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.
This is as bad as outlives errors we get within a defining scope, like:
fn foo<'a, T>(t: T) -> impl Sized + 'a { t }
error[E0309]: the parameter type `T` may not live long enough
--> src/lib.rs:1:42
|
1 | fn foo<'a, T>(t: T) -> impl Sized + 'a { t }
| -- ^ ...so that the type `T` will meet its required lifetime bounds
| |
| the parameter type `T` must be valid for the lifetime `'a` as defined here...
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.
can we also emit the "this definition site has more where clauses than the opaque type" note for region errors, I feel like it's even more useful there
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.
really annoying to do that given the way that region error reporting is handled with a totally different error path :/
72940c7
to
97dfe8b
Compare
@@ -364,6 +393,97 @@ fn check_opaque_meets_bounds<'tcx>( | |||
} | |||
} | |||
|
|||
fn best_definition_site_of_opaque<'tcx>( |
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.
This is kinda annoyingly duplicated w/ the TAIT visitor, but also I could not find a way to genericize that without making it a mess, since it has a lot of responsibilities.
cc @oli-obk r=me after suggestion |
I remember we added the duplicate check in borrowck because the wf check failed to handle lifetimes in all cases. |
@oli-obk: #96736 does not seem to suggest that this extra well-formedness check is necessary for correctness, and instead is used for improving diagnostics.
We don't even check lifetimes in the borrowck copy of the well-formedness check, so I'm not totally sure what you mean.... As far as I can tell, the checks in |
Ah, I misremembered. Thanks for investigating. |
I spent an hour on this and could not get the lifetime error reporting machinery to work correctly, so I won't do anything else to this PR. @bors r=lcnr |
Get rid of `check_opaque_type_well_formed` Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`. This has two consequences: 1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF. 2. Spans have gotten slightly worse. Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration. r? lcnr
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
lol that definitely has nothing to do with opaques @bors retry |
…kingjubilee Rollup of 5 pull requests Successful merges: - rust-lang#132755 (Do not reveal opaques in the param-env, we got lazy norm instead) - rust-lang#132757 (Get rid of `check_opaque_type_well_formed`) - rust-lang#132760 (Don't suggest `.into_iter()` on iterators) - rust-lang#132778 (update io::Error::into_inner to acknowledge io::Error::other) - rust-lang#132780 (use verbose for path separator suggestion) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132757 - compiler-errors:yeet-check-wf, r=lcnr Get rid of `check_opaque_type_well_formed` Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`. This has two consequences: 1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF. 2. Spans have gotten slightly worse. Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration. r? lcnr
Get rid of `check_opaque_type_well_formed` Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`. This has two consequences: 1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF. 2. Spans have gotten slightly worse. Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration. r? lcnr
…kingjubilee Rollup of 5 pull requests Successful merges: - rust-lang#132755 (Do not reveal opaques in the param-env, we got lazy norm instead) - rust-lang#132757 (Get rid of `check_opaque_type_well_formed`) - rust-lang#132760 (Don't suggest `.into_iter()` on iterators) - rust-lang#132778 (update io::Error::into_inner to acknowledge io::Error::other) - rust-lang#132780 (use verbose for path separator suggestion) r? `@ghost` `@rustbot` modify labels: rollup
Instead, replicate it by improving the span of the opaque in
check_opaque_meets_bounds
.This has two consequences:
Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration.
r? lcnr