From aedfc41a9192951efeeb11a7801be82750f69c29 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sat, 9 Nov 2019 19:34:21 -0500 Subject: [PATCH] Remove "error" qualifier from error messages, as it's redundant --- .../tests/ui/attribute-misuse.stderr | 32 ++++++------ .../ui/duplication-backtrace-delegate.stderr | 4 +- .../ui/duplication-backtrace-fields.stderr | 2 +- .../tests/ui/duplication-enum.stderr | 2 +- .../ui/duplication-multiple-attributes.stderr | 2 +- .../ui/duplication-source-attributes.stderr | 2 +- .../tests/ui/duplication-source-from.stderr | 2 +- .../tests/ui/duplication-struct.stderr | 2 +- .../tests/ui/duplication-variant.stderr | 2 +- snafu-derive/src/lib.rs | 50 +++++++++---------- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/compatibility-tests/compile-fail/tests/ui/attribute-misuse.stderr b/compatibility-tests/compile-fail/tests/ui/attribute-misuse.stderr index 2626336e..c5cbfc68 100644 --- a/compatibility-tests/compile-fail/tests/ui/attribute-misuse.stderr +++ b/compatibility-tests/compile-fail/tests/ui/attribute-misuse.stderr @@ -1,58 +1,58 @@ -error: `display` attribute is only valid on variants of an error enum, not on an enum +error: `display` attribute is only valid on variants of an enum, not on an enum --> $DIR/attribute-misuse.rs:5:13 | 5 | #[snafu(display("display should not work here"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `source(from)` attribute is only valid on fields of an error variant, not on an enum +error: `source(from)` attribute is only valid on fields of a variant, not on an enum --> $DIR/attribute-misuse.rs:6:13 | 6 | #[snafu(source(from(XXXX, Box::new)))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `source(bool)` attribute is only valid on fields of an error variant, not on an enum +error: `source(bool)` attribute is only valid on fields of a variant, not on an enum --> $DIR/attribute-misuse.rs:7:13 | 7 | #[snafu(source(true))] | ^^^^^^^^^^^^ -error: `backtrace` attribute is only valid on fields of an error variant, not on an enum +error: `backtrace` attribute is only valid on fields of a variant, not on an enum --> $DIR/attribute-misuse.rs:8:13 | 8 | #[snafu(backtrace)] | ^^^^^^^^^ -error: `context` attribute is only valid on an error variant, not on an enum +error: `context` attribute is only valid on a variant, not on an enum --> $DIR/attribute-misuse.rs:9:13 | 9 | #[snafu(context)] | ^^^^^^^ -error: `source` attribute is only valid on fields of an error variant, not on a variant +error: `source` attribute is only valid on fields of a variant, not on a variant --> $DIR/attribute-misuse.rs:21:46 | 21 | #[snafu(display("an error variant"), source(from(XXXX, Box::new)))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `source` attribute is only valid on fields of an error variant, not on a variant +error: `source` attribute is only valid on fields of a variant, not on a variant --> $DIR/attribute-misuse.rs:22:17 | 22 | #[snafu(source)] | ^^^^^^ -error: `backtrace` attribute is only valid on fields of an error variant, not on a variant +error: `backtrace` attribute is only valid on fields of a variant, not on a variant --> $DIR/attribute-misuse.rs:23:17 | 23 | #[snafu(backtrace)] | ^^^^^^^^^ -error: `display` attribute is only valid on variants of an error enum, not on a field +error: `display` attribute is only valid on variants of an enum, not on a field --> $DIR/attribute-misuse.rs:34:21 | 34 | #[snafu(display("display should not work here"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `visibility` attribute is only valid on an error enum and its variants, not on a field +error: `visibility` attribute is only valid on an enum and its variants, not on a field --> $DIR/attribute-misuse.rs:35:21 | 35 | #[snafu(visibility(pub))] @@ -64,37 +64,37 @@ error: Incompatible attributes [`source(false)`, `source(from)`] specified on a 37 | #[snafu(source(from(XXXX, Box::new)))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `context` attribute is only valid on variants of an error enum, not on a field +error: `context` attribute is only valid on variants of an enum, not on a field --> $DIR/attribute-misuse.rs:38:21 | 38 | #[snafu(context)] | ^^^^^^^ -error: `display` attribute is only valid on variants of an error enum, not on a struct +error: `display` attribute is only valid on variants of an enum, not on a struct --> $DIR/attribute-misuse.rs:51:13 | 51 | #[snafu(display("display should not work here"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `visibility` attribute is only valid on an error enum and its variants, not on a struct +error: `visibility` attribute is only valid on an enum and its variants, not on a struct --> $DIR/attribute-misuse.rs:53:13 | 53 | #[snafu(visibility(pub))] | ^^^^^^^^^^^^^^^ -error: `source(bool)` attribute is only valid on fields of an error variant, not on a struct +error: `source(bool)` attribute is only valid on fields of a variant, not on a struct --> $DIR/attribute-misuse.rs:54:13 | 54 | #[snafu(source(true))] | ^^^^^^^^^^^^ -error: `backtrace` attribute is only valid on fields of an error variant, not on a struct +error: `backtrace` attribute is only valid on fields of a variant, not on a struct --> $DIR/attribute-misuse.rs:55:13 | 55 | #[snafu(backtrace)] | ^^^^^^^^^ -error: `context` attribute is only valid on variants of an error enum, not on a struct +error: `context` attribute is only valid on variants of an enum, not on a struct --> $DIR/attribute-misuse.rs:56:13 | 56 | #[snafu(context)] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-delegate.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-delegate.stderr index d2d46245..707453a5 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-delegate.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-delegate.stderr @@ -1,11 +1,11 @@ -error: Cannot have `backtrace` field and `backtrace` attribute on a source field in the same error variant +error: Cannot have `backtrace` field and `backtrace` attribute on a source field in the same variant --> $DIR/duplication-backtrace-delegate.rs:10:9 | 10 | / #[snafu(backtrace)] 11 | | source: String, | |______________________^ -error: Cannot have `backtrace` field and `backtrace` attribute on a source field in the same error variant +error: Cannot have `backtrace` field and `backtrace` attribute on a source field in the same variant --> $DIR/duplication-backtrace-delegate.rs:7:9 | 7 | backtrace: Backtrace, diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-fields.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-fields.stderr index b4e85ebd..ca206b02 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-fields.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-backtrace-fields.stderr @@ -1,4 +1,4 @@ -error: Multiple `backtrace` attributes are not supported within an error variant +error: Multiple `backtrace` attributes are not supported within a variant --> $DIR/duplication-backtrace-fields.rs:10:17 | 10 | #[snafu(backtrace)] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-enum.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-enum.stderr index c9838da9..e2621432 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-enum.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-enum.stderr @@ -1,4 +1,4 @@ -error: Multiple `visibility` attributes are not supported on an error enum +error: Multiple `visibility` attributes are not supported on an enum --> $DIR/duplication-enum.rs:5:9 | 5 | #[snafu(visibility(pub))] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-multiple-attributes.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-multiple-attributes.stderr index eb58fe76..1ed0e6a4 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-multiple-attributes.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-multiple-attributes.stderr @@ -1,4 +1,4 @@ -error: Multiple `visibility` attributes are not supported on an error variant +error: Multiple `visibility` attributes are not supported on a variant --> $DIR/duplication-multiple-attributes.rs:6:30 | 6 | #[snafu(visibility(pub), visibility(pub))] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-source-attributes.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-source-attributes.stderr index 06fefd68..fb537e8d 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-source-attributes.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-source-attributes.stderr @@ -1,4 +1,4 @@ -error: Multiple `source` attributes are not supported within an error variant +error: Multiple `source` attributes are not supported within a variant --> $DIR/duplication-source-attributes.rs:10:18 | 10 | #[snafu(source)] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-source-from.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-source-from.stderr index 13aaf3a9..68284f8f 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-source-from.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-source-from.stderr @@ -1,4 +1,4 @@ -error: Multiple `source` attributes are not supported within an error variant +error: Multiple `source` attributes are not supported within a variant --> $DIR/duplication-source-from.rs:10:18 | 10 | #[snafu(source(from(EnumError, Box::new)))] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-struct.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-struct.stderr index bd7ffff3..cfcb9651 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-struct.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-struct.stderr @@ -1,4 +1,4 @@ -error: Multiple `source(from)` attributes are not supported on an error struct +error: Multiple `source(from)` attributes are not supported on a struct --> $DIR/duplication-struct.rs:8:9 | 8 | #[snafu(source(from(UsableError, Box::new)))] diff --git a/compatibility-tests/compile-fail/tests/ui/duplication-variant.stderr b/compatibility-tests/compile-fail/tests/ui/duplication-variant.stderr index fb916f5a..77770e6e 100644 --- a/compatibility-tests/compile-fail/tests/ui/duplication-variant.stderr +++ b/compatibility-tests/compile-fail/tests/ui/duplication-variant.stderr @@ -1,4 +1,4 @@ -error: Multiple `display` attributes are not supported on an error variant +error: Multiple `display` attributes are not supported on a variant --> $DIR/duplication-variant.rs:6:13 | 6 | #[snafu(display("should not allow duplicate display"))] diff --git a/snafu-derive/src/lib.rs b/snafu-derive/src/lib.rs index 86322fa0..7d604779 100644 --- a/snafu-derive/src/lib.rs +++ b/snafu-derive/src/lib.rs @@ -381,7 +381,7 @@ fn parse_snafu_enum( let mut errors = SyntaxErrors::default(); - let mut default_visibilities = AtMostOne::new("visibility", "on an error enum"); + let mut default_visibilities = AtMostOne::new("visibility", "on an enum"); for attr in attributes_from_syn(attrs)? { match attr { @@ -393,7 +393,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "display", - valid_on: "variants of an error enum", + valid_on: "variants of an enum", not_on: "an enum", }, ); @@ -406,7 +406,7 @@ fn parse_snafu_enum( tokens.clone(), OnlyValidOn { attribute: "source(bool)", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "an enum", }, ); @@ -416,7 +416,7 @@ fn parse_snafu_enum( tokens.clone(), OnlyValidOn { attribute: "source(from)", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "an enum", }, ); @@ -429,7 +429,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "backtrace", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "an enum", }, ); @@ -440,7 +440,7 @@ fn parse_snafu_enum( OnlyValidOn { // TODO: enums for these attribute: "context", - valid_on: "an error variant", + valid_on: "a variant", not_on: "an enum", }, ); @@ -460,9 +460,9 @@ fn parse_snafu_enum( let name = variant.ident; let variant_span = name.span(); - let mut display_formats = AtMostOne::new("display", "on an error variant"); - let mut visibilities = AtMostOne::new("visibility", "on an error variant"); - let mut contexts = AtMostOne::new("context", "on an error variant"); + let mut display_formats = AtMostOne::new("display", "on a variant"); + let mut visibilities = AtMostOne::new("visibility", "on a variant"); + let mut contexts = AtMostOne::new("context", "on a variant"); let mut doc_comment = String::new(); let mut reached_end_of_doc_comment = false; @@ -476,7 +476,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "source", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "a variant", }, ); @@ -486,7 +486,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "backtrace", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "a variant", }, ); @@ -522,8 +522,8 @@ fn parse_snafu_enum( }; let mut user_fields = Vec::new(); - let mut source_fields = AtMostOne::new("source", "within an error variant"); - let mut backtrace_fields = AtMostOne::new("backtrace", "within an error variant"); + let mut source_fields = AtMostOne::new("source", "within a variant"); + let mut backtrace_fields = AtMostOne::new("backtrace", "within a variant"); for syn_field in fields { let original = syn_field.clone(); @@ -627,7 +627,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "visibility", - valid_on: "an error enum and its variants", + valid_on: "an enum and its variants", not_on: "a field", }, ); @@ -637,7 +637,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "display", - valid_on: "variants of an error enum", + valid_on: "variants of an enum", not_on: "a field", }, ); @@ -647,7 +647,7 @@ fn parse_snafu_enum( tokens, OnlyValidOn { attribute: "context", - valid_on: "variants of an error enum", + valid_on: "variants of an enum", not_on: "a field", }, ); @@ -713,11 +713,11 @@ fn parse_snafu_enum( let backtrace_location = backtrace.1.clone(); errors.add( source_location, - "Cannot have `backtrace` field and `backtrace` attribute on a source field in the same error variant", + "Cannot have `backtrace` field and `backtrace` attribute on a source field in the same variant", ); errors.add( backtrace_location, - "Cannot have `backtrace` field and `backtrace` attribute on a source field in the same error variant", + "Cannot have `backtrace` field and `backtrace` attribute on a source field in the same variant", ); } _ => {} // no conflict @@ -789,7 +789,7 @@ fn parse_snafu_struct( ) -> MultiSynResult { use syn::Fields; - let mut transformations = AtMostOne::new("source(from)", "on an error struct"); + let mut transformations = AtMostOne::new("source(from)", "on a struct"); let mut errors = SyntaxErrors::default(); @@ -800,7 +800,7 @@ fn parse_snafu_struct( tokens, OnlyValidOn { attribute: "display", - valid_on: "variants of an error enum", + valid_on: "variants of an enum", not_on: "a struct", }, ); @@ -810,7 +810,7 @@ fn parse_snafu_struct( tokens, OnlyValidOn { attribute: "visibility", - valid_on: "an error enum and its variants", + valid_on: "an enum and its variants", not_on: "a struct", }, ); @@ -823,7 +823,7 @@ fn parse_snafu_struct( tokens.clone(), OnlyValidOn { attribute: "source(bool)", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "a struct", }, ); @@ -837,7 +837,7 @@ fn parse_snafu_struct( tokens, OnlyValidOn { attribute: "backtrace", - valid_on: "fields of an error variant", + valid_on: "fields of a variant", not_on: "a struct", }, ); @@ -847,7 +847,7 @@ fn parse_snafu_struct( tokens, OnlyValidOn { attribute: "context", - valid_on: "variants of an error enum", + valid_on: "variants of an enum", not_on: "a struct", }, ); @@ -1388,7 +1388,7 @@ impl<'a> quote::ToTokens for ContextSelector<'a> { let names: Vec<_> = user_fields.iter().map(|f| f.name.clone()).collect(); let selector_doc = format!( - "SNAFU context selector for the `{}::{}` error variant", + "SNAFU context selector for the `{}::{}` variant", enum_name, variant_name, );