Skip to content
This repository was archived by the owner on Oct 10, 2019. It is now read-only.

Commit 0fad8fc

Browse files
committed
Clean up error messages
1 parent 67ac288 commit 0fad8fc

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

postgres-derive-codegen/src/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn get_variants(ctx: &mut ExtCtxt, trait_: &str, def: &EnumDef) -> Vec<(Iden
1212
VariantData::Unit(_) => {}
1313
_ => {
1414
ctx.span_err(variant.span,
15-
&format!("#[derive({})] can only be applied to C-like enums", trait_));
15+
&format!("#[derive({})] does not support non-C-like enums", trait_));
1616
continue;
1717
}
1818
}

postgres-derive-codegen/src/fromsql.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub fn expand(ctx: &mut ExtCtxt,
1717
let item = match *annotatable {
1818
Annotatable::Item(ref item) => item,
1919
_ => {
20-
ctx.span_err(span,
21-
"#[derive(FromSql)] can only be applied to tuple structs and enums");
20+
ctx.span_err(span, "#[derive(FromSql)] can only be applied to structs, single field \
21+
tuple structs, and enums");
2222
return;
2323
}
2424
};
@@ -34,8 +34,8 @@ pub fn expand(ctx: &mut ExtCtxt,
3434
}
3535
ItemKind::Struct(VariantData::Tuple(ref fields, _), _) => {
3636
if fields.len() != 1 {
37-
ctx.span_err(span,
38-
"#[derive(FromSql)] can only be applied to one field tuple structs");
37+
ctx.span_err(span, "#[derive(FromSql)] can only be applied to structs, single \
38+
field tuple structs, and enums");
3939
return;
4040
}
4141
let inner = &fields[0].ty;
@@ -56,8 +56,8 @@ pub fn expand(ctx: &mut ExtCtxt,
5656
composite_from_sql_body(ctx, span, item.ident, &*fields))
5757
}
5858
_ => {
59-
ctx.span_err(span,
60-
"#[derive(FromSql)] can only be applied to tuple structs and enums");
59+
ctx.span_err(span, "#[derive(FromSql)] can only be applied to structs, single field \
60+
tuple structs, and enums");
6161
return;
6262
}
6363
};

postgres-derive-codegen/src/tosql.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub fn expand(ctx: &mut ExtCtxt,
1717
let item = match *annotatable {
1818
Annotatable::Item(ref item) => item,
1919
_ => {
20-
ctx.span_err(span,
21-
"#[derive(ToSql)] can only be applied to tuple structs and enums");
20+
ctx.span_err(span, "#[derive(ToSql)] can only be applied to structs, single field \
21+
tuple structs, and enums");
2222
return;
2323
}
2424
};
@@ -34,8 +34,8 @@ pub fn expand(ctx: &mut ExtCtxt,
3434
}
3535
ItemKind::Struct(VariantData::Tuple(ref fields, _), _) => {
3636
if fields.len() != 1 {
37-
ctx.span_err(span,
38-
"#[derive(ToSql)] can only be applied to one field tuple structs");
37+
ctx.span_err(span, "#[derive(ToSql)] can only be applied to structs, single field \
38+
tuple structs, and enums");
3939
return;
4040
}
4141
let inner = &fields[0].ty;
@@ -56,8 +56,8 @@ pub fn expand(ctx: &mut ExtCtxt,
5656
composite_to_sql_body(ctx, span, &*fields))
5757
}
5858
_ => {
59-
ctx.span_err(span,
60-
"#[derive(ToSql)] can only be applied to tuple structs and enums");
59+
ctx.span_err(span, "#[derive(ToSql)] can only be applied to structs, single field \
60+
tuple structs, and enums");
6161
return;
6262
}
6363
};

postgres-derive-macros/tests/compile-fail/big-tuple-struct.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ macro_rules! to_sql_checked {
55
() => ()
66
}
77

8-
#[derive(ToSql)] //~ ERROR #[derive(ToSql)] can only be applied to one field tuple structs
8+
#[derive(ToSql)] //~ ERROR #[derive(ToSql)] can only be applied to structs, single field tuple structs, and enums
99
struct Foo(i32, i32);
1010

11-
#[derive(FromSql)] //~ ERROR #[derive(FromSql)] can only be applied to one field tuple structs
11+
#[derive(FromSql)] //~ ERROR #[derive(FromSql)] can only be applied to structs, single field tuple structs, and enums
1212
struct Bar(i32, i32);
1313

1414
fn main() {}

postgres-derive-macros/tests/compile-fail/complex-enum.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ macro_rules! to_sql_checked {
77

88
#[derive(ToSql)]
99
enum Foo {
10-
Bar(i32), //~ ERROR #[derive(ToSql)] can only be applied to C-like enums
11-
Baz { b: i32 }, //~ ERROR #[derive(ToSql)] can only be applied to C-like enums
10+
Bar(i32), //~ ERROR #[derive(ToSql)] does not support non-C-like enums
11+
Baz { b: i32 }, //~ ERROR #[derive(ToSql)] does not support non-C-like enums
1212
}
1313

1414
#[derive(FromSql)]
1515
enum Foo {
16-
Bar(i32), //~ ERROR #[derive(FromSql)] can only be applied to C-like enums
17-
Baz { b: i32 }, //~ ERROR #[derive(FromSql)] can only be applied to C-like enums
16+
Bar(i32), //~ ERROR #[derive(FromSql)] does not support non-C-like enums
17+
Baz { b: i32 }, //~ ERROR #[derive(FromSql)] does not support non-C-like enums
1818
}
1919

2020
fn main() {}

0 commit comments

Comments
 (0)