This repository was 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 #1427 from matthiaskrgr/1234
add 15+ ices?
- Loading branch information
Showing
20 changed files
with
379 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,15 @@ | ||
// crash with edition=2021 | ||
pub struct Example<'a, T> { | ||
a: T, | ||
b: &'a T, | ||
} | ||
|
||
impl<'a, T> Example<'a, T> { | ||
pub fn error_trying_to_destructure_self_in_closure(self) { | ||
let closure = || { | ||
let Self { a, b } = self; | ||
}; | ||
} | ||
} | ||
|
||
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,12 @@ | ||
#![feature(allocator_api)] | ||
|
||
#![feature(const_trait_impl)] | ||
use core::convert::{From, TryFrom}; | ||
use std::pin::Pin; | ||
use std::alloc::Allocator; | ||
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>> | ||
where | ||
A: 'static, | ||
{} | ||
|
||
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,34 @@ | ||
use std::marker::PhantomData; | ||
|
||
#[derive(Default)] | ||
struct MyType<'a> { | ||
field: usize, | ||
_phantom: PhantomData<&'a ()>, | ||
} | ||
|
||
#[derive(Default)] | ||
struct MyTypeVariant<'a> { | ||
field: usize, | ||
_phantom: PhantomData<&'a ()>, | ||
} | ||
|
||
trait AsVariantTrait { | ||
type Type; | ||
} | ||
|
||
impl<'a> AsVariantTrait for MyType<'a> { | ||
type Type = MyTypeVariant<'a>; | ||
} | ||
|
||
type Variant<G> = <G as AsVariantTrait>::Type; | ||
|
||
fn foo<T: Default, F: FnOnce(T)>(f: F) { | ||
let input = T::default(); | ||
f(input); | ||
} | ||
|
||
fn main() { | ||
foo(|a: Variant<MyType>| { | ||
a.field; | ||
}); | ||
} |
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,32 @@ | ||
use std::marker::PhantomData; | ||
|
||
#[derive(Default)] | ||
struct MyType<'a> { | ||
field: usize, | ||
_phantom: PhantomData<&'a ()>, | ||
} | ||
|
||
#[derive(Default)] | ||
struct MyTypeVariant<'a> { | ||
field: usize, | ||
_phantom: PhantomData<&'a ()>, | ||
} | ||
|
||
trait AsVariantTrait { | ||
type Type; | ||
} | ||
|
||
impl<'a> AsVariantTrait for MyType<'a> { | ||
type Type = MyTypeVariant<'a>; | ||
} | ||
|
||
fn foo<T: Default, F: FnOnce(T)>(f: F) { | ||
let input = T::default(); | ||
f(input); | ||
} | ||
|
||
fn main() { | ||
foo(|a: <MyType as AsVariantTrait>::Type| { | ||
a.field; | ||
}); | ||
} |
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,10 @@ | ||
pub fn ice( | ||
x: impl AsRef<str>, | ||
) -> impl IntoIterator<Item = ()> { | ||
vec![].append(&mut ice(x.as_ref())); | ||
|
||
Vec::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,19 @@ | ||
pub trait Trait { | ||
type Fut<'a> where Self: 'a; | ||
fn fun<'a, 'b>(&'a self, x: &'_ mut &'b ()) -> Self::Fut<'a> | ||
where | ||
'b: 'a; | ||
} | ||
impl Trait for () { | ||
type Fut<'a> = impl ::std::future::Future + 'a | ||
where | ||
Self: 'a; | ||
fn fun<'a, 'b>(&'a self, x: &'_ mut &'b ()) -> Self::Fut<'a> | ||
where | ||
'b: 'a, | ||
{ | ||
async { } | ||
} | ||
} | ||
|
||
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,9 @@ | ||
#![feature(core_intrinsics)] | ||
|
||
pub fn wrapping<T: Copy>(a: T, b: T) { | ||
let _z = core::intrinsics::wrapping_mul(a, b); | ||
} | ||
|
||
pub fn main() { | ||
wrapping(1,2); | ||
} |
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,34 @@ | ||
|
||
#![crate_type = "lib"] | ||
#![feature(lang_items)] | ||
#![no_std] | ||
|
||
struct NonNull<T: ?Sized>(*mut T); | ||
|
||
struct Unique<T: ?Sized>(NonNull<T>); | ||
|
||
#[lang = "owned_box"] | ||
pub struct Box<T: ?Sized>(Unique<T>); | ||
|
||
impl<T: ?Sized> Drop for Box<T> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[lang = "box_free"] | ||
#[inline(always)] | ||
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>) { | ||
dealloc(ptr.0.0) | ||
} | ||
|
||
#[inline(never)] | ||
fn dealloc<T: ?Sized>(_: *mut T) {} | ||
|
||
pub struct Foo<T>(T); | ||
|
||
pub fn foo(a: Option<Box<Foo<usize>>>) -> usize { | ||
let f = match a { | ||
None => Foo(0), | ||
Some(vec) => *vec, | ||
}; | ||
f.0 | ||
} |
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,43 @@ | ||
struct Ty1; | ||
struct Ty2; | ||
|
||
pub trait Trait<T> {} | ||
|
||
pub trait WithAssoc1<'a> { | ||
type Assoc; | ||
} | ||
pub trait WithAssoc2<'a> { | ||
type Assoc; | ||
} | ||
|
||
impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U) | ||
where | ||
T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>, | ||
U: for<'a> WithAssoc2<'a>, | ||
{ | ||
} | ||
|
||
impl WithAssoc1<'_> for Ty1 { | ||
type Assoc = (); | ||
} | ||
impl WithAssoc2<'_> for Ty1 { | ||
type Assoc = i32; | ||
} | ||
impl WithAssoc1<'_> for Ty2 { | ||
type Assoc = (); | ||
} | ||
impl WithAssoc2<'_> for Ty2 { | ||
type Assoc = u32; | ||
} | ||
|
||
fn foo<T, U, V>() | ||
where | ||
T: for<'a> WithAssoc1<'a>, | ||
U: for<'a> WithAssoc2<'a>, | ||
(T, U): Trait<V>, | ||
{ | ||
} | ||
|
||
fn main() { | ||
foo::<Ty1, Ty2, _>(); | ||
} |
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,7 @@ | ||
#![crate_type = "lib"] | ||
#![feature(rustc_attrs)] | ||
|
||
#[rustc_allocator] | ||
pub fn allocator() -> *const i8 { | ||
std::ptr::null() | ||
} |
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,6 @@ | ||
trait A{type B<'b>;} | ||
struct C; | ||
impl A for C { | ||
type B<b> =impl; | ||
fn a() -> Self::B<'a>; | ||
} |
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,13 @@ | ||
trait A { | ||
type B<'b>; | ||
fn a() -> Self::B<'static>; | ||
} | ||
|
||
struct C; | ||
|
||
struct Wrapper<T>(T); | ||
|
||
impl A for C { | ||
type B<T> = Wrapper<T>; | ||
fn a() -> Self::B<'static> {} | ||
} |
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 @@ | ||
#![crate_type = "lib"] | ||
#![feature(inline_const, const_type_id)] | ||
|
||
use std::alloc::Layout; | ||
use std::any::TypeId; | ||
use std::mem::transmute; | ||
use std::ptr::drop_in_place; | ||
|
||
pub struct VTable { | ||
layout: Layout, | ||
type_id: TypeId, | ||
drop_in_place: unsafe fn(*mut ()), | ||
} | ||
|
||
impl VTable { | ||
pub fn new<T>() -> &'static Self { | ||
const { | ||
&VTable { | ||
layout: Layout::new::<T>(), | ||
type_id: TypeId::of::<T>(), | ||
drop_in_place: unsafe { | ||
transmute::<unsafe fn(*mut T), unsafe fn(*mut ())>(drop_in_place::<T>) | ||
}, | ||
} | ||
} | ||
} | ||
} |
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,22 @@ | ||
#!/bin/bash | ||
|
||
rustc -Zmir-opt-level=3 - <<'EOF' | ||
const L: usize = 4; | ||
pub trait Print<const N: usize> { | ||
fn print(&self) -> usize { | ||
N | ||
} | ||
} | ||
pub struct Printer; | ||
impl Print<L> for Printer {} | ||
fn main() { | ||
let p = Printer; | ||
assert_eq!(p.print(), 4); | ||
} | ||
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,23 @@ | ||
#![feature(return_position_impl_trait_in_trait)] | ||
|
||
trait Marker {} | ||
impl Marker for u32 {} | ||
|
||
trait MyTrait { | ||
fn foo(&self) -> impl Marker | ||
where Self: Sized; | ||
} | ||
|
||
struct Outer; | ||
|
||
impl MyTrait for Outer { | ||
fn foo(&self) -> impl Marker { | ||
42 | ||
} | ||
} | ||
|
||
impl dyn MyTrait { | ||
fn other(&self) -> impl Marker { | ||
MyTrait::foo(&self) | ||
} | ||
} |
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,21 @@ | ||
#!/bin/bash | ||
|
||
cat > out.rs <<'EOF' | ||
trait A<Y, N> { | ||
type B; | ||
} | ||
type MaybeBox<T> = <T as A<T, Box<T>>>::B; | ||
struct P { | ||
t: MaybeBox<P> | ||
} | ||
impl<Y, N> A<Y, N> for P { | ||
type B = N; | ||
} | ||
fn main() { | ||
let t: MaybeBox<P>; | ||
} | ||
EOF | ||
|
||
rustdoc --edition=2021 out.rs |
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,8 @@ | ||
#![feature(dyn_star)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn main() { | ||
let i = 42 as &dyn* Debug; | ||
} |
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,10 @@ | ||
#![feature(dyn_star)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn main() { | ||
let i = [1, 2, 3, 4] as dyn* Debug; | ||
|
||
dbg!(i); | ||
} |
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,29 @@ | ||
use std::marker::PhantomData; | ||
|
||
pub struct NfaBuilder<'brand> { | ||
brand: PhantomData<&'brand mut &'brand mut ()>, | ||
} | ||
|
||
impl NfaBuilder<'_> { | ||
pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R { | ||
Brand::with(|brand| { | ||
// This should be using NfaBuilder instead of Self becuase they have diffrent lifetime constraints | ||
f(Self { | ||
brand: brand.lt, | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct Brand<'brand> { | ||
lt: PhantomData<&'brand mut &'brand mut ()>, | ||
} | ||
|
||
impl Brand<'_> { | ||
pub fn with<R, F: FnOnce(Brand<'_>) -> R>(f: F) -> R { | ||
f(Self { lt: PhantomData }) | ||
} | ||
} | ||
|
||
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,5 @@ | ||
#![crate_type = "lib"] | ||
#![feature(async_fn_in_trait)] | ||
trait T { | ||
async fn foo(); | ||
} |