Skip to content

Commit

Permalink
add 3/4 ices
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Sep 8, 2022
1 parent 97ab2f6 commit dc11b43
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ices/101465.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![feature(trait_alias)]

struct B;

struct C;

trait Tr2<S> = Into<S>;

fn foo2<T: Tr2<()>>() {}

fn foo() -> impl Sized {
let x = foo2::<_>();

match true {
true => B,
false => C,
}
}

pub fn main() {}
31 changes: 31 additions & 0 deletions ices/101518-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

rustc -Cincremental=/tmp/a -Zincremental-verify-ich=yes --crate-type lib - <<'EOF'
#[derive(PartialEq, Eq)]
struct Id<'a> {
ns: &'a str,
}
fn visit_struct() {
let id = Id { ns: "random1" };
const FLAG: Id<'static> = Id {
ns: "needs_to_be_the_same",
};
match id {
FLAG => {}
_ => {}
}
}
fn visit_struct2() {
let id = Id { ns: "random2" };
const FLAG: Id<'static> = Id {
ns: "needs_to_be_the_same",
};
match id {
FLAG => {}
_ => {}
}
}
EOF
24 changes: 24 additions & 0 deletions ices/101518-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

rustc -Cincremental=/tmp/a -Zincremental-verify-ich=yes --crate-type lib - <<'EOF'
#[derive(Eq, PartialEq)]
struct Id(&'static str);
fn f() {
const FLAG: Id = Id("");
match Id("") {
FLAG => (),
_ => (),
};
}
fn g() {
const FLAG: Id = Id("");
match Id("") {
FLAG => (),
_ => (),
};
}
EOF
40 changes: 40 additions & 0 deletions ices/101557.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#![feature(generic_const_exprs)]
use std::marker::PhantomData;

trait Trait {
const CONST: usize;
}

struct A<T: Trait> {
_marker: PhantomData<T>,
}

impl<const N: usize> Trait for [i8; N] {
const CONST: usize = N;
}

impl<const N: usize> From<usize> for A<[i8; N]> {
fn from(_: usize) -> Self {
todo!()
}
}

impl<T: Trait> From<A<[i8; T::CONST]>> for A<T> {
fn from(_: A<[i8; T::CONST]>) -> Self {
todo!()
}
}

fn f<T: Trait>() -> A<T>
where
[(); T::CONST]:,
{
// Usage of `0` is arbitrary
let a = A::<[i8; T::CONST]>::from(0);
A::<T>::from(a)
}

fn main() {
// Usage of `1` is arbitrary
f::<[i8; 1]>();
}

0 comments on commit dc11b43

Please sign in to comment.