Run clippy

This commit is contained in:
Steven Fackler
2018-12-09 21:23:31 -08:00
parent 8c3338e37d
commit 04ce4bb7a1
29 changed files with 642 additions and 810 deletions

View File

@@ -1,3 +1,5 @@
#![warn(clippy::all)]
extern crate linked_hash_map;
extern crate marksman_escape;
extern crate phf_codegen;

View File

@@ -4,7 +4,7 @@ use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::Path;
const ERRCODES_TXT: &'static str = include_str!("errcodes.txt");
const ERRCODES_TXT: &str = include_str!("errcodes.txt");
pub fn build(path: &Path) {
let mut file = BufWriter::new(File::create(path.join("error/sqlstate.rs")).unwrap());
@@ -20,7 +20,7 @@ fn parse_codes() -> LinkedHashMap<String, Vec<String>> {
let mut codes = LinkedHashMap::new();
for line in ERRCODES_TXT.lines() {
if line.starts_with("#") || line.starts_with("Section") || line.trim().is_empty() {
if line.starts_with('#') || line.starts_with("Section") || line.trim().is_empty() {
continue;
}
@@ -39,7 +39,6 @@ fn make_type(file: &mut BufWriter<File>) {
write!(
file,
"// Autogenerated file - DO NOT EDIT
use phf;
use std::borrow::Cow;
/// A SQLSTATE error code
@@ -96,5 +95,5 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
builder.entry(&**code, &format!("SqlState::{}", &names[0]));
}
builder.build(file).unwrap();
write!(file, ";\n").unwrap();
writeln!(file, ";").unwrap();
}

View File

@@ -7,8 +7,8 @@ use std::path::Path;
use crate::snake_to_camel;
const PG_TYPE_H: &'static str = include_str!("pg_type.h");
const PG_RANGE_H: &'static str = include_str!("pg_range.h");
const PG_TYPE_H: &str = include_str!("pg_type.h");
const PG_RANGE_H: &str = include_str!("pg_range.h");
struct Type {
name: &'static str,
@@ -122,7 +122,7 @@ fn make_header(w: &mut BufWriter<File>) {
"// Autogenerated file - DO NOT EDIT
use std::sync::Arc;
use types::{{Type, Oid, Kind}};
use crate::types::{{Type, Oid, Kind}};
#[derive(PartialEq, Eq, Debug)]
pub struct Other {{
@@ -231,8 +231,7 @@ fn make_impl(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
write!(
w,
" Inner::{} => {{
const V: &'static Kind = &Kind::{};
V
&Kind::{}
}}
",
type_.variant, kind