add ui testcase for issue 82772

This commit is contained in:
csmoe 2021-03-05 13:54:35 +08:00
parent 45b3c28518
commit 2fd2796aae
7 changed files with 101 additions and 8 deletions

View file

@ -1,9 +1,11 @@
// aux-build:struct_variant_privacy.rs
extern crate struct_variant_privacy;
fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private
fn f(b: struct_variant_privacy::Bar) {
//~^ ERROR enum `Bar` is private
match b {
struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private
struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR cannot match on
//~^ ERROR enum `Bar` is private
}
}

View file

@ -11,7 +11,7 @@ LL | enum Bar {
| ^^^^^^^^
error[E0603]: enum `Bar` is private
--> $DIR/struct-variant-privacy-xc.rs:6:33
--> $DIR/struct-variant-privacy-xc.rs:7:33
|
LL | struct_variant_privacy::Bar::Baz { a: _a } => {}
| ^^^ private enum
@ -22,6 +22,12 @@ note: the enum `Bar` is defined here
LL | enum Bar {
| ^^^^^^^^
error: aborting due to 2 previous errors
error[E0603]: cannot match on a field named `a` of variant `struct_variant_privacy::Bar::Baz`, which is not accessible in current scope
--> $DIR/struct-variant-privacy-xc.rs:7:44
|
LL | struct_variant_privacy::Bar::Baz { a: _a } => {}
| ^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0603`.

View file

@ -1,12 +1,14 @@
mod foo {
enum Bar {
Baz { a: isize }
Baz { a: isize },
}
}
fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private
fn f(b: foo::Bar) {
//~^ ERROR enum `Bar` is private
match b {
foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private
//~^ ERROR cannot match on
}
}

View file

@ -11,7 +11,7 @@ LL | enum Bar {
| ^^^^^^^^
error[E0603]: enum `Bar` is private
--> $DIR/struct-variant-privacy.rs:9:14
--> $DIR/struct-variant-privacy.rs:10:14
|
LL | foo::Bar::Baz { a: _a } => {}
| ^^^ private enum
@ -22,6 +22,12 @@ note: the enum `Bar` is defined here
LL | enum Bar {
| ^^^^^^^^
error: aborting due to 2 previous errors
error[E0603]: cannot match on a field named `a` of variant `Bar::Baz`, which is not accessible in current scope
--> $DIR/struct-variant-privacy.rs:10:25
|
LL | foo::Bar::Baz { a: _a } => {}
| ^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0603`.

View file

@ -0,0 +1,13 @@
// edition:2018
fn main() {
use a::LocalModPrivateStruct;
let Box { 1: _, .. }: Box<()>; //~ ERROR cannot match on
let LocalModPrivateStruct { 1: _, .. } = LocalModPrivateStruct::default();
//~^ ERROR cannot match on
}
mod a {
#[derive(Default)]
pub struct LocalModPrivateStruct(u8, u8);
}

View file

@ -0,0 +1,15 @@
error[E0603]: cannot match on a field named `1` of struct `Box`, which is not accessible in current scope
--> $DIR/issue-82772.rs:5:15
|
LL | let Box { 1: _, .. }: Box<()>;
| ^
error[E0603]: cannot match on a field named `1` of struct `LocalModPrivateStruct`, which is not accessible in current scope
--> $DIR/issue-82772.rs:6:33
|
LL | let LocalModPrivateStruct { 1: _, .. } = LocalModPrivateStruct::default();
| ^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0603`.