Skip to content

Commit 8d681b3

Browse files
committed
Derive debug for SqlState
The code generation problems that required the manual impl are now gone.
1 parent dcd621b commit 8d681b3

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

build.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ fn main() {
493493
make_enum(&codes, &mut file);
494494
make_map(&codes, &mut file);
495495
make_impl(&codes, &mut file);
496-
make_debug(&codes, &mut file);
497496

498497
// This is already assumed to be the case but there's no way to say that
499498
// you don't depend on anything at all
@@ -571,7 +570,7 @@ fn variant_name(code: &str) -> Option<String> {
571570
fn make_enum(codes: &[Code], file: &mut BufWriter<File>) {
572571
write!(file,
573572
r#"/// SQLSTATE error codes
574-
#[derive(PartialEq, Eq, Clone)]
573+
#[derive(PartialEq, Eq, Clone, Debug)]
575574
pub enum SqlState {{
576575
"#
577576
).unwrap();
@@ -631,26 +630,3 @@ impl SqlState {{
631630
"#
632631
).unwrap();
633632
}
634-
635-
fn make_debug(codes: &[Code], file: &mut BufWriter<File>) {
636-
write!(file, r#"
637-
impl fmt::Debug for SqlState {{
638-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {{
639-
let s = match *self {{"#
640-
).unwrap();
641-
642-
for code in codes {
643-
write!(file, r#"
644-
SqlState::{0} => "{0}","#,
645-
code.variant).unwrap();
646-
}
647-
648-
write!(file, r#"
649-
SqlState::Other(ref s) => return write!(fmt, "Other({{:?}})", s),
650-
}};
651-
fmt.write_str(s)
652-
}}
653-
}}
654-
"#
655-
).unwrap();
656-
}

0 commit comments

Comments
 (0)