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

Add some ICEs #1535

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ices/102465.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![feature(lang_items, no_core)]
#![no_std]
#![no_core]

#[lang = "sized"]
pub trait Sized {}

#[lang = "copy"]
trait Copy {}

fn bla(argc: isize) {
match argc {
1 => 1, // removing this arm fixes the ICE
_ => 1,
};
}

fn main() {}
9 changes: 9 additions & 0 deletions ices/105047.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(raw_ref_op)]

const RCZ: *const i32 = &raw const *&0;

const fn f() {
if let RCZ = &raw const *&0 {}
}

fn main() {}
15 changes: 15 additions & 0 deletions ices/105819.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(type_alias_impl_trait)]
// check-pass

fn main() {}

fn upvar() {
#[derive(Copy, Clone)]
struct Foo((u32, u32));

type T = impl Copy;
let foo: T = Foo((1u32, 2u32));
let x = move || {
let Foo((a, b)) = foo;
};
}
27 changes: 27 additions & 0 deletions ices/108580.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#![feature(associated_type_bounds, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

trait Iterator {
type Item;
}

trait IntoIterator {
fn into_iterator(&self) -> impl Iterator<Item: > + '_;
}

struct IntoIterFn<F, I> {
f: F,
_marker: core::marker::PhantomData<I>,
}

impl<F, I> IntoIterator for IntoIterFn<F, I>
where
F: Fn() -> I,
I: Iterator,
{
fn into_iterator(&self) -> impl Iterator<Item: '_> {
(self.f)()
}
}

fn main() {}
10 changes: 10 additions & 0 deletions ices/109239.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![allow(incomplete_features)]
#![feature(return_position_impl_trait_in_trait)]

trait Trait {
type Type;

fn method(&self) -> impl Trait<Type = impl Trait<Type = impl Sized + '_> + '_>;
}

fn main() {}
9 changes: 9 additions & 0 deletions ices/109281.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(type_alias_impl_trait)]
struct S;
type ReturnType<'a> = impl Eq + 'a;
impl std::ops::Deref for S {
type Target = dyn Fn(&()) -> ReturnType;
fn deref() -> &'static Self::Target {}
}

fn main() {}
8 changes: 8 additions & 0 deletions ices/109298.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn arr_by_ref(mut x: [(); 3]) {
let f = || {
let [ref y, ref mut z @ ..] = x;
};
f();
}

fn main() {}
14 changes: 14 additions & 0 deletions ices/109299.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trait Document {
fn cursor(&self) -> Lexer::Cursor<'_>;
}

struct Lexer<'d> {
cursor: (),
_phantom: std::marker::PhantomData<&'d ()>,
}

impl<'cursor> Lexer<'d> {
type Cursor<'a> = DocCursorImpl<'a>;
}

fn main() {}
8 changes: 8 additions & 0 deletions ices/109300.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(generic_const_exprs)]
trait B {
type U<T: A>;
}

fn f<T: B<U<1i32> = ()>>() {}

fn main() {}
40 changes: 40 additions & 0 deletions ices/109304.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#![recursion_limit = "10"]
macro_rules! link {
($outer:ident, $inner:ident) => {
struct $outer($inner);
impl $outer {
fn new() -> $outer {
$outer($inner::new())
}
}
impl std::ops::Deref for $outer {
type Target = $inner;
fn deref(&self) -> &$inner {
&self.0
}
}
};
}

struct Bottom;

impl Bottom {
fn new() -> Bottom {
Bottom
}
}

link!(Top, A);
link!(A, B);
link!(B, C);
link!(C, D);
link!(D, E);
link!(E, F);
link!(F, G);
link!(G, H);
link!(H, I);
link!(I, J);
link!(J, K);
link!(K, Bottom);

fn main() {}
24 changes: 24 additions & 0 deletions ices/95134.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
if n > 15 {
encode_num(n / 16, &mut writer)?;
}
Ok(())
}

pub trait ExampleWriter {
type Error;
}

impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
type Error = T::Error;
}

struct EmptyWriter;

impl ExampleWriter for EmptyWriter {
type Error = ();
}

fn main() {
encode_num(69, &mut EmptyWriter).unwrap();
}
46 changes: 46 additions & 0 deletions ices/98010.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#![no_std]
#![no_core]
#![no_main]
#![feature(no_core, lang_items)]

#[lang = "sized"]
trait Sized {}
#[lang = "sync"]
trait Sync {}
#[lang = "copy"]
trait Copy {}
#[lang = "freeze"]
trait Freeze {}

impl Sync for u32 {}
impl Sync for i32 {}

// impl Copy for u32 {} // if remove, it cause rustc crash

#[lang = "drop_in_place"]
#[allow(unconditional_recursion)]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
unsafe { drop_in_place(to_drop) }
}

#[link(name = "Kernel32")]
extern "system" {
pub fn ExitProcess(uexitcode: u32) -> !;
}

fn exit_process(exit_code: u32) -> ! {
// Copying is necessary to pass the value through the function argument, and if this is avoided, there will be no error either.
unsafe {
ExitProcess(exit_code);
}
}

#[no_mangle]
pub extern "C" fn wWinMainCRTStartup() -> i32 {
exit_process(0);
}

#[no_mangle]
pub static _fltused: i32 = 1;

fn main() {}