Skip to content

Commit 3021598

Browse files
Do not register placeholder region outlives when considering_regions is false
1 parent db0597f commit 3021598

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
355355
}
356356

357357
ty::PredicateKind::RegionOutlives(data) => {
358-
if infcx.considering_regions || data.has_placeholders() {
358+
if infcx.considering_regions {
359359
infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data));
360360
}
361361

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// check-pass
2+
3+
struct Foo<'a> {
4+
foo: &'a mut usize,
5+
}
6+
7+
trait Bar<'a> {
8+
type FooRef<'b>
9+
where
10+
'a: 'b;
11+
fn uwu(foo: Foo<'a>, f: impl for<'b> FnMut(Self::FooRef<'b>));
12+
}
13+
impl<'a> Bar<'a> for () {
14+
type FooRef<'b>
15+
=
16+
&'b Foo<'a>
17+
where
18+
'a : 'b,
19+
;
20+
21+
fn uwu(
22+
foo: Foo<'a>,
23+
mut f: impl for<'b> FnMut(&'b Foo<'a>), //relevant part
24+
) {
25+
f(&foo);
26+
}
27+
}
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// check-pass
2+
3+
pub trait BufferTrait<'buffer> {
4+
type Subset<'channel>
5+
where
6+
'buffer: 'channel;
7+
8+
fn for_each_subset<F>(&self, f: F)
9+
where
10+
F: for<'channel> Fn(Self::Subset<'channel>);
11+
}
12+
13+
pub struct SomeBuffer<'buffer> {
14+
samples: &'buffer [()],
15+
}
16+
17+
impl<'buffer> BufferTrait<'buffer> for SomeBuffer<'buffer> {
18+
type Subset<'subset> = Subset<'subset> where 'buffer: 'subset;
19+
20+
fn for_each_subset<F>(&self, _f: F)
21+
where
22+
F: for<'subset> Fn(Subset<'subset>),
23+
{
24+
todo!()
25+
}
26+
}
27+
28+
pub struct Subset<'subset> {
29+
buffer: &'subset [()],
30+
}
31+
32+
fn main() {}

0 commit comments

Comments
 (0)