Implement feature(precise_capturing_of_types)
by compiler-errors · Pull Request #138473 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
- Set uncaptured ty/ct substs as bivariant. I'm almost certain is still quite broken, and I'll come up with a follow-up PR hopefully soon exercising some of the ways that it doesn't work today (related to the fact that "invariant xform bivariant = invariant").
- Validate that uncaptured ty/ct substs don't show up in the hidden type. I also reworked uncaptured ty/ct errors for TAITs. That diagnostic could also be improved tbh.
- Add a couple simple tests.
r? lcnr or reassign if you're not interested in reviewing feature work
tracking:
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Contributor
lcnr left a comment
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this avoid unconstrained type variables when doing something like
fn foo() -> impl Sized + use<> {}
fn main() { let x = foo(); // opaque; let y = x; // opaque<?unconstrained> }
it doesn't afaict :> this feature is still pretty broken, that's why it's incomplete
Comment on lines +228 to +245
let guar = if self.uncaptured_args.contains(&ct.into()) { |
---|
// FIXME(precise_capturing_of_types): Mention `use<>` list |
// and add an structured suggestion. |
self.tcx.dcx().struct_span_err( |
self.span, |
format!("hidden type mentions uncaptured const parameter `{ct}`"), |
) |
} else { |
self.tcx.dcx().struct_span_err( |
self.span, |
format!( |
"const parameter `{ct}` is mentioned in hidden type of \ |
type alias impl trait, but is not declared in its generic \ |
args" |
), |
) |
} |
.emit_unless(self.ignore_errors); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also extract this into a subfn?
it doesn't afaict :> this feature is still pretty broken, that's why it's incomplete
do you have a plan for how to fix this? I feel like the feature as is doesn't have much value and worry that we likely can't stabilize it without large changes
however, I don't think the cost of supporting this is meaningfully large, so r=me after nits
Labels
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.