From 83722c62b08a2ced521a79f25be05a0c16a907d1 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sun, 25 Jun 2023 22:28:04 +0900 Subject: [PATCH] accept `ReStatic` for RPITIT add an ui test for #112094 --- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 2 +- .../static-lifetime-return-position-impl-trait.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index f93f395caed68..f43c7bbe9b85b 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1550,7 +1550,7 @@ impl<'tcx> TypeVisitor> for ImplTraitInTraitFinder<'_, 'tcx> { { let opaque_ty = tcx.fold_regions(unshifted_opaque_ty, |re, _depth| { match re.kind() { - ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReError(_) => re, + ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReError(_) | ty::ReStatic => re, r => bug!("unexpected region: {r:?}"), } }); diff --git a/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs new file mode 100644 index 0000000000000..98dbaf036be7b --- /dev/null +++ b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs @@ -0,0 +1,12 @@ +// check-pass + +#![allow(incomplete_features)] +#![feature(adt_const_params, return_position_impl_trait_in_trait)] + +pub struct Element; + +pub trait Node { + fn elements(&self) -> impl Iterator; +} + +fn main() {}