forked from rust-lang/glacier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust-lang/rust#101964 rust-lang/rust#102047 rust-lang/rust#102089 rust-lang/rust#102105 rust-lang/rust#102114 rust-lang/rust#102117 rust-lang/rust#102124 rust-lang/rust#102140 rust-lang/rust#102154 rust-lang/rust#102156 rust-lang/rust#102172 rust-lang/rust#102173
- Loading branch information
1 parent
2526894
commit 5c98aaa
Showing
13 changed files
with
241 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,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,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,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,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,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); | ||
} |