forked from rust-lang/glacier
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- rust-lang/rust#99173 - rust-lang/rust#103708 - rust-lang/rust#104827 - rust-lang/rust#105209 - rust-lang/rust#106298 - rust-lang/rust#106423 Signed-off-by: Yuki Okushi <jtitor@2k36.org> rust-lang/rust#99173 Signed-off-by: Yuki Okushi <jtitor@2k36.org>
- Loading branch information
Showing
6 changed files
with
180 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,9 @@ | ||
#![feature(min_specialization)] | ||
|
||
trait Dance {} | ||
|
||
impl<'a, T> Dance for T {} | ||
|
||
impl Dance for bool {} | ||
|
||
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,15 @@ | ||
#![feature(try_trait_v2)] | ||
|
||
use std::ops::FromResidual; | ||
|
||
struct MySnafu; | ||
|
||
fn test_function() { | ||
impl FromResidual for MySnafu { | ||
fn from_residual(s: Self) -> Self { | ||
todo!() | ||
} | ||
} | ||
} | ||
|
||
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,5 @@ | ||
#!/bin/bash | ||
|
||
rustc -Zunpretty=ast-tree - << EOF | ||
#![c={#![c[)x | ||
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,50 @@ | ||
#!/bin/bash | ||
|
||
cat > Cargo.toml <<'EOF' | ||
[package] | ||
name = "alba" | ||
version = "0.0.1" | ||
edition = "2021" | ||
[dependencies] | ||
sera = { path = "sera/" } | ||
EOF | ||
|
||
mkdir -p src sera/src | ||
|
||
cat > sera/Cargo.toml <<'EOF' | ||
[package] | ||
name = "sera" | ||
version = "0.0.1" | ||
edition = "2021" | ||
[lib] | ||
crate-type = ["proc-macro"] | ||
EOF | ||
|
||
cat > sera/src/lib.rs << EOF | ||
extern crate proc_macro; | ||
struct PanicOnDrop; | ||
impl Drop for PanicOnDrop { | ||
fn drop(&mut self) { panic!("panic on drop!"); } | ||
} | ||
#[proc_macro_derive(Panic)] | ||
pub fn derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
let _p_on_d = PanicOnDrop; | ||
panic!("panic during panic-during-expand's derive") | ||
} | ||
EOF | ||
|
||
cat > src/main.rs << EOF | ||
#[macro_use] | ||
extern crate sena; | ||
#[derive(sena::Panic)] | ||
struct S { x: u8 } | ||
fn main() {} | ||
EOF | ||
|
||
cargo check |
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,52 @@ | ||
#![feature(generic_const_exprs, generic_arg_infer)] | ||
#![allow(incomplete_features)] | ||
#![allow(unused)] | ||
|
||
use std::mem::MaybeUninit; | ||
|
||
pub struct Arr<T, const N: usize> { | ||
v: [MaybeUninit<T>; N], | ||
} | ||
|
||
impl<T, const N: usize> Arr<T, N> { | ||
const ELEM: MaybeUninit<T> = MaybeUninit::uninit(); | ||
const INIT: [MaybeUninit<T>; N] = [Self::ELEM; N]; // important for optimization of `new` | ||
|
||
fn new() -> Self { | ||
Arr { v: Self::INIT } | ||
} | ||
} | ||
|
||
pub struct BaFormatFilter<const N: usize> {} | ||
|
||
pub enum DigitalFilter<const N: usize> | ||
where | ||
[(); N * 2 + 1]: Sized, | ||
[(); N * 2]: Sized, | ||
{ | ||
Ba(BaFormatFilter<{ N * 2 + 1 }>), | ||
} | ||
|
||
pub fn iirfilter_st_copy<const N: usize, const M: usize>(_: [f32; M]) -> DigitalFilter<N> | ||
where | ||
[(); N * 2 + 1]: Sized, | ||
[(); N * 2]: Sized, | ||
{ | ||
let zpk = zpk2tf_st(&Arr::<f32, { N * 2 }>::new(), &Arr::<f32, { N * 2 }>::new()); | ||
DigitalFilter::Ba(zpk) | ||
} | ||
|
||
pub fn zpk2tf_st<const N: usize>( | ||
_z: &Arr<f32, N>, | ||
_p: &Arr<f32, N>, | ||
) -> BaFormatFilter<{ N + 1 }> | ||
where | ||
[(); N + 1]: Sized, | ||
{ | ||
BaFormatFilter {} | ||
} | ||
|
||
|
||
fn main() { | ||
iirfilter_st_copy::<4, 2>([10., 50.,]); | ||
} |
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,49 @@ | ||
#!/bin/bash | ||
|
||
cat > Cargo.toml <<'EOF' | ||
[package] | ||
name = "alba" | ||
version = "0.0.1" | ||
edition = "2021" | ||
[dependencies] | ||
sera = { path = "sera/" } | ||
EOF | ||
|
||
mkdir -p src sera/src | ||
|
||
cat > sera/Cargo.toml <<'EOF' | ||
[package] | ||
name = "sera" | ||
version = "0.0.1" | ||
edition = "2021" | ||
[lib] | ||
crate-type = ["proc-macro"] | ||
EOF | ||
|
||
cat > sera/src/lib.rs << EOF | ||
extern crate proc_macro; | ||
#[proc_macro] | ||
pub fn ignore(input: TokenStream) -> TokenStream { | ||
let mut result : TokenStream = TokenStream::new(); | ||
result.into() | ||
} | ||
#[proc_macro] | ||
pub fn this_fails(input: TokenStream) -> TokenStream { | ||
let mut result : TokenStream = TokenStream::new(); | ||
result.extend::<TokenStream>("metamodel_macros::ignore!(42).into()".parse().unwrap()); | ||
result.into() | ||
} | ||
EOF | ||
|
||
cat > src/main.rs << EOF | ||
#[test] | ||
pub fn bug_report() { | ||
sera::this_fails!(1*2*3*7); | ||
} | ||
EOF | ||
|
||
cargo test |