Skip to content

13 files changed

+241
-0
lines changed

ices/101964.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
#![crate_type = "lib"]
3+
#![feature(lang_items)]
4+
#![no_std]
5+
6+
struct NonNull<T: ?Sized>(*mut T);
7+
8+
struct Unique<T: ?Sized>(NonNull<T>);
9+
10+
#[lang = "owned_box"]
11+
pub struct Box<T: ?Sized>(Unique<T>);
12+
13+
impl<T: ?Sized> Drop for Box<T> {
14+
fn drop(&mut self) {}
15+
}
16+
17+
#[lang = "box_free"]
18+
#[inline(always)]
19+
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>) {
20+
dealloc(ptr.0.0)
21+
}
22+
23+
#[inline(never)]
24+
fn dealloc<T: ?Sized>(_: *mut T) {}
25+
26+
pub struct Foo<T>(T);
27+
28+
pub fn foo(a: Option<Box<Foo<usize>>>) -> usize {
29+
let f = match a {
30+
None => Foo(0),
31+
Some(vec) => *vec,
32+
};
33+
f.0
34+
}

ices/102047.rs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
struct Ty1;
2+
struct Ty2;
3+
4+
pub trait Trait<T> {}
5+
6+
pub trait WithAssoc1<'a> {
7+
type Assoc;
8+
}
9+
pub trait WithAssoc2<'a> {
10+
type Assoc;
11+
}
12+
13+
impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U)
14+
where
15+
T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>,
16+
U: for<'a> WithAssoc2<'a>,
17+
{
18+
}
19+
20+
impl WithAssoc1<'_> for Ty1 {
21+
type Assoc = ();
22+
}
23+
impl WithAssoc2<'_> for Ty1 {
24+
type Assoc = i32;
25+
}
26+
impl WithAssoc1<'_> for Ty2 {
27+
type Assoc = ();
28+
}
29+
impl WithAssoc2<'_> for Ty2 {
30+
type Assoc = u32;
31+
}
32+
33+
fn foo<T, U, V>()
34+
where
35+
T: for<'a> WithAssoc1<'a>,
36+
U: for<'a> WithAssoc2<'a>,
37+
(T, U): Trait<V>,
38+
{
39+
}
40+
41+
fn main() {
42+
foo::<Ty1, Ty2, _>();
43+
}

ices/102089.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// crash with edition=2021
2+
pub struct Example<'a, T> {
3+
a: T,
4+
b: &'a T,
5+
}
6+
7+
impl<'a, T> Example<'a, T> {
8+
pub fn error_trying_to_destructure_self_in_closure(self) {
9+
let closure = || {
10+
let Self { a, b } = self;
11+
};
12+
}
13+
}
14+
15+
pub fn main() {}

ices/102105.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![crate_type = "lib"]
2+
#![feature(rustc_attrs)]
3+
4+
#[rustc_allocator]
5+
pub fn allocator() -> *const i8 {
6+
std::ptr::null()
7+
}

ices/102114-1.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait A{type B<'b>;}
2+
struct C;
3+
impl A for C {
4+
type B<b> =impl;
5+
fn a() -> Self::B<'a>;
6+
}

ices/102114-2.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait A {
2+
type B<'b>;
3+
fn a() -> Self::B<'static>;
4+
}
5+
6+
struct C;
7+
8+
struct Wrapper<T>(T);
9+
10+
impl A for C {
11+
type B<T> = Wrapper<T>;
12+
fn a() -> Self::B<'static> {}
13+
}

ices/102117.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![crate_type = "lib"]
2+
#![feature(inline_const, const_type_id)]
3+
4+
use std::alloc::Layout;
5+
use std::any::TypeId;
6+
use std::mem::transmute;
7+
use std::ptr::drop_in_place;
8+
9+
pub struct VTable {
10+
layout: Layout,
11+
type_id: TypeId,
12+
drop_in_place: unsafe fn(*mut ()),
13+
}
14+
15+
impl VTable {
16+
pub fn new<T>() -> &'static Self {
17+
const {
18+
&VTable {
19+
layout: Layout::new::<T>(),
20+
type_id: TypeId::of::<T>(),
21+
drop_in_place: unsafe {
22+
transmute::<unsafe fn(*mut T), unsafe fn(*mut ())>(drop_in_place::<T>)
23+
},
24+
}
25+
}
26+
}
27+
}

ices/102124.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
rustc -Zmir-opt-level=3 - <<'EOF'
4+
5+
const L: usize = 4;
6+
7+
pub trait Print<const N: usize> {
8+
fn print(&self) -> usize {
9+
N
10+
}
11+
}
12+
13+
pub struct Printer;
14+
impl Print<L> for Printer {}
15+
16+
fn main() {
17+
let p = Printer;
18+
assert_eq!(p.print(), 4);
19+
}
20+
21+
EOF
22+

ices/102140.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(return_position_impl_trait_in_trait)]
2+
3+
trait Marker {}
4+
impl Marker for u32 {}
5+
6+
trait MyTrait {
7+
fn foo(&self) -> impl Marker
8+
where Self: Sized;
9+
}
10+
11+
struct Outer;
12+
13+
impl MyTrait for Outer {
14+
fn foo(&self) -> impl Marker {
15+
42
16+
}
17+
}
18+
19+
impl dyn MyTrait {
20+
fn other(&self) -> impl Marker {
21+
MyTrait::foo(&self)
22+
}
23+
}

ices/102154.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
cat > out.rs <<'EOF'
4+
5+
trait A<Y, N> {
6+
type B;
7+
}
8+
type MaybeBox<T> = <T as A<T, Box<T>>>::B;
9+
struct P {
10+
t: MaybeBox<P>
11+
}
12+
impl<Y, N> A<Y, N> for P {
13+
type B = N;
14+
}
15+
fn main() {
16+
let t: MaybeBox<P>;
17+
}
18+
19+
EOF
20+
21+
rustdoc --edition=2021 out.rs

ices/102156.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(allocator_api)]
2+
3+
#![feature(const_trait_impl)]
4+
use core::convert::{From, TryFrom};
5+
use std::pin::Pin;
6+
use std::alloc::Allocator;
7+
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
8+
where
9+
A: 'static,
10+
{}
11+
12+
pub fn main() {}

ices/102172.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(dyn_star)]
2+
#![allow(incomplete_features)]
3+
4+
use std::fmt::Debug;
5+
6+
fn main() {
7+
let i = 42 as &dyn* Debug;
8+
}

ices/102173.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(dyn_star)]
2+
#![allow(incomplete_features)]
3+
4+
use std::fmt::Debug;
5+
6+
fn main() {
7+
let i = [1, 2, 3, 4] as dyn* Debug;
8+
9+
dbg!(i);
10+
}

0 commit comments

Comments
 (0)