diff options
| author | Michael Goulet <michael@errs.io> | 2022-10-12 04:03:59 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-10-12 04:04:55 +0000 |
| commit | 3021598fdbba9ce32d313bba6b49e03c7701da1f (patch) | |
| tree | 504eb3233a76d40be6c1cdccc85a847883a700f5 | |
| parent | db0597f5619d5ed93feca28e61226d3581cc7867 (diff) | |
| download | rust-3021598fdbba9ce32d313bba6b49e03c7701da1f.tar.gz rust-3021598fdbba9ce32d313bba6b49e03c7701da1f.zip | |
Do not register placeholder region outlives when considering_regions is false
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/fulfill.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/higher-rank-trait-bounds/issue-100689.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/higher-rank-trait-bounds/issue-102899.rs | 32 |
3 files changed, 62 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 6eb02395685..ee752a1c73d 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -355,7 +355,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> { } ty::PredicateKind::RegionOutlives(data) => { - if infcx.considering_regions || data.has_placeholders() { + if infcx.considering_regions { infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data)); } diff --git a/src/test/ui/higher-rank-trait-bounds/issue-100689.rs b/src/test/ui/higher-rank-trait-bounds/issue-100689.rs new file mode 100644 index 00000000000..2db7f8a354c --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-100689.rs @@ -0,0 +1,29 @@ +// check-pass + +struct Foo<'a> { + foo: &'a mut usize, +} + +trait Bar<'a> { + type FooRef<'b> + where + 'a: 'b; + fn uwu(foo: Foo<'a>, f: impl for<'b> FnMut(Self::FooRef<'b>)); +} +impl<'a> Bar<'a> for () { + type FooRef<'b> + = + &'b Foo<'a> + where + 'a : 'b, + ; + + fn uwu( + foo: Foo<'a>, + mut f: impl for<'b> FnMut(&'b Foo<'a>), //relevant part + ) { + f(&foo); + } +} + +fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/issue-102899.rs b/src/test/ui/higher-rank-trait-bounds/issue-102899.rs new file mode 100644 index 00000000000..952b81584f3 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-102899.rs @@ -0,0 +1,32 @@ +// check-pass + +pub trait BufferTrait<'buffer> { + type Subset<'channel> + where + 'buffer: 'channel; + + fn for_each_subset<F>(&self, f: F) + where + F: for<'channel> Fn(Self::Subset<'channel>); +} + +pub struct SomeBuffer<'buffer> { + samples: &'buffer [()], +} + +impl<'buffer> BufferTrait<'buffer> for SomeBuffer<'buffer> { + type Subset<'subset> = Subset<'subset> where 'buffer: 'subset; + + fn for_each_subset<F>(&self, _f: F) + where + F: for<'subset> Fn(Subset<'subset>), + { + todo!() + } +} + +pub struct Subset<'subset> { + buffer: &'subset [()], +} + +fn main() {} |
