Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
iliabylich committed Oct 28, 2021
1 parent 3c7e183 commit 3607eb8
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions examples/real/compare_with_mri.rs
Expand Up @@ -32,13 +32,13 @@ fn compare(file: InputFile) -> Output {
// emits multibyte UTF chars as separate tSTRING_CONTENT chunks
} else {
return Output::Skip {
reason: format!("has multibyte UTF-8 chars"),
reason: "has multibyte UTF-8 chars".to_string(),
};
}
}
Err(_) => {
return Output::Skip {
reason: format!("has invalid utf-8 source"),
reason: "has invalid utf-8 source".to_string(),
};
}
}
Expand All @@ -50,7 +50,7 @@ fn compare(file: InputFile) -> Output {
if expected.status.code() != Some(0) {
// invalid file, even popular gems have them
return Output::Skip {
reason: format!("contains invalid Ruby code"),
reason: "contains invalid Ruby code".to_string(),
};
}

Expand Down Expand Up @@ -111,7 +111,7 @@ pub(crate) fn main() -> Result<(), Box<dyn std::error::Error>> {
let files = args
.pattern
.map(|pattern| InputFiles::new_pattern(&pattern))
.unwrap_or_else(|| InputFiles::empty());
.unwrap_or_else(InputFiles::empty);

let mut warnings = vec![];
let mut errors = vec![];
Expand Down
2 changes: 1 addition & 1 deletion examples/real/helpers/input_files.rs
Expand Up @@ -25,7 +25,7 @@ impl InputFiles {
}

pub(crate) fn new_pattern(pattern: &str) -> Self {
let files: Vec<InputFile> = glob::glob(&pattern)
let files: Vec<InputFile> = glob::glob(pattern)
.expect("invalid glob pattern")
.map(|f| f.unwrap().to_str().unwrap().to_string())
.map(|filepath| InputFile {
Expand Down
2 changes: 1 addition & 1 deletion examples/real/helpers/parse.rs
Expand Up @@ -4,7 +4,7 @@ use lib_ruby_parser::{Parser, ParserOptions, ParserResult};
#[allow(dead_code)]
pub(crate) fn parse(input: InputFile, drop_tokens: bool) -> ParserResult {
let options = ParserOptions {
buffer_name: input.filepath.into(),
buffer_name: input.filepath,
record_tokens: !drop_tokens,
..Default::default()
};
Expand Down
6 changes: 3 additions & 3 deletions examples/real/helpers/printer.rs
Expand Up @@ -28,15 +28,15 @@ mod formatters {

pub(crate) fn print_compact_ast_with_locations(result: &ParserResult) {
let src = result.input.as_shared_bytes();
let src = std::str::from_utf8(src.as_ref()).unwrap_or_else(|_| "invalid-source");
let src = std::str::from_utf8(src).unwrap_or("invalid-source");
println!("{}", src);
print_only_diagnostics(&result);
print_only_diagnostics(result);
if let Some(ast) = result.ast.as_ref() {
ast.print_with_locs()
}
}
pub(crate) fn print_compact_ast(result: &ParserResult) {
print_only_diagnostics(&result);
print_only_diagnostics(result);
if let Some(ast) = result.ast.as_ref() {
println!("{}", ast.inspect(0));
}
Expand Down
6 changes: 3 additions & 3 deletions examples/real/helpers/profiler.rs
@@ -1,5 +1,5 @@
#[cfg(feature = "pprof")]
mod profiler {
mod implementation {
extern crate pprof;

pub(crate) struct Profiler {
Expand Down Expand Up @@ -58,7 +58,7 @@ mod profiler {
}

#[cfg(not(feature = "pprof"))]
mod profiler {
mod implementation {
pub(crate) struct Profiler {}

impl Profiler {
Expand All @@ -74,4 +74,4 @@ mod profiler {
}
}

pub(crate) use profiler::Profiler;
pub(crate) use implementation::Profiler;
2 changes: 1 addition & 1 deletion examples/real/helpers/token_list.rs
Expand Up @@ -42,7 +42,7 @@ impl std::fmt::Debug for TokenList {
.iter()
.map(|token| {
let name = rpad(&token.token_name(), tok_name_length);
let value = rpad(&token_value(&token), tok_value_length);
let value = rpad(&token_value(token), tok_value_length);

format!(
" :{}{}[{}, {}]",
Expand Down
6 changes: 3 additions & 3 deletions examples/real/parse.rs
Expand Up @@ -38,10 +38,10 @@ impl From<&Args> for Option<InputFiles> {
fn from(args: &Args) -> Self {
if let Some(code_to_eval) = &args.code_to_eval {
Some(InputFiles::new_eval(code_to_eval.clone().into_bytes()))
} else if let Some(pattern) = &args.pattern {
Some(InputFiles::new_pattern(&pattern))
} else {
None
args.pattern
.as_ref()
.map(|pattern| InputFiles::new_pattern(pattern))
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions examples/real/tokenize.rs
@@ -1,7 +1,6 @@
extern crate clap;
use clap::Parser;

#[allow(dead_code)]
use super::helpers::*;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -35,5 +34,5 @@ pub(crate) fn main() -> Result<(), Box<dyn std::error::Error>> {
callback(TokenList { tokens });
}

return Ok(());
Ok(())
}

0 comments on commit 3607eb8

Please sign in to comment.