]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #68236 - JohnTitor:ice-tests, r=Centril
authorDylan DPC <dylan.dpc@gmail.com>
Wed, 15 Jan 2020 17:19:28 +0000 (22:49 +0530)
committerGitHub <noreply@github.com>
Wed, 15 Jan 2020 17:19:28 +0000 (22:49 +0530)
Add some regression tests

Closes #64848 (fixed by #67631)
Closes #65918 (ICE is hidden by #67000, no longer ICE)
Closes #66473 (fixed by #68084)
Closes #67550 (set mir-opt-level to 3)

r? @Centril

src/test/mir-opt/inline/inline-into-box-place.rs
src/test/ui/associated-types/issue-64848.rs [new file with mode: 0644]
src/test/ui/issues/issue-66473.rs [new file with mode: 0644]
src/test/ui/issues/issue-66473.stderr [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-65918.rs [new file with mode: 0644]

index 0bb9dfa403d582285b6da6ad20857e619993fe99..f368bdef6f8e2d85d0fb28b6e1db639a4de3b834 100644 (file)
@@ -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() {
diff --git a/src/test/ui/associated-types/issue-64848.rs b/src/test/ui/associated-types/issue-64848.rs
new file mode 100644 (file)
index 0000000..7771216
--- /dev/null
@@ -0,0 +1,29 @@
+// build-pass
+
+trait AssociatedConstant {
+    const DATA: ();
+}
+
+impl<F, T> 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: AssociatedConstant>(_: T) -> &'static () {
+    &T::DATA
+}
+
+fn main() {
+    get_data(foo);
+}
diff --git a/src/test/ui/issues/issue-66473.rs b/src/test/ui/issues/issue-66473.rs
new file mode 100644 (file)
index 0000000..cc298a2
Binary files /dev/null and b/src/test/ui/issues/issue-66473.rs differ
diff --git a/src/test/ui/issues/issue-66473.stderr b/src/test/ui/issues/issue-66473.stderr
new file mode 100644 (file)
index 0000000..dbeef44
Binary files /dev/null and b/src/test/ui/issues/issue-66473.stderr differ
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 (file)
index 0000000..97efb85
--- /dev/null
@@ -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<T> {
+    type O;
+    fn my_index(self) -> Self::O;
+}
+trait MyFrom<T>: Sized {
+    type Error;
+    fn my_from(value: T) -> Result<Self, Self::Error>;
+}
+
+/* MCVE starts here */
+trait F {}
+impl F for () {}
+type DummyT<T> = impl F;
+fn _dummy_t<T>() -> DummyT<T> {}
+
+struct Phantom1<T>(PhantomData<T>);
+struct Phantom2<T>(PhantomData<T>);
+struct Scope<T>(Phantom2<DummyT<T>>);
+
+impl<T> Scope<T> {
+    fn new() -> Self {
+        unimplemented!()
+    }
+}
+
+impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
+    type Error = ();
+    fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
+        unimplemented!()
+    }
+}
+
+impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
+    type O = T;
+    fn my_index(self) -> Self::O {
+        MyFrom::my_from(self.0).ok().unwrap()
+    }
+}
+
+fn main() {
+    let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
+}