From 492d8d72936685726066ef0f0f0a9d935f537eee Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Sat, 12 Mar 2022 15:38:44 -0500 Subject: [PATCH] Fix rebase conflicts with stderr files --- .../src/thir/pattern/deconstruct_pat.rs | 2 +- .../pattern/usefulness/doc-hidden-fields.rs | 4 +- .../usefulness/doc-hidden-fields.stderr | 10 +- .../doc-hidden-non-exhaustive.stderr | 101 +++++++++++++----- .../usefulness/stable-gated-fields.stderr | 29 +++++ .../usefulness/stable-gated-patterns.stderr | 24 ++--- .../usefulness/unstable-gated-fields.stderr | 33 ++++++ .../usefulness/unstable-gated-patterns.stderr | 12 +-- 8 files changed, 161 insertions(+), 54 deletions(-) create mode 100644 src/test/ui/pattern/usefulness/stable-gated-fields.stderr create mode 100644 src/test/ui/pattern/usefulness/unstable-gated-fields.stderr diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 72b12759315ea..612bed639bfb1 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -695,7 +695,7 @@ impl<'tcx> Constructor<'tcx> { /// attribute from a type not local to the current crate. pub(super) fn is_doc_hidden_variant(&self, pcx: PatCtxt<'_, '_, 'tcx>) -> bool { if let Constructor::Variant(idx) = self && let ty::Adt(adt, _) = pcx.ty.kind() { - let variant_def_id = adt.variants[*idx].def_id; + let variant_def_id = adt.variants()[*idx].def_id; return pcx.cx.tcx.is_doc_hidden(variant_def_id) && !variant_def_id.is_local(); } false diff --git a/src/test/ui/pattern/usefulness/doc-hidden-fields.rs b/src/test/ui/pattern/usefulness/doc-hidden-fields.rs index aad3809a410a4..4163b87dc8597 100644 --- a/src/test/ui/pattern/usefulness/doc-hidden-fields.rs +++ b/src/test/ui/pattern/usefulness/doc-hidden-fields.rs @@ -12,10 +12,10 @@ struct InCrate { } fn main() { - let HiddenStruct { one, two, } = HiddenStruct::default(); + let HiddenStruct { one, two } = HiddenStruct::default(); //~^ pattern requires `..` due to inaccessible fields - let HiddenStruct { one, } = HiddenStruct::default(); + let HiddenStruct { one } = HiddenStruct::default(); //~^ pattern does not mention field `two` and inaccessible fields let HiddenStruct { one, hide } = HiddenStruct::default(); diff --git a/src/test/ui/pattern/usefulness/doc-hidden-fields.stderr b/src/test/ui/pattern/usefulness/doc-hidden-fields.stderr index 2f1575bfa4167..f277bfbc884fb 100644 --- a/src/test/ui/pattern/usefulness/doc-hidden-fields.stderr +++ b/src/test/ui/pattern/usefulness/doc-hidden-fields.stderr @@ -1,19 +1,19 @@ error: pattern requires `..` due to inaccessible fields --> $DIR/doc-hidden-fields.rs:15:9 | -LL | let HiddenStruct { one, two, } = HiddenStruct::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let HiddenStruct { one, two } = HiddenStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: ignore the inaccessible and unused fields | -LL | let HiddenStruct { one, two, .., } = HiddenStruct::default(); +LL | let HiddenStruct { one, two, .. } = HiddenStruct::default(); | ++++ error[E0027]: pattern does not mention field `two` and inaccessible fields --> $DIR/doc-hidden-fields.rs:18:9 | -LL | let HiddenStruct { one, } = HiddenStruct::default(); - | ^^^^^^^^^^^^^^^^^^^^^ missing field `two` and inaccessible fields +LL | let HiddenStruct { one } = HiddenStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^ missing field `two` and inaccessible fields | help: include the missing field in the pattern and ignore the inaccessible fields | diff --git a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr index 729716cb723dd..296465eb81838 100644 --- a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr +++ b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr @@ -4,8 +4,22 @@ error[E0004]: non-exhaustive patterns: `_` not covered LL | match HiddenEnum::A { | ^^^^^^^^^^^^^ pattern `_` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `HiddenEnum` defined here + --> $DIR/auxiliary/hidden.rs:1:1 + | +LL | / pub enum HiddenEnum { +LL | | A, +LL | | B, +LL | | #[doc(hidden)] +LL | | C, +LL | | } + | |_^ = note: the matched value is of type `HiddenEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ HiddenEnum::B => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/doc-hidden-non-exhaustive.rs:21:11 @@ -13,14 +27,23 @@ error[E0004]: non-exhaustive patterns: `B` not covered LL | match HiddenEnum::A { | ^^^^^^^^^^^^^ pattern `B` not covered | -note: `Foo` defined here +note: `HiddenEnum` defined here --> $DIR/auxiliary/hidden.rs:3:5 | -LL | B, - | - not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum HiddenEnum { +LL | | A, +LL | | B, + | | ^ not covered +LL | | #[doc(hidden)] +LL | | C, +LL | | } + | |_- = note: the matched value is of type `HiddenEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ HiddenEnum::C => {} +LL + B => todo!() + | error[E0004]: non-exhaustive patterns: `B` and `_` not covered --> $DIR/doc-hidden-non-exhaustive.rs:27:11 @@ -28,14 +51,23 @@ error[E0004]: non-exhaustive patterns: `B` and `_` not covered LL | match HiddenEnum::A { | ^^^^^^^^^^^^^ patterns `B` and `_` not covered | -note: `Foo` defined here +note: `HiddenEnum` defined here --> $DIR/auxiliary/hidden.rs:3:5 | -LL | B, - | - not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum HiddenEnum { +LL | | A, +LL | | B, + | | ^ not covered +LL | | #[doc(hidden)] +LL | | C, +LL | | } + | |_- = note: the matched value is of type `HiddenEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ HiddenEnum::A => {} +LL + B | _ => todo!() + | error[E0004]: non-exhaustive patterns: `Some(B)` and `Some(_)` not covered --> $DIR/doc-hidden-non-exhaustive.rs:32:11 @@ -43,32 +75,45 @@ error[E0004]: non-exhaustive patterns: `Some(B)` and `Some(_)` not covered LL | match None { | ^^^^ patterns `Some(B)` and `Some(_)` not covered | -note: `Option` defined here +note: `Option` defined here --> $SRC_DIR/core/src/option.rs:LL:COL | -LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), - | ---- not covered - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +LL | / pub enum Option { +LL | | /// No value. +LL | | #[lang = "None"] +LL | | #[stable(feature = "rust1", since = "1.0.0")] +... | +LL | | Some(#[stable(feature = "rust1", since = "1.0.0")] T), + | | ^^^^ not covered +LL | | } + | |_- = note: the matched value is of type `Option` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ Some(HiddenEnum::A) => {} +LL + Some(B) | Some(_) => todo!() + | error[E0004]: non-exhaustive patterns: `C` not covered --> $DIR/doc-hidden-non-exhaustive.rs:38:11 | -LL | / enum InCrate { -LL | | A, -LL | | B, -LL | | #[doc(hidden)] -LL | | C, - | | - not covered -LL | | } - | |_- `InCrate` defined here -... -LL | match InCrate::A { - | ^^^^^^^^^^ pattern `C` not covered +LL | match InCrate::A { + | ^^^^^^^^^^ pattern `C` not covered | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +note: `InCrate` defined here + --> $DIR/doc-hidden-non-exhaustive.rs:11:5 + | +LL | enum InCrate { + | ------- +... +LL | C, + | ^ not covered = note: the matched value is of type `InCrate` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ InCrate::B => {} +LL + C => todo!() + | error: aborting due to 5 previous errors diff --git a/src/test/ui/pattern/usefulness/stable-gated-fields.stderr b/src/test/ui/pattern/usefulness/stable-gated-fields.stderr new file mode 100644 index 0000000000000..cf98c51a2b41e --- /dev/null +++ b/src/test/ui/pattern/usefulness/stable-gated-fields.stderr @@ -0,0 +1,29 @@ +error[E0027]: pattern does not mention field `stable2` and inaccessible fields + --> $DIR/stable-gated-fields.rs:8:9 + | +LL | let UnstableStruct { stable } = UnstableStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `stable2` and inaccessible fields + | +help: include the missing field in the pattern and ignore the inaccessible fields + | +LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); + | ~~~~~~~~~~~~~~~ +help: if you don't care about this missing field, you can explicitly ignore it + | +LL | let UnstableStruct { stable, .. } = UnstableStruct::default(); + | ~~~~~~ + +error: pattern requires `..` due to inaccessible fields + --> $DIR/stable-gated-fields.rs:11:9 + | +LL | let UnstableStruct { stable, stable2 } = UnstableStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: ignore the inaccessible and unused fields + | +LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0027`. diff --git a/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr b/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr index 696ef9d8de936..559539178cbe3 100644 --- a/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr +++ b/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr @@ -1,13 +1,13 @@ error[E0004]: non-exhaustive patterns: `Stable2` and `_` not covered --> $DIR/stable-gated-patterns.rs:8:11 | -LL | match Foo::Stable { - | ^^^^^^^^^^^ patterns `Stable2` and `_` not covered +LL | match UnstableEnum::Stable { + | ^^^^^^^^^^^^^^^^^^^^ patterns `Stable2` and `_` not covered | -note: `Foo` defined here +note: `UnstableEnum` defined here --> $DIR/auxiliary/unstable.rs:9:5 | -LL | / pub enum Foo { +LL | / pub enum UnstableEnum { LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] LL | | Stable, LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -17,23 +17,23 @@ LL | | #[unstable(feature = "unstable_test_feature", issue = "none")] LL | | Unstable, LL | | } | |_- - = note: the matched value is of type `Foo` + = note: the matched value is of type `UnstableEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ Foo::Stable => {} +LL ~ UnstableEnum::Stable => {} LL + Stable2 | _ => todo!() | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/stable-gated-patterns.rs:13:11 | -LL | match Foo::Stable { - | ^^^^^^^^^^^ pattern `_` not covered +LL | match UnstableEnum::Stable { + | ^^^^^^^^^^^^^^^^^^^^ pattern `_` not covered | -note: `Foo` defined here +note: `UnstableEnum` defined here --> $DIR/auxiliary/unstable.rs:5:1 | -LL | / pub enum Foo { +LL | / pub enum UnstableEnum { LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] LL | | Stable, LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -41,10 +41,10 @@ LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] LL | | Unstable, LL | | } | |_^ - = note: the matched value is of type `Foo` + = note: the matched value is of type `UnstableEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Foo::Stable2 => {} +LL ~ UnstableEnum::Stable2 => {} LL + _ => todo!() | diff --git a/src/test/ui/pattern/usefulness/unstable-gated-fields.stderr b/src/test/ui/pattern/usefulness/unstable-gated-fields.stderr new file mode 100644 index 0000000000000..e4f5fa06b3ff5 --- /dev/null +++ b/src/test/ui/pattern/usefulness/unstable-gated-fields.stderr @@ -0,0 +1,33 @@ +error[E0027]: pattern does not mention field `unstable` + --> $DIR/unstable-gated-fields.rs:10:9 + | +LL | let UnstableStruct { stable, stable2, } = UnstableStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `unstable` + | +help: include the missing field in the pattern + | +LL | let UnstableStruct { stable, stable2, unstable } = UnstableStruct::default(); + | ~~~~~~~~~~~~ +help: if you don't care about this missing field, you can explicitly ignore it + | +LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); + | ~~~~~~ + +error[E0027]: pattern does not mention field `stable2` + --> $DIR/unstable-gated-fields.rs:13:9 + | +LL | let UnstableStruct { stable, unstable, } = UnstableStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `stable2` + | +help: include the missing field in the pattern + | +LL | let UnstableStruct { stable, unstable, stable2 } = UnstableStruct::default(); + | ~~~~~~~~~~~ +help: if you don't care about this missing field, you can explicitly ignore it + | +LL | let UnstableStruct { stable, unstable, .. } = UnstableStruct::default(); + | ~~~~~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0027`. diff --git a/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr b/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr index 8487c9725da83..b5f1805deef11 100644 --- a/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr +++ b/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr @@ -1,13 +1,13 @@ error[E0004]: non-exhaustive patterns: `Unstable` not covered --> $DIR/unstable-gated-patterns.rs:10:11 | -LL | match Foo::Stable { - | ^^^^^^^^^^^ pattern `Unstable` not covered +LL | match UnstableEnum::Stable { + | ^^^^^^^^^^^^^^^^^^^^ pattern `Unstable` not covered | -note: `Foo` defined here +note: `UnstableEnum` defined here --> $DIR/auxiliary/unstable.rs:11:5 | -LL | / pub enum Foo { +LL | / pub enum UnstableEnum { LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] LL | | Stable, LL | | #[stable(feature = "stable_test_feature", since = "1.0.0")] @@ -16,10 +16,10 @@ LL | | Unstable, | | ^^^^^^^^ not covered LL | | } | |_- - = note: the matched value is of type `Foo` + = note: the matched value is of type `UnstableEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Foo::Stable2 => {} +LL ~ UnstableEnum::Stable2 => {} LL + Unstable => todo!() |