Skip to content

Correctly deny late-bound lifetimes from parent in anon consts and TAITs#115486

Merged
bors merged 2 commits intorust-lang:masterfrom
compiler-errors:dont-capture-late-pls
Sep 20, 2023
Merged

Correctly deny late-bound lifetimes from parent in anon consts and TAITs#115486
bors merged 2 commits intorust-lang:masterfrom
compiler-errors:dont-capture-late-pls

Conversation

@compiler-errors
Copy link
Contributor

@compiler-errors compiler-errors commented Sep 2, 2023

Reuse the AnonConstBoundary scope (introduced in #108553, renamed in this PR to LateBoundary) to deny late-bound vars of all kinds (ty/const/lifetime) in anon consts and TAITs.

Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657):

if !parent_id.is_owner() {
struct_span_err!(
self.tcx.sess,
lifetime.ident.span,
E0657,
"`impl Trait` can only capture lifetimes bound at the fn or impl level"
)
.emit();
self.uninsert_lifetime_on_error(lifetime, def.unwrap());
}
if let hir::Node::Item(hir::Item {
kind: hir::ItemKind::OpaqueTy { .. }, ..
}) = self.tcx.hir().get(parent_id)
{
let mut err = self.tcx.sess.struct_span_err(
lifetime.ident.span,
"higher kinded lifetime bounds on nested opaque types are not supported yet",
);
err.span_note(self.tcx.def_span(def_id), "lifetime declared here");
err.emit();
self.uninsert_lifetime_on_error(lifetime, def.unwrap());
}
but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched.

Fixes #115474

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. 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

Development

Successfully merging this pull request may close these issues.

ice Not enough bound vars: BoundRegion

9 participants