From b276b65f46465cffe207b4b732e6ab4642d47558 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 14 May 2022 11:25:53 +0200 Subject: Forbid nested opaque types to reference HRTB from opaque types. --- compiler/rustc_resolve/src/late/lifetimes.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'compiler/rustc_resolve/src') diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index ae4455531ab..700d7c3bfb6 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -1025,6 +1025,20 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { } 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) + { + if !self.trait_definition_only { + let mut err = self.tcx.sess.struct_span_err( + lifetime.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()); + } } // We want to start our early-bound indices at the end of the parent scope, -- cgit 1.4.1-3-g733a5