From 5c98aaa21282fcfbe5bb7a3ee2d5f5c363d18a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 23 Sep 2022 18:17:06 +0200 Subject: [PATCH] add 12/13 ices https://github.com/rust-lang/rust/issues/101964 https://github.com/rust-lang/rust/issues/102047 https://github.com/rust-lang/rust/issues/102089 https://github.com/rust-lang/rust/issues/102105 https://github.com/rust-lang/rust/issues/102114 https://github.com/rust-lang/rust/issues/102117 https://github.com/rust-lang/rust/issues/102124 https://github.com/rust-lang/rust/issues/102140 https://github.com/rust-lang/rust/issues/102154 https://github.com/rust-lang/rust/issues/102156 https://github.com/rust-lang/rust/issues/102172 https://github.com/rust-lang/rust/issues/102173 --- ices/101964.rs | 34 ++++++++++++++++++++++++++++++++++ ices/102047.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ ices/102089.rs | 15 +++++++++++++++ ices/102105.rs | 7 +++++++ ices/102114-1.rs | 6 ++++++ ices/102114-2.rs | 13 +++++++++++++ ices/102117.rs | 27 +++++++++++++++++++++++++++ ices/102124.sh | 22 ++++++++++++++++++++++ ices/102140.rs | 23 +++++++++++++++++++++++ ices/102154.sh | 21 +++++++++++++++++++++ ices/102156.rs | 12 ++++++++++++ ices/102172.rs | 8 ++++++++ ices/102173.rs | 10 ++++++++++ 13 files changed, 241 insertions(+) create mode 100644 ices/101964.rs create mode 100644 ices/102047.rs create mode 100644 ices/102089.rs create mode 100644 ices/102105.rs create mode 100644 ices/102114-1.rs create mode 100644 ices/102114-2.rs create mode 100644 ices/102117.rs create mode 100755 ices/102124.sh create mode 100644 ices/102140.rs create mode 100755 ices/102154.sh create mode 100644 ices/102156.rs create mode 100644 ices/102172.rs create mode 100644 ices/102173.rs diff --git a/ices/101964.rs b/ices/101964.rs new file mode 100644 index 00000000..7805e716 --- /dev/null +++ b/ices/101964.rs @@ -0,0 +1,34 @@ + +#![crate_type = "lib"] +#![feature(lang_items)] +#![no_std] + +struct NonNull(*mut T); + +struct Unique(NonNull); + +#[lang = "owned_box"] +pub struct Box(Unique); + +impl Drop for Box { + fn drop(&mut self) {} +} + +#[lang = "box_free"] +#[inline(always)] +unsafe fn box_free(ptr: Unique) { + dealloc(ptr.0.0) +} + +#[inline(never)] +fn dealloc(_: *mut T) {} + +pub struct Foo(T); + +pub fn foo(a: Option>>) -> usize { + let f = match a { + None => Foo(0), + Some(vec) => *vec, + }; + f.0 +} diff --git a/ices/102047.rs b/ices/102047.rs new file mode 100644 index 00000000..81e571a9 --- /dev/null +++ b/ices/102047.rs @@ -0,0 +1,43 @@ +struct Ty1; +struct Ty2; + +pub trait Trait {} + +pub trait WithAssoc1<'a> { + type Assoc; +} +pub trait WithAssoc2<'a> { + type Assoc; +} + +impl Trait fn(>::Assoc, >::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() +where + T: for<'a> WithAssoc1<'a>, + U: for<'a> WithAssoc2<'a>, + (T, U): Trait, +{ +} + +fn main() { + foo::(); +} diff --git a/ices/102089.rs b/ices/102089.rs new file mode 100644 index 00000000..1e4abbf5 --- /dev/null +++ b/ices/102089.rs @@ -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() {} diff --git a/ices/102105.rs b/ices/102105.rs new file mode 100644 index 00000000..d5e6712b --- /dev/null +++ b/ices/102105.rs @@ -0,0 +1,7 @@ +#![crate_type = "lib"] +#![feature(rustc_attrs)] + +#[rustc_allocator] +pub fn allocator() -> *const i8 { + std::ptr::null() +} diff --git a/ices/102114-1.rs b/ices/102114-1.rs new file mode 100644 index 00000000..65f8236e --- /dev/null +++ b/ices/102114-1.rs @@ -0,0 +1,6 @@ +trait A{type B<'b>;} +struct C; +impl A for C { + type B =impl; + fn a() -> Self::B<'a>; +} diff --git a/ices/102114-2.rs b/ices/102114-2.rs new file mode 100644 index 00000000..1e6d43b4 --- /dev/null +++ b/ices/102114-2.rs @@ -0,0 +1,13 @@ +trait A { + type B<'b>; + fn a() -> Self::B<'static>; +} + +struct C; + +struct Wrapper(T); + +impl A for C { + type B = Wrapper; + fn a() -> Self::B<'static> {} +} diff --git a/ices/102117.rs b/ices/102117.rs new file mode 100644 index 00000000..0cde30cb --- /dev/null +++ b/ices/102117.rs @@ -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() -> &'static Self { + const { + &VTable { + layout: Layout::new::(), + type_id: TypeId::of::(), + drop_in_place: unsafe { + transmute::(drop_in_place::) + }, + } + } + } +} diff --git a/ices/102124.sh b/ices/102124.sh new file mode 100755 index 00000000..ea7afd9e --- /dev/null +++ b/ices/102124.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +rustc -Zmir-opt-level=3 - <<'EOF' + +const L: usize = 4; + +pub trait Print { + fn print(&self) -> usize { + N + } +} + +pub struct Printer; +impl Print for Printer {} + +fn main() { + let p = Printer; + assert_eq!(p.print(), 4); +} + +EOF + diff --git a/ices/102140.rs b/ices/102140.rs new file mode 100644 index 00000000..243b61b9 --- /dev/null +++ b/ices/102140.rs @@ -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) + } +} diff --git a/ices/102154.sh b/ices/102154.sh new file mode 100755 index 00000000..0a9c84fd --- /dev/null +++ b/ices/102154.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +cat > out.rs <<'EOF' + +trait A { + type B; +} +type MaybeBox = >>::B; +struct P { + t: MaybeBox

+} +impl A for P { + type B = N; +} +fn main() { + let t: MaybeBox

; +} + +EOF + +rustdoc --edition=2021 out.rs diff --git a/ices/102156.rs b/ices/102156.rs new file mode 100644 index 00000000..bd675944 --- /dev/null +++ b/ices/102156.rs @@ -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 const From> for Pin> +where + A: 'static, +{} + +pub fn main() {} diff --git a/ices/102172.rs b/ices/102172.rs new file mode 100644 index 00000000..e1366b4f --- /dev/null +++ b/ices/102172.rs @@ -0,0 +1,8 @@ +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +fn main() { + let i = 42 as &dyn* Debug; +} diff --git a/ices/102173.rs b/ices/102173.rs new file mode 100644 index 00000000..4b54c43a --- /dev/null +++ b/ices/102173.rs @@ -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); +}