Skip to content

Commit

Permalink
Remove "error" qualifier from error messages, as it's redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Nov 14, 2019
1 parent 0335662 commit aedfc41
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
32 changes: 16 additions & 16 deletions compatibility-tests/compile-fail/tests/ui/attribute-misuse.stderr
Original file line number Diff line number Diff line change
@@ -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))]
Expand All @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -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))]
Expand Down
Original file line number Diff line number Diff line change
@@ -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))]
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -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)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -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)))]
Expand Down
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down
50 changes: 25 additions & 25 deletions snafu-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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;

Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -789,7 +789,7 @@ fn parse_snafu_struct(
) -> MultiSynResult<StructInfo> {
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();

Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand All @@ -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",
},
);
Expand Down Expand Up @@ -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,
);

Expand Down

0 comments on commit aedfc41

Please sign in to comment.