File tree 4 files changed +130
-0
lines changed
4 files changed +130
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ rustc -Zmir-opt-level=3 --emit=mir - << EOF
4
+
5
+ pub trait Associate {
6
+ type Associated;
7
+ }
8
+
9
+ pub struct Wrap<'a> {
10
+ pub field: &'a i32,
11
+ }
12
+
13
+ pub trait Create<T> {
14
+ fn create() -> Self;
15
+ }
16
+
17
+ pub fn oh_no<'a, T>()
18
+ where
19
+ Wrap<'a>: Associate,
20
+ <Wrap<'a> as Associate>::Associated: Create<T>,
21
+ {
22
+ <Wrap<'a> as Associate>::Associated::create();
23
+ }
24
+
25
+ pub fn main() {}
26
+
27
+ EOF
Original file line number Diff line number Diff line change
1
+ use std:: ffi:: CString ;
2
+
3
+ impl Lock {
4
+ pub fn new ( ) {
5
+ if ( ) == -1 {
6
+ CString :: new ( ) ;
7
+ }
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ pub fn compose (
2
+ f1 : impl FnOnce ( f64 ) -> f64 + Clone ,
3
+ f2 : impl FnOnce ( f64 ) -> f64 + Clone ,
4
+ ) -> impl FnOnce ( f64 ) -> f64 + Clone {
5
+ move |x| f1 ( f2 ( x) )
6
+ }
7
+
8
+ pub fn double ( f : impl FnOnce ( f64 ) -> f64 + Clone ) -> impl FnOnce ( f64 ) -> f64 + Clone {
9
+ compose ( f. clone ( ) , f)
10
+ }
11
+
12
+
13
+ fn repeat_helper ( f : impl FnOnce ( f64 ) -> f64 + Clone , res : impl FnOnce ( f64 ) -> f64 + Clone , times : usize ) -> impl FnOnce ( f64 ) -> f64 + Clone {
14
+ if times == 1 {
15
+ return res;
16
+ }
17
+ repeat_helper ( f. clone ( ) , compose ( f, res) , times - 1 )
18
+ }
19
+
20
+ pub fn repeat ( f : impl FnOnce ( f64 ) -> f64 + Clone , times : usize ) -> impl FnOnce ( f64 ) -> f64 + Clone {
21
+ repeat_helper ( f. clone ( ) , f, times)
22
+ }
23
+
24
+ pub fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ rustc -Zmir-opt-level=3 --emit=mir - << EOF
4
+
5
+
6
+ // check-pass
7
+
8
+ #![allow(dead_code)]
9
+
10
+ trait ParseError {
11
+ type StreamError;
12
+ }
13
+
14
+ impl<T> ParseError for T {
15
+ type StreamError = ();
16
+ }
17
+
18
+ trait Stream {
19
+ type Item;
20
+ type Error: ParseError;
21
+ }
22
+
23
+ trait Parser
24
+ where
25
+ <Self as Parser>::PartialState: Default,
26
+ {
27
+ type PartialState;
28
+ fn parse_mode(_: &Self, _: Self::PartialState) {
29
+ loop {}
30
+ }
31
+ }
32
+
33
+ impl Stream for () {
34
+ type Item = ();
35
+ type Error = ();
36
+ }
37
+
38
+ impl Parser for () {
39
+ type PartialState = ();
40
+ }
41
+
42
+ struct AndThen<A, B>(core::marker::PhantomData<(A, B)>);
43
+
44
+ impl<A, B> Parser for AndThen<A, B>
45
+ where
46
+ A: Stream,
47
+ B: Into<<A::Error as ParseError>::StreamError>,
48
+ {
49
+ type PartialState = ();
50
+ }
51
+
52
+ fn expr<A>() -> impl Parser
53
+ where
54
+ A: Stream<Error = <A as Stream>::Item>,
55
+ {
56
+ AndThen::<A, ()>(core::marker::PhantomData)
57
+ }
58
+
59
+ fn parse_mode_impl<A>()
60
+ where
61
+ <A as Stream>::Error: ParseError,
62
+ A: Stream<Error = <A as Stream>::Item>,
63
+ {
64
+ Parser::parse_mode(&expr::<A>(), Default::default())
65
+ }
66
+
67
+ fn main() {}
68
+
69
+
70
+ EOF
You can’t perform that action at this time.
0 commit comments