]> git.lizzy.rs Git - rust.git/commitdiff
Address review comments
authorAaron Hill <aa1ronham@gmail.com>
Fri, 5 Jul 2019 23:10:29 +0000 (19:10 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sun, 7 Jul 2019 21:22:07 +0000 (17:22 -0400)
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_typeck/check/writeback.rs
src/test/run-pass/existential_type_const.rs [deleted file]
src/test/run-pass/existential_type_const.stderr [deleted file]
src/test/run-pass/existential_type_fns.rs [deleted file]
src/test/run-pass/existential_type_tuple.rs [deleted file]
src/test/ui/existential_types/existential_type_const.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type_const.stderr [new file with mode: 0644]
src/test/ui/existential_types/existential_type_fns.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type_tuple.rs [new file with mode: 0644]

index a505750b1a12d0ab856de6119abad409c1f8aabe..1194872c0afd484d3c8449888fcd4873704475cb 100644 (file)
@@ -1280,14 +1280,14 @@ fn eq_opaque_type_and_type(
                             concrete_is_opaque
                         );
 
-                        // concrete_is_opaque is 'true' when we're using an existential
-                        // type without 'revelaing' it. For example, code like this:
+                        // concrete_is_opaque is `true` when we're using an existential
+                        // type without 'revealing' it. For example, code like this:
                         //
                         // existential type Foo: Debug;
                         // fn foo1() -> Foo { ... }
                         // fn foo2() -> Foo { foo1() }
                         //
-                        // In 'foo2', we're not revealing the type of 'Foo' - we're
+                        // In `foo2`, we're not revealing the type of `Foo` - we're
                         // just treating it as the opaque type.
                         //
                         // When this occurs, we do *not* want to try to equate
index 14bd2f0fa7eb912cfe970b9f7d23ca3d2faaf1e5..831f9daa52d91f966e443560b2aa9300ec0f8edb 100644 (file)
@@ -587,6 +587,11 @@ fn visit_opaque_types(&mut self, span: Span) {
             }
 
             if !opaque_defn.substs.has_local_value() {
+                // We only want to add an entry into `concrete_existential_types`
+                // if we actually found a defining usage of this existential type.
+                // Otherwise, we do nothing - we'll either find a defining usage
+                // in some other location, or we'll end up emitting an error due
+                // to the lack of defining usage
                 if !skip_add {
                     let new = ty::ResolvedOpaqueTy {
                         concrete_type: definition_ty,
diff --git a/src/test/run-pass/existential_type_const.rs b/src/test/run-pass/existential_type_const.rs
deleted file mode 100644 (file)
index 1f80475..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#![feature(existential_type)]
-#![feature(impl_trait_in_bindings)]
-//~^ WARN the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
-
-// Ensures that `const` items can constrain an `existential type`.
-
-use std::fmt::Debug;
-
-pub existential type Foo: Debug;
-
-const _FOO: Foo = 5;
-
-fn main() {
-}
diff --git a/src/test/run-pass/existential_type_const.stderr b/src/test/run-pass/existential_type_const.stderr
deleted file mode 100644 (file)
index b6d83fb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
-  --> $DIR/existential_type_const.rs:2:12
-   |
-LL | #![feature(impl_trait_in_bindings)]
-   |            ^^^^^^^^^^^^^^^^^^^^^^
-
diff --git a/src/test/run-pass/existential_type_fns.rs b/src/test/run-pass/existential_type_fns.rs
deleted file mode 100644 (file)
index e477dca..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#![feature(existential_type)]
-
-// Regression test for issue #61863
-
-pub trait MyTrait {}
-
-#[derive(Debug)]
-pub struct MyStruct {
-  v: u64
-}
-
-impl MyTrait for MyStruct {}
-
-pub fn bla() -> TE {
-    return MyStruct {v:1}
-}
-
-pub fn bla2() -> TE {
-    bla()
-}
-
-
-existential type TE: MyTrait;
-
-fn main() {}
diff --git a/src/test/run-pass/existential_type_tuple.rs b/src/test/run-pass/existential_type_tuple.rs
deleted file mode 100644 (file)
index 31c145e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#![feature(existential_type)]
-
-#![allow(dead_code)]
-
-pub trait MyTrait {}
-
-impl MyTrait for bool {}
-
-struct Blah {
-    my_foo: Foo,
-    my_u8: u8
-}
-
-impl Blah {
-    fn new() -> Blah {
-        Blah {
-            my_foo: make_foo(),
-            my_u8: 12
-        }
-    }
-    fn into_inner(self) -> (Foo, u8) {
-        (self.my_foo, self.my_u8)
-    }
-}
-
-fn make_foo() -> Foo {
-    true
-}
-
-existential type Foo: MyTrait;
-
-fn main() {}
diff --git a/src/test/ui/existential_types/existential_type_const.rs b/src/test/ui/existential_types/existential_type_const.rs
new file mode 100644 (file)
index 0000000..55920b8
--- /dev/null
@@ -0,0 +1,16 @@
+// check-pass
+
+#![feature(existential_type)]
+#![feature(impl_trait_in_bindings)]
+//~^ WARN the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
+
+// Ensures that `const` items can constrain an `existential type`.
+
+use std::fmt::Debug;
+
+pub existential type Foo: Debug;
+
+const _FOO: Foo = 5;
+
+fn main() {
+}
diff --git a/src/test/ui/existential_types/existential_type_const.stderr b/src/test/ui/existential_types/existential_type_const.stderr
new file mode 100644 (file)
index 0000000..b6d83fb
--- /dev/null
@@ -0,0 +1,6 @@
+warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
+  --> $DIR/existential_type_const.rs:2:12
+   |
+LL | #![feature(impl_trait_in_bindings)]
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/src/test/ui/existential_types/existential_type_fns.rs b/src/test/ui/existential_types/existential_type_fns.rs
new file mode 100644 (file)
index 0000000..6f22eef
--- /dev/null
@@ -0,0 +1,27 @@
+// check-pass
+
+#![feature(existential_type)]
+
+// Regression test for issue #61863
+
+pub trait MyTrait {}
+
+#[derive(Debug)]
+pub struct MyStruct {
+  v: u64
+}
+
+impl MyTrait for MyStruct {}
+
+pub fn bla() -> TE {
+    return MyStruct {v:1}
+}
+
+pub fn bla2() -> TE {
+    bla()
+}
+
+
+existential type TE: MyTrait;
+
+fn main() {}
diff --git a/src/test/ui/existential_types/existential_type_tuple.rs b/src/test/ui/existential_types/existential_type_tuple.rs
new file mode 100644 (file)
index 0000000..0f134a5
--- /dev/null
@@ -0,0 +1,33 @@
+// check-pass
+
+#![feature(existential_type)]
+#![allow(dead_code)]
+
+pub trait MyTrait {}
+
+impl MyTrait for bool {}
+
+struct Blah {
+    my_foo: Foo,
+    my_u8: u8
+}
+
+impl Blah {
+    fn new() -> Blah {
+        Blah {
+            my_foo: make_foo(),
+            my_u8: 12
+        }
+    }
+    fn into_inner(self) -> (Foo, u8) {
+        (self.my_foo, self.my_u8)
+    }
+}
+
+fn make_foo() -> Foo {
+    true
+}
+
+existential type Foo: MyTrait;
+
+fn main() {}