]> git.lizzy.rs Git - rust.git/commitdiff
Add tests.
authorLuqman Aden <me@luqman.ca>
Sat, 8 May 2021 08:07:27 +0000 (01:07 -0700)
committerLuqman Aden <me@luqman.ca>
Sat, 8 May 2021 08:07:27 +0000 (01:07 -0700)
src/test/ui/issues/auxiliary/issue-75907.rs
src/test/ui/issues/issue-75907_b.rs
src/test/ui/issues/issue-75907_b.stderr
src/test/ui/rfc-2008-non-exhaustive/struct.stderr

index 0b70452a24d7177777498105eefcc171fe83dafe..389c9c35101ab4367eee05aeda41003eb3487b3d 100644 (file)
@@ -3,3 +3,15 @@
 pub fn make_bar() -> Bar {
     Bar(1, 12, 10)
 }
+
+mod inner {
+    pub struct Foo(u8, pub u8, u8);
+
+    impl Foo {
+        pub fn new() -> Foo {
+            Foo(1, 12, 10)
+        }
+    }
+}
+
+pub use inner::Foo;
index a775845279eb8c5d90ed89d661d398b0b099c561..e30747782339cb4c675e783ba043beeb3f6a78cb 100644 (file)
@@ -3,9 +3,12 @@
 
 extern crate issue_75907 as a;
 
-use a::{make_bar, Bar};
+use a::{make_bar, Bar, Foo};
 
 fn main() {
     let Bar(x, y, z) = make_bar();
     //~^ ERROR cannot match against a tuple struct which contains private fields
+
+    let Foo(x, y, z) = Foo::new();
+    //~^ ERROR cannot match against a tuple struct which contains private fields
 }
index 8884484e18d8152c937004677e64d5f4c39bee56..b82d08473c8c9962a6298c577adf58a916286085 100644 (file)
@@ -2,8 +2,30 @@ error[E0532]: cannot match against a tuple struct which contains private fields
   --> $DIR/issue-75907_b.rs:9:9
    |
 LL |     let Bar(x, y, z) = make_bar();
-   |         ^^^ constructor is not visible here due to private fields
+   |         ^^^
+   |
+note: constructor is not visible here due to private fields
+  --> $DIR/issue-75907_b.rs:9:16
+   |
+LL |     let Bar(x, y, z) = make_bar();
+   |                ^  ^ private field
+   |                |
+   |                private field
+
+error[E0532]: cannot match against a tuple struct which contains private fields
+  --> $DIR/issue-75907_b.rs:12:9
+   |
+LL |     let Foo(x, y, z) = Foo::new();
+   |         ^^^
+   |
+note: constructor is not visible here due to private fields
+  --> $DIR/issue-75907_b.rs:12:13
+   |
+LL |     let Foo(x, y, z) = Foo::new();
+   |             ^     ^ private field
+   |             |
+   |             private field
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0532`.
index e2ee8d6a6fe5e0b35d347f8974bbf5febb5757e2..d023ba3096e68ee0b85998869d2c802304f8a508 100644 (file)
@@ -2,7 +2,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields
   --> $DIR/struct.rs:20:14
    |
 LL |     let ts = TupleStruct(640, 480);
-   |              ^^^^^^^^^^^ constructor is not visible here due to private fields
+   |              ^^^^^^^^^^^
 
 error[E0423]: expected value, found struct `UnitStruct`
   --> $DIR/struct.rs:29:14