about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2023-06-25 22:28:04 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2023-06-26 01:11:44 +0900
commit83722c62b08a2ced521a79f25be05a0c16a907d1 (patch)
treee915ada2e745fc8913cc266f83455f13f503fba1
parent0c2c243342ec2a2427f0624fac5ac59f0ee6fbcd (diff)
downloadrust-83722c62b08a2ced521a79f25be05a0c16a907d1.tar.gz
rust-83722c62b08a2ced521a79f25be05a0c16a907d1.zip
accept `ReStatic` for RPITIT
add an ui test for #112094
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs2
-rw-r--r--tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index f93f395caed..f43c7bbe9b8 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<TyCtxt<'tcx>> 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 00000000000..98dbaf036be
--- /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<const T: &'static str>(&self) -> impl Iterator<Item = Element>;
+}
+
+fn main() {}