Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,13 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
#[instrument(level = "trace", skip(self), ret)]
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
match (*a, *b) {
(ReLateBound(..), _) | (_, ReLateBound(..)) | (ReErased, _) | (_, ReErased) => {
(ReLateBound(..), _) | (_, ReLateBound(..)) => {
bug!("cannot relate region: LUB({:?}, {:?})", a, b);
}

(_, ReErased) => a,
(ReErased, _) => b,

(ReVar(v_id), _) | (_, ReVar(v_id)) => {
span_bug!(
self.var_infos[v_id].origin.span(),
Expand Down
29 changes: 29 additions & 0 deletions src/test/ui/impl-trait/unconstrained-tait-region-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// check-pass
// edition:2021

#![feature(type_alias_impl_trait)]

use std::future::Future;

pub trait Ctx {}

pub trait MyTrait {
type AssocT<'m, C>: Future<Output = ()> + 'm
where
Self: 'm,
C: Ctx + 'm;
fn run<'d, C: Ctx + 'd>(&mut self, c: C) -> Self::AssocT<'_, C>;
}

pub struct MyType;

impl MyTrait for MyType {
type AssocT<'m, C> = impl Future<Output = ()> + 'm where Self: 'm, C: Ctx + 'm;
fn run<'d, C: Ctx + 'd>(&mut self, c: C) -> Self::AssocT<'_, C> {
async move {}
}
}

fn main() {
let t = MyType;
}
38 changes: 38 additions & 0 deletions src/test/ui/impl-trait/unconstrained-tait-region.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// check-pass

#![feature(type_alias_impl_trait)]

struct Output;

trait Service {
type OutputStream;

fn stream<'l, 'a>(&'l self) -> Self::OutputStream
where
Self: 'a,
'l: 'a;
}

trait Stream {
type Item;
}

struct ImplStream<F: Fn()>(F);

impl<F: Fn()> Stream for ImplStream<F> {
type Item = Output;
}

impl Service for () {
type OutputStream = impl Stream<Item = Output>;

fn stream<'l, 'a>(&'l self) -> Self::OutputStream
where
Self: 'a,
'l: 'a,
{
ImplStream(|| ())
}
}

fn main() {}