From 55471f89152d20f81b4077311272cc33f16202c0 Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 16:32:02 +0100 Subject: [PATCH 1/8] Added #67945. Centril asked in the issue to include all variants in a regression test. --- ices/67945-1.rs | 12 ++++++++++++ ices/67945-2.rs | 7 +++++++ ices/67945-3.rs | 9 +++++++++ ices/67945-4.rs | 11 +++++++++++ 4 files changed, 39 insertions(+) create mode 100644 ices/67945-1.rs create mode 100644 ices/67945-2.rs create mode 100644 ices/67945-3.rs create mode 100644 ices/67945-4.rs diff --git a/ices/67945-1.rs b/ices/67945-1.rs new file mode 100644 index 00000000..d915a204 --- /dev/null +++ b/ices/67945-1.rs @@ -0,0 +1,12 @@ +// original reproducer by DutchGhost +use std::marker::PhantomData; + +use std::mem::{self, MaybeUninit}; + +struct Bug { + A: [(); { + let x: S = MaybeUninit::uninit(); + let b = &*(&x as *const _ as *const S); + 0 + }], +} diff --git a/ices/67945-2.rs b/ices/67945-2.rs new file mode 100644 index 00000000..6fc544ca --- /dev/null +++ b/ices/67945-2.rs @@ -0,0 +1,7 @@ +// reduced version by Centril +enum Bug { + Var = { + let x: S = 0; + 0 + }, +} \ No newline at end of file diff --git a/ices/67945-3.rs b/ices/67945-3.rs new file mode 100644 index 00000000..713b3781 --- /dev/null +++ b/ices/67945-3.rs @@ -0,0 +1,9 @@ +// Note: Centril asked in the issue to +// include all variants in a regression test. + +// even more reduced version by Centril +#![feature(type_ascription)] + +enum Bug { + Var = 0: S, +} diff --git a/ices/67945-4.rs b/ices/67945-4.rs new file mode 100644 index 00000000..14003dc2 --- /dev/null +++ b/ices/67945-4.rs @@ -0,0 +1,11 @@ +// reproducer by nikomatsakis +use std::marker::PhantomData; + +use std::mem::{self, MaybeUninit}; + +struct Bug { + A: [(); { + let x: Option> = None; + 0 + }], +} From bd6dfd14f40987e9e99eb50ad0c29e36712aa91a Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 16:38:41 +0100 Subject: [PATCH 2/8] Added #67981 --- ices/67981.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ices/67981.rs diff --git a/ices/67981.rs b/ices/67981.rs new file mode 100644 index 00000000..4bdeeb4e --- /dev/null +++ b/ices/67981.rs @@ -0,0 +1,9 @@ +#![feature(unsized_locals)] + +fn main() { + let f: fn([u8]) = |_| {}; + + let slice: Box<[u8]> = Box::new([1; 8]); + + f(*slice); +} \ No newline at end of file From a34e75b3c0798d59d74c1fa2b49f2589f1cc8508 Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 16:51:21 +0100 Subject: [PATCH 3/8] Added #68013. The imports are also needed, otherwise the reproducer just emits an error. --- ices/68013.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ices/68013.rs diff --git a/ices/68013.rs b/ices/68013.rs new file mode 100644 index 00000000..113e717c --- /dev/null +++ b/ices/68013.rs @@ -0,0 +1,13 @@ +#![feature(coerce_unsized)] + +use std::rc::Rc; +use std::cell::Cell; +use std::ops::Deref; +use std::ops::CoerceUnsized; + +#[derive(Clone)] +struct Redirectable<'a, T: ?Sized> { + data: Rc> +} + +impl> CoerceUnsized> for Redirectable<'_, T> {} From c7a374243b07059d43560b8724205ea0c91467bf Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 16:56:40 +0100 Subject: [PATCH 4/8] Added link to playground. --- ices/68013.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ices/68013.rs b/ices/68013.rs index 113e717c..e32d5f49 100644 --- a/ices/68013.rs +++ b/ices/68013.rs @@ -1,5 +1,9 @@ +// https://github.com/rust-lang/rust/issues/68013 +// Reduced from [https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0f18f9d5d6071f9a10586e87e5dfd0b0] + #![feature(coerce_unsized)] +// These imports are also needed to get the ICE. use std::rc::Rc; use std::cell::Cell; use std::ops::Deref; From 8b370bd0ef289b1b9bf8dde63412979fe31ad87f Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 17:13:08 +0100 Subject: [PATCH 5/8] Added #44861. It needs `--crate-type lib` as a build flag. --- ices/44861.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 ices/44861.sh diff --git a/ices/44861.sh b/ices/44861.sh new file mode 100644 index 00000000..18102d1e --- /dev/null +++ b/ices/44861.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# https://github.com/rust-lang/rust/issues/44861 +# Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=bdd59503a0dc2d33c60a949fc7c57633 +# You need to select `build` instead of `run`. +rustc --crate-type lib - << END + +#![feature(specialization)] +#![feature(unsize, coerce_unsized)] + +use std::ops::CoerceUnsized; +use std::marker::Unsize; + +pub struct SmartassPtr(A::Data); + +pub trait Smartass { + type Data; + type Data2: CoerceUnsized<*const [u8]>; +} + +pub trait MaybeObjectSafe {} + +impl MaybeObjectSafe for () {} + +impl Smartass for T { + type Data = ::Data2; + default type Data2 = (); +} + +impl Smartass for () { + type Data2 = *const [u8; 1]; +} + +impl Smartass for MaybeObjectSafe { + type Data = *const [u8]; + type Data2 = *const [u8; 0]; +} + +impl CoerceUnsized> for SmartassPtr + where ::Data: std::ops::CoerceUnsized<::Data> +{} + +pub fn conv(s: SmartassPtr<()>) -> SmartassPtr { + s +} + +END From 6ddf588cdd417fe9d28f8d37e3a77d5969e97cf0 Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 17:17:26 +0100 Subject: [PATCH 6/8] Added #68025. --- ices/68025.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 ices/68025.rs diff --git a/ices/68025.rs b/ices/68025.rs new file mode 100644 index 00000000..f0ab8c37 --- /dev/null +++ b/ices/68025.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/68025 +// simplified by Centril +fn foo(_: G, _: Box) + where + F: Fn(), + G: Fn(Box), +{ +} + +fn main() { + foo(|f| (*f)(), Box::new(|| {})); +} \ No newline at end of file From 45907ea57c468ca60c8dc3a373a5c1a156b38b41 Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 17:22:13 +0100 Subject: [PATCH 7/8] Added missing newline at the ends of files. --- ices/67945-2.rs | 2 +- ices/67981.rs | 2 +- ices/68025.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ices/67945-2.rs b/ices/67945-2.rs index 6fc544ca..a4f19c22 100644 --- a/ices/67945-2.rs +++ b/ices/67945-2.rs @@ -4,4 +4,4 @@ enum Bug { let x: S = 0; 0 }, -} \ No newline at end of file +} diff --git a/ices/67981.rs b/ices/67981.rs index 4bdeeb4e..10c2c6b9 100644 --- a/ices/67981.rs +++ b/ices/67981.rs @@ -6,4 +6,4 @@ fn main() { let slice: Box<[u8]> = Box::new([1; 8]); f(*slice); -} \ No newline at end of file +} diff --git a/ices/68025.rs b/ices/68025.rs index f0ab8c37..be2f8835 100644 --- a/ices/68025.rs +++ b/ices/68025.rs @@ -9,4 +9,4 @@ fn foo(_: G, _: Box) fn main() { foo(|f| (*f)(), Box::new(|| {})); -} \ No newline at end of file +} From 8a9670e7bef0dee0d3e4f13b97bd3b81953e5f64 Mon Sep 17 00:00:00 2001 From: Julian Wollersberger <24991778+Julian-Wollersberger@users.noreply.github.com> Date: Wed, 15 Jan 2020 18:22:59 +0100 Subject: [PATCH 8/8] Refactored #44861 to use the `crate_type` attribute. --- ices/{44861.sh => 44861.rs} | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) rename ices/{44861.sh => 44861.rs} (75%) diff --git a/ices/44861.sh b/ices/44861.rs similarity index 75% rename from ices/44861.sh rename to ices/44861.rs index 18102d1e..1325b601 100644 --- a/ices/44861.sh +++ b/ices/44861.rs @@ -1,10 +1,8 @@ -#!/bin/bash - -# https://github.com/rust-lang/rust/issues/44861 -# Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=bdd59503a0dc2d33c60a949fc7c57633 -# You need to select `build` instead of `run`. -rustc --crate-type lib - << END +// https://github.com/rust-lang/rust/issues/44861 +// Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=bdd59503a0dc2d33c60a949fc7c57633 +// You need to select `build` instead of `run`. +#![crate_type = "lib"] #![feature(specialization)] #![feature(unsize, coerce_unsized)] @@ -43,5 +41,3 @@ impl CoerceUnsized> for S pub fn conv(s: SmartassPtr<()>) -> SmartassPtr { s } - -END