Skip to content
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

Deny non-lifetime bound vars in for<..> || closure binders #108186

Merged

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Feb 17, 2023

Moves the check for illegal bound var types from astconv to resolve_bound_vars. If a binder is defined to have a type or const late-bound var that's not allowed, we'll resolve any usages to ty error or const error values, so we shouldn't ever see late-bound types or consts in places they aren't expected.

Fixes #108184
Fixes #108181
Fixes #108192

@rustbot
Copy link
Collaborator

rustbot commented Feb 17, 2023

r? @WaffleLapkin

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 17, 2023
@@ -52,6 +52,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> Ty<'tcx> {
trace!("decl = {:#?}", closure.fn_decl);

deny_non_region_late_bound(self.tcx, closure.bound_generic_params, "closure");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this checks should probably be in rustc_hir_analysis::collect::lifetimes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to implement something like that. If binder doesn't allow late-bound ty or consts, then it'll resolve to ResolvedArg::Error instead, so we never actually see these late-bound type or const variables showing up where they shouldn't be.

Not sure if this is what you were looking for.

@compiler-errors compiler-errors force-pushed the closures-with-late-bound-types-r-bad branch from f4dd264 to cec7835 Compare February 18, 2023 03:29
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Feb 18, 2023

📌 Commit 5ec812d has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#108031 (Don't recover lifetimes/labels containing emojis as character literals)
 - rust-lang#108046 (Don't allow evaluating queries that were fed in a previous compiler run)
 - rust-lang#108162 (Don't eagerly convert principal to string)
 - rust-lang#108186 (Deny non-lifetime bound vars in `for<..> ||` closure binders)
 - rust-lang#108197 (Update cargo)
 - rust-lang#108205 (link to llvm changes that prompted the special cases)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d3d5163 into rust-lang:master Feb 18, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 18, 2023
@compiler-errors compiler-errors added the F-non_lifetime_binders `#![feature(non_lifetime_binders)]` label Mar 10, 2023
@compiler-errors compiler-errors deleted the closures-with-late-bound-types-r-bad branch August 11, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-non_lifetime_binders `#![feature(non_lifetime_binders)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants