This repository has been archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1280 from matthiaskrgr/20220603
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
- Loading branch information
Showing
4 changed files
with
129 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,27 @@ | ||
#!/bin/sh | ||
|
||
rustc -Zmir-opt-level=3 --emit=mir - << EOF | ||
pub trait Associate { | ||
type Associated; | ||
} | ||
pub struct Wrap<'a> { | ||
pub field: &'a i32, | ||
} | ||
pub trait Create<T> { | ||
fn create() -> Self; | ||
} | ||
pub fn oh_no<'a, T>() | ||
where | ||
Wrap<'a>: Associate, | ||
<Wrap<'a> as Associate>::Associated: Create<T>, | ||
{ | ||
<Wrap<'a> as Associate>::Associated::create(); | ||
} | ||
fn main() {} | ||
EOF |
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,11 @@ | ||
use std::ffi::CString; | ||
|
||
impl Lock { | ||
pub fn new() { | ||
if () == -1 { | ||
CString::new(); | ||
} | ||
} | ||
} | ||
|
||
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,24 @@ | ||
pub fn compose( | ||
f1: impl FnOnce(f64) -> f64 + Clone, | ||
f2: impl FnOnce(f64) -> f64 + Clone, | ||
) -> impl FnOnce(f64) -> f64 + Clone { | ||
move |x| f1(f2(x)) | ||
} | ||
|
||
pub fn double(f: impl FnOnce(f64) -> f64 + Clone) -> impl FnOnce(f64) -> f64 + Clone { | ||
compose(f.clone(), f) | ||
} | ||
|
||
|
||
fn repeat_helper(f: impl FnOnce(f64) -> f64 + Clone, res: impl FnOnce(f64) -> f64 + Clone, times: usize) -> impl FnOnce(f64) -> f64 + Clone { | ||
if times == 1 { | ||
return res; | ||
} | ||
repeat_helper(f.clone(), compose(f, res), times - 1) | ||
} | ||
|
||
pub fn repeat(f: impl FnOnce(f64) -> f64 + Clone, times: usize) -> impl FnOnce(f64) -> f64 + Clone { | ||
repeat_helper(f.clone(), f, times) | ||
} | ||
|
||
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,67 @@ | ||
#!/bin/sh | ||
|
||
rustc -Zmir-opt-level=3 --emit=mir - << EOF | ||
// check-pass | ||
#![allow(dead_code)] | ||
trait ParseError { | ||
type StreamError; | ||
} | ||
impl<T> ParseError for T { | ||
type StreamError = (); | ||
} | ||
trait Stream { | ||
type Item; | ||
type Error: ParseError; | ||
} | ||
trait Parser | ||
where | ||
<Self as Parser>::PartialState: Default, | ||
{ | ||
type PartialState; | ||
fn parse_mode(_: &Self, _: Self::PartialState) { | ||
loop {} | ||
} | ||
} | ||
impl Stream for () { | ||
type Item = (); | ||
type Error = (); | ||
} | ||
impl Parser for () { | ||
type PartialState = (); | ||
} | ||
struct AndThen<A, B>(core::marker::PhantomData<(A, B)>); | ||
impl<A, B> Parser for AndThen<A, B> | ||
where | ||
A: Stream, | ||
B: Into<<A::Error as ParseError>::StreamError>, | ||
{ | ||
type PartialState = (); | ||
} | ||
fn expr<A>() -> impl Parser | ||
where | ||
A: Stream<Error = <A as Stream>::Item>, | ||
{ | ||
AndThen::<A, ()>(core::marker::PhantomData) | ||
} | ||
fn parse_mode_impl<A>() | ||
where | ||
<A as Stream>::Error: ParseError, | ||
A: Stream<Error = <A as Stream>::Item>, | ||
{ | ||
Parser::parse_mode(&expr::<A>(), Default::default()) | ||
} | ||
fn main() {} | ||
EOF |