diff options
author | Blaž Hrastnik | 2021-03-01 08:37:31 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-01 08:37:31 +0000 |
commit | a16c6e25852d985d90e56981a3aba62be012071d (patch) | |
tree | 29f1b80c7fe8446212190b7f22f00edbcd3099aa /helix-syntax | |
parent | 2088c45075875cd069a2c403ee76028146487bb0 (diff) |
clippy lints
Diffstat (limited to 'helix-syntax')
-rw-r--r-- | helix-syntax/build.rs | 46 | ||||
-rw-r--r-- | helix-syntax/src/lib.rs | 10 |
2 files changed, 26 insertions, 30 deletions
diff --git a/helix-syntax/build.rs b/helix-syntax/build.rs index b915ebf1..f08a8819 100644 --- a/helix-syntax/build.rs +++ b/helix-syntax/build.rs @@ -13,13 +13,11 @@ fn get_debug() -> bool { fn collect_tree_sitter_dirs(ignore: Vec<String>) -> Vec<String> { let mut dirs = Vec::new(); - for entry in fs::read_dir("languages").unwrap() { - if let Ok(entry) = entry { - let path = entry.path(); - let dir = path.file_name().unwrap().to_str().unwrap().to_string(); - if !ignore.contains(&dir) { - dirs.push(dir); - } + for entry in fs::read_dir("languages").unwrap().flatten() { + let path = entry.path(); + let dir = path.file_name().unwrap().to_str().unwrap().to_string(); + if !ignore.contains(&dir) { + dirs.push(dir); } } dirs @@ -31,24 +29,22 @@ fn collect_src_files(dir: &str) -> (Vec<String>, Vec<String>) { let mut c_files = Vec::new(); let mut cpp_files = Vec::new(); let path = PathBuf::from("languages").join(&dir).join("src"); - for entry in fs::read_dir(path).unwrap() { - if let Ok(entry) = entry { - let path = entry.path(); - if path - .file_stem() - .unwrap() - .to_str() - .unwrap() - .starts_with("binding") - { - continue; - } - if let Some(ext) = path.extension() { - if ext == "c" { - c_files.push(path.to_str().unwrap().to_string()); - } else if ext == "cc" || ext == "cpp" || ext == "cxx" { - cpp_files.push(path.to_str().unwrap().to_string()); - } + for entry in fs::read_dir(path).unwrap().flatten() { + let path = entry.path(); + if path + .file_stem() + .unwrap() + .to_str() + .unwrap() + .starts_with("binding") + { + continue; + } + if let Some(ext) = path.extension() { + if ext == "c" { + c_files.push(path.to_str().unwrap().to_string()); + } else if ext == "cc" || ext == "cpp" || ext == "cxx" { + cpp_files.push(path.to_str().unwrap().to_string()); } } } diff --git a/helix-syntax/src/lib.rs b/helix-syntax/src/lib.rs index 11a6f840..64fe1023 100644 --- a/helix-syntax/src/lib.rs +++ b/helix-syntax/src/lib.rs @@ -13,7 +13,7 @@ macro_rules! mk_extern { macro_rules! mk_enum { ( $( $camel:ident ),* ) => { #[derive(Clone, Copy, Debug, PartialEq)] - pub enum LANG { + pub enum Lang { $( $camel, )* @@ -25,11 +25,11 @@ macro_rules! mk_enum { macro_rules! mk_get_language { ( $( ($camel:ident, $name:ident) ),* ) => { #[must_use] - pub fn get_language(lang: LANG) -> Language { + pub fn get_language(lang: Lang) -> Language { unsafe { match lang { $( - LANG::$camel => $name(), + Lang::$camel => $name(), )* } } @@ -41,10 +41,10 @@ macro_rules! mk_get_language { macro_rules! mk_get_language_name { ( $( $camel:ident ),* ) => { #[must_use] - pub const fn get_language_name(lang: LANG) -> &'static str { + pub const fn get_language_name(lang: Lang) -> &'static str { match lang { $( - LANG::$camel => stringify!($camel), + Lang::$camel => stringify!($camel), )* } } |