Skip to content

Commit d02a221

Browse files
authored
Rollup merge of #102945 - compiler-errors:placeholder-region-outlives, r=lcnr
Do not register placeholder `RegionOutlives` obligations when `considering_regions` is false **NOTE:** I'm kinda just putting this up for discussion. I'm not certain this is correct...? This was introduced in [`608625d`](608625d#diff-6e54b18681342ec725d75591dbf384ad08cd73df29db00485fe51b4e90f76ff7R361). Interestingly, we only check `data.has_placeholders()` for `RegionOutlives`, and not for `TypeOutlives`... why? For the record, that different treatment between `RegionOutlives` and `TypeOutlives` is why the fix "The compiling succeeds when all `'a : 'b` are replaced with `&'a () : 'b`" in #100689 _"works"_, but it seems like an implementation detail considering this. Also, why do we care about placeholder regions being registered if `considering_regions` is false? It doesn't seem to affect any UI tests, for example. r? `@lcnr` Fixes #102899 Fixes #100689
2 parents e91fd0b + 3021598 commit d02a221

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)