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

Commit

Permalink
Merge pull request #1427 from matthiaskrgr/1234
Browse files Browse the repository at this point in the history
add 15+ ices?
  • Loading branch information
Alexendoo authored Oct 1, 2022
2 parents e356843 + 3562248 commit cd0b80b
Show file tree
Hide file tree
Showing 20 changed files with 379 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fixed/102089.rs
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() {}
12 changes: 12 additions & 0 deletions fixed/102156.rs
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() {}
34 changes: 34 additions & 0 deletions ices/101696-1.rs
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;
});
}
32 changes: 32 additions & 0 deletions ices/101696-2.rs
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;
});
}
10 changes: 10 additions & 0 deletions ices/101852.rs
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() {
}
19 changes: 19 additions & 0 deletions ices/101940.rs
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() {}
9 changes: 9 additions & 0 deletions ices/101962.rs
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);
}
34 changes: 34 additions & 0 deletions ices/101964.rs
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
}
43 changes: 43 additions & 0 deletions ices/102047.rs
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, _>();
}
7 changes: 7 additions & 0 deletions ices/102105.rs
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()
}
6 changes: 6 additions & 0 deletions ices/102114-1.rs
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>;
}
13 changes: 13 additions & 0 deletions ices/102114-2.rs
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> {}
}
27 changes: 27 additions & 0 deletions ices/102117.rs
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>)
},
}
}
}
}
22 changes: 22 additions & 0 deletions ices/102124.sh
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

23 changes: 23 additions & 0 deletions ices/102140.rs
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)
}
}
21 changes: 21 additions & 0 deletions ices/102154.sh
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
8 changes: 8 additions & 0 deletions ices/102172.rs
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;
}
10 changes: 10 additions & 0 deletions ices/102173.rs
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);
}
29 changes: 29 additions & 0 deletions ices/102209.rs
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() {}
5 changes: 5 additions & 0 deletions ices/102219.rs
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();
}

0 comments on commit cd0b80b

Please sign in to comment.