From dc11b43091d1622f3086d9f60d0c5cf3e8a00cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 8 Sep 2022 22:45:10 +0200 Subject: [PATCH] add 3/4 ices https://github.com/rust-lang/rust/issues/101465 https://github.com/rust-lang/rust/issues/101518 https://github.com/rust-lang/rust/issues/101557 --- ices/101465.rs | 20 ++++++++++++++++++++ ices/101518-1.sh | 31 +++++++++++++++++++++++++++++++ ices/101518-2.sh | 24 ++++++++++++++++++++++++ ices/101557.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 ices/101465.rs create mode 100644 ices/101518-1.sh create mode 100644 ices/101518-2.sh create mode 100644 ices/101557.rs diff --git a/ices/101465.rs b/ices/101465.rs new file mode 100644 index 00000000..37adcf99 --- /dev/null +++ b/ices/101465.rs @@ -0,0 +1,20 @@ +#![feature(trait_alias)] + +struct B; + +struct C; + +trait Tr2 = Into; + +fn foo2>() {} + +fn foo() -> impl Sized { + let x = foo2::<_>(); + + match true { + true => B, + false => C, + } +} + +pub fn main() {} diff --git a/ices/101518-1.sh b/ices/101518-1.sh new file mode 100644 index 00000000..f0e1474a --- /dev/null +++ b/ices/101518-1.sh @@ -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 diff --git a/ices/101518-2.sh b/ices/101518-2.sh new file mode 100644 index 00000000..1c2e5893 --- /dev/null +++ b/ices/101518-2.sh @@ -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 diff --git a/ices/101557.rs b/ices/101557.rs new file mode 100644 index 00000000..772ad48d --- /dev/null +++ b/ices/101557.rs @@ -0,0 +1,40 @@ +#![feature(generic_const_exprs)] +use std::marker::PhantomData; + +trait Trait { + const CONST: usize; +} + +struct A { + _marker: PhantomData, +} + +impl Trait for [i8; N] { + const CONST: usize = N; +} + +impl From for A<[i8; N]> { + fn from(_: usize) -> Self { + todo!() + } +} + +impl From> for A { + fn from(_: A<[i8; T::CONST]>) -> Self { + todo!() + } +} + +fn f() -> A +where + [(); T::CONST]:, +{ + // Usage of `0` is arbitrary + let a = A::<[i8; T::CONST]>::from(0); + A::::from(a) +} + +fn main() { + // Usage of `1` is arbitrary + f::<[i8; 1]>(); +}