Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 97667cf

Browse files
authored
Merge pull request #1615 from JohnTitor/ices-20230625
2 parents b0f47b8 + add5143 commit 97667cf

File tree

9 files changed

+172
-0
lines changed

9 files changed

+172
-0
lines changed

ices/110453.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub struct B;
2+
pub fn a() -> B {
3+
B
4+
}
5+
6+
mod handlers {
7+
pub struct C(B);
8+
pub fn c() -> impl Fn() -> C {
9+
let a1 = ();
10+
|| C((crate::a(), a1).into())
11+
}
12+
}
13+
14+
fn main() {}

ices/110534.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#![allow(coherence_leak_check)]
2+
3+
use core::cell::Ref;
4+
5+
struct System;
6+
7+
trait IntoSystem {
8+
fn into_system(self) -> System;
9+
}
10+
11+
impl IntoSystem for fn(Ref<'_, u32>) {
12+
fn into_system(self) -> System {
13+
System
14+
}
15+
}
16+
17+
impl<A> IntoSystem for fn(A)
18+
where
19+
// n.b. No `Ref<'_, u32>` can satisfy this bound
20+
A: 'static + for<'x> MaybeBorrowed<'x, Output = A>,
21+
{
22+
fn into_system(self) -> System {
23+
System
24+
}
25+
}
26+
27+
//---------------------------------------------------
28+
29+
trait MaybeBorrowed<'a> {
30+
type Output: 'a;
31+
}
32+
33+
// If you comment this out you'll see the compiler chose to look at the
34+
// fn(A) implementation of IntoSystem above
35+
impl<'a, 'b> MaybeBorrowed<'a> for Ref<'b, u32> {
36+
type Output = Ref<'a, u32>;
37+
}
38+
39+
// ---------------------------------------------
40+
41+
fn main() {
42+
fn sys_ref(_age: Ref<u32>) {}
43+
let _sys_c = (sys_ref as fn(_)).into_system();
44+
// properly fails
45+
// let _sys_c = (sys_ref as fn(Ref<'static, u32>)).into_system();
46+
// properly succeeds
47+
// let _sys_c = (sys_ref as fn(Ref<'_, u32>)).into_system();
48+
}

ices/111470.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(dead_code)]
2+
#![allow(unused_variables)]
3+
#![feature(type_alias_impl_trait)]
4+
5+
use std::fmt::Debug;
6+
use std::marker::PhantomData;
7+
8+
struct Foo<T: Debug, F: FnOnce(T)> {
9+
f: F,
10+
_phantom: PhantomData<T>,
11+
}
12+
13+
type ImplT = impl Debug;
14+
type FooImpl = Foo<ImplT, impl FnOnce(ImplT)>;
15+
16+
fn bar() -> FooImpl {
17+
let x = 5i32;
18+
Foo::<i32, _> {
19+
f: |_| (),
20+
_phantom: PhantomData,
21+
}
22+
}
23+
24+
fn main() {}

ices/111742.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![allow(incomplete_features)]
2+
#![feature(generic_const_exprs)]
3+
4+
const CONST: u32 = 0;
5+
struct Test<const N: u32, const M: u32 = { CONST/* Must be a const and not a Literal */ }> where [(); N as usize]: , ([u32; N as usize]);
6+
7+
fn main() {
8+
let _: Test<1>;
9+
}

ices/112047.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![feature(async_fn_in_trait)]
2+
3+
fn main() {
4+
let _ = async {
5+
A.first().await.second().await;
6+
};
7+
}
8+
9+
pub trait First {
10+
type Second: Second;
11+
async fn first(self) -> Self::Second;
12+
}
13+
14+
struct A;
15+
16+
impl First for A {
17+
type Second = A;
18+
async fn first(self) -> Self::Second {
19+
A
20+
}
21+
}
22+
23+
pub trait Second {
24+
async fn second(self);
25+
}
26+
27+
impl<C> Second for C
28+
where
29+
C: First,
30+
{
31+
async fn second(self) {
32+
self.first().await.second().await;
33+
}
34+
}

ices/112630.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enum Foo {
2+
Bar(B),
3+
}
4+
5+
fn main() {
6+
let _ = [0u32; Foo::Bar as usize];
7+
}

ices/112822.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(const_trait_impl)]
2+
3+
const fn test() -> impl ~const Fn() {
4+
const move || {
5+
let sl: &[u8] = b"foo";
6+
7+
match sl {
8+
[first, _remainder @ ..] => {
9+
assert_eq!(first, &b'f');
10+
}
11+
[] => panic!(),
12+
}
13+
}
14+
}
15+
16+
fn main() {}

ices/112824.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pub struct Opcode(pub u8);
2+
3+
pub struct Opcode2(&'a S);
4+
5+
impl Opcode2 {
6+
pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
7+
}
8+
9+
pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
10+
move |i| match msg_type {
11+
Opcode2::OP2 => unimplemented!(),
12+
}
13+
}
14+
15+
fn main() {}

ices/113016.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![feature(non_lifetime_binders)]
2+
3+
trait Trait<Input> {}
4+
5+
fn main(x: impl for<f> Trait<'_, Assoc = impl Trait<f> + '_>) {}

0 commit comments

Comments
 (0)