forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for rust-lang#106874 ICE BoundUniversalRegionError
Fixes rust-lang#106874
- Loading branch information
1 parent
cc422ce
commit f2bc9c5
Showing
2 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// issue: rust-lang/rust#106874 | ||
// ICE BoundUniversalRegionError | ||
|
||
use std::marker::PhantomData; | ||
use std::rc::Rc; | ||
|
||
pub fn func<V, F: Fn(&mut V)>(f: F) -> A<impl X> { | ||
A(B(C::new(D::new(move |st| f(st))))) | ||
//~^ ERROR implementation of `FnOnce` is not general enough | ||
//~^^ ERROR implementation of `Fn` is not general enough | ||
//~^^^ ERROR implementation of `FnOnce` is not general enough | ||
//~^^^^ ERROR implementation of `FnOnce` is not general enough | ||
//~^^^^^ ERROR implementation of `Fn` is not general enough | ||
//~^^^^^^ ERROR implementation of `FnOnce` is not general enough | ||
//~^^^^^^^ ERROR implementation of `Fn` is not general enough | ||
//~^^^^^^^^ ERROR implementation of `FnOnce` is not general enough | ||
//~^^^^^^^^^ ERROR higher-ranked subtype error | ||
//~^^^^^^^^^^ ERROR higher-ranked subtype error | ||
} | ||
|
||
trait X {} | ||
trait Y { | ||
type V; | ||
} | ||
|
||
struct A<T>(T); | ||
|
||
struct B<T>(Rc<T>); | ||
impl<T> X for B<T> {} | ||
|
||
struct C<T: Y>(T::V); | ||
impl<T: Y> C<T> { | ||
fn new(_: T) -> Rc<Self> { | ||
todo!() | ||
} | ||
} | ||
struct D<V, F>(F, PhantomData<fn(&mut V)>); | ||
|
||
impl<V, F> D<V, F> { | ||
fn new(_: F) -> Self { | ||
todo!() | ||
} | ||
} | ||
impl<V, F: Fn(&mut V)> Y for D<V, F> { | ||
type V = V; | ||
} | ||
|
||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/ice-106874.rs:8:5 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: closure with signature `fn(&'0 mut V)` must implement `FnOnce<(&mut V,)>`, for some specific lifetime `'0`... | ||
= note: ...but it actually implements `FnOnce<(&'1 mut V,)>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/ice-106874.rs:8:5 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: closure with signature `fn(&'0 mut V)` must implement `FnOnce<(&mut V,)>`, for some specific lifetime `'0`... | ||
= note: ...but it actually implements `FnOnce<(&'1 mut V,)>`, for some specific lifetime `'1` | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: implementation of `Fn` is not general enough | ||
--> $DIR/ice-106874.rs:8:7 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | ||
| | ||
= note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/ice-106874.rs:8:7 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` | ||
|
||
error: implementation of `Fn` is not general enough | ||
--> $DIR/ice-106874.rs:8:7 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | ||
| | ||
= note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/ice-106874.rs:8:9 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` | ||
|
||
error: implementation of `Fn` is not general enough | ||
--> $DIR/ice-106874.rs:8:9 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | ||
| | ||
= note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/ice-106874.rs:8:9 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| | ||
= note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/ice-106874.rs:8:41 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^ | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/ice-106874.rs:8:41 | ||
| | ||
LL | A(B(C::new(D::new(move |st| f(st))))) | ||
| ^ | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: aborting due to 10 previous errors | ||
|