Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 0 deletions.
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, _>();
}
15 changes: 15 additions & 0 deletions ices/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() {}
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
12 changes: 12 additions & 0 deletions ices/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() {}
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);
}

0 comments on commit 5c98aaa

Please sign in to comment.