From 406049df4948a2c93d50f2c72cfa0e2811695ef5 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 15 Jan 2020 08:34:20 +0900 Subject: [PATCH 1/4] Add test for issue-64848 --- src/test/ui/associated-types/issue-64848.rs | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/ui/associated-types/issue-64848.rs diff --git a/src/test/ui/associated-types/issue-64848.rs b/src/test/ui/associated-types/issue-64848.rs new file mode 100644 index 0000000000000..77712168a0fd9 --- /dev/null +++ b/src/test/ui/associated-types/issue-64848.rs @@ -0,0 +1,29 @@ +// build-pass + +trait AssociatedConstant { + const DATA: (); +} + +impl AssociatedConstant for F +where + F: FnOnce() -> T, + T: AssociatedConstant, +{ + const DATA: () = T::DATA; +} + +impl AssociatedConstant for () { + const DATA: () = (); +} + +fn foo() -> impl AssociatedConstant { + () +} + +fn get_data(_: T) -> &'static () { + &T::DATA +} + +fn main() { + get_data(foo); +} From ce8fed65f5e6f75b91cff35aec21190714231091 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 15 Jan 2020 08:34:33 +0900 Subject: [PATCH 2/4] Add test for issue-65918 --- .../ui/type-alias-impl-trait/issue-65918.rs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/test/ui/type-alias-impl-trait/issue-65918.rs diff --git a/src/test/ui/type-alias-impl-trait/issue-65918.rs b/src/test/ui/type-alias-impl-trait/issue-65918.rs new file mode 100644 index 0000000000000..97efb85ef64c7 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-65918.rs @@ -0,0 +1,49 @@ +// build-pass + +#![feature(type_alias_impl_trait)] + +use std::marker::PhantomData; + +/* copied Index and TryFrom for convinience (and simplicity) */ +trait MyIndex { + type O; + fn my_index(self) -> Self::O; +} +trait MyFrom: Sized { + type Error; + fn my_from(value: T) -> Result; +} + +/* MCVE starts here */ +trait F {} +impl F for () {} +type DummyT = impl F; +fn _dummy_t() -> DummyT {} + +struct Phantom1(PhantomData); +struct Phantom2(PhantomData); +struct Scope(Phantom2>); + +impl Scope { + fn new() -> Self { + unimplemented!() + } +} + +impl MyFrom> for Phantom1 { + type Error = (); + fn my_from(_: Phantom2) -> Result { + unimplemented!() + } +} + +impl>>, U> MyIndex> for Scope { + type O = T; + fn my_index(self) -> Self::O { + MyFrom::my_from(self.0).ok().unwrap() + } +} + +fn main() { + let _pos: Phantom1> = Scope::new().my_index(); +} From 27a810c719a1b9b245bb0b95e5774e3d092f7e6f Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 15 Jan 2020 08:34:51 +0900 Subject: [PATCH 3/4] Add test for issue-66473 --- src/test/ui/issues/issue-66473.rs | Bin 0 -> 113 bytes src/test/ui/issues/issue-66473.stderr | Bin 0 -> 2632 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/test/ui/issues/issue-66473.rs create mode 100644 src/test/ui/issues/issue-66473.stderr diff --git a/src/test/ui/issues/issue-66473.rs b/src/test/ui/issues/issue-66473.rs new file mode 100644 index 0000000000000000000000000000000000000000..cc298a28b97e5bc6e683fe5faee36d95d64720bf GIT binary patch literal 113 zcmdPbS4b@?$}iF_NGvHyEy}Y}D9y{x%P-GUC@x7XDpAN!Qz*&LPR--e$55DBQIMKk klA5BB5S^f-kd|MX2V|NhaB(T0?O?zFT->r|vJ4Dd0C6%O9{>OV literal 0 HcmV?d00001 diff --git a/src/test/ui/issues/issue-66473.stderr b/src/test/ui/issues/issue-66473.stderr new file mode 100644 index 0000000000000000000000000000000000000000..dbeef44bad0ec68b68ce3c3c06768df43587855c GIT binary patch literal 2632 zcmchZPfNov7>9d~pJDKV9_`%QrrFG4CojTIUX{_!W>N;p$R8D)cfXw9$xvZLWL*#A z&8d*`dqUuS@>A9tDc4fQLW2 g_IIdjtF^Jd)i2Nl6^kJh9ClW{wk9~}8l7Y82jcILL;wH) literal 0 HcmV?d00001 From 3ba15bda53272a73ee04b3d592ffb14d6ee177cb Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 15 Jan 2020 08:35:44 +0900 Subject: [PATCH 4/4] Set mir-opt-level to 3 to prevent regressions --- src/test/mir-opt/inline/inline-into-box-place.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/mir-opt/inline/inline-into-box-place.rs b/src/test/mir-opt/inline/inline-into-box-place.rs index 0bb9dfa403d58..f368bdef6f8e2 100644 --- a/src/test/mir-opt/inline/inline-into-box-place.rs +++ b/src/test/mir-opt/inline/inline-into-box-place.rs @@ -1,5 +1,6 @@ // ignore-tidy-linelength // ignore-wasm32-bare compiled with panic=abort by default +// compile-flags: -Z mir-opt-level=3 #![feature(box_syntax)] fn main() {