mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
clippy
This commit is contained in:
parent
feb77b5bcc
commit
db7e604643
6 changed files with 19 additions and 26 deletions
|
@ -191,7 +191,7 @@ pub fn main() -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_parse_error<'a>(fail: Bag<'a>) {
|
fn report_parse_error(fail: Bag<'_>) {
|
||||||
println!("TODO Gracefully report parse error in repl: {:?}", fail);
|
println!("TODO Gracefully report parse error in repl: {:?}", fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2198,7 +2198,7 @@ fn load_pkg_config<'a>(
|
||||||
Ok(Msg::Many(vec![effects_module_msg, pkg_config_module_msg]))
|
Ok(Msg::Many(vec![effects_module_msg, pkg_config_module_msg]))
|
||||||
}
|
}
|
||||||
Err((_, fail, _)) => Err(LoadingProblem::ParsingFailed(
|
Err((_, fail, _)) => Err(LoadingProblem::ParsingFailed(
|
||||||
fail.to_parse_problem(filename, bytes),
|
fail.into_parse_problem(filename, bytes),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2445,7 +2445,7 @@ fn parse_header<'a>(
|
||||||
module_timing,
|
module_timing,
|
||||||
),
|
),
|
||||||
Err((_, fail, _)) => Err(LoadingProblem::ParsingFailed(
|
Err((_, fail, _)) => Err(LoadingProblem::ParsingFailed(
|
||||||
fail.to_parse_problem(filename, src_bytes),
|
fail.into_parse_problem(filename, src_bytes),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3459,7 +3459,7 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result<Msg<'a>, Loadi
|
||||||
Ok((_, success, _state)) => success,
|
Ok((_, success, _state)) => success,
|
||||||
Err((_, fail, _)) => {
|
Err((_, fail, _)) => {
|
||||||
return Err(LoadingProblem::ParsingFailed(
|
return Err(LoadingProblem::ParsingFailed(
|
||||||
fail.to_parse_problem(header.module_path, header.src),
|
fail.into_parse_problem(header.module_path, header.src),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -580,7 +580,7 @@ type Body<'a> = (Located<Pattern<'a>>, Located<Expr<'a>>);
|
||||||
|
|
||||||
fn body<'a>(min_indent: u16) -> impl Parser<'a, Body<'a>> {
|
fn body<'a>(min_indent: u16) -> impl Parser<'a, Body<'a>> {
|
||||||
let indented_more = min_indent + 1;
|
let indented_more = min_indent + 1;
|
||||||
let result = and!(
|
and!(
|
||||||
// this backtrackable is required for the case
|
// this backtrackable is required for the case
|
||||||
//
|
//
|
||||||
// i = 64
|
// i = 64
|
||||||
|
@ -601,8 +601,7 @@ fn body<'a>(min_indent: u16) -> impl Parser<'a, Body<'a>> {
|
||||||
.parse(a, s)
|
.parse(a, s)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn body_at_indent<'a>(indent_level: u16) -> impl Parser<'a, Body<'a>> {
|
fn body_at_indent<'a>(indent_level: u16) -> impl Parser<'a, Body<'a>> {
|
||||||
|
|
|
@ -297,14 +297,8 @@ pub fn platform_header<'a>() -> impl Parser<'a, PlatformHeader<'a>> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn module_defs<'a>() -> impl Parser<'a, Vec<'a, Located<Def<'a>>>> {
|
pub fn module_defs<'a>() -> impl Parser<'a, Vec<'a, Located<Def<'a>>>> {
|
||||||
move |a: &'a Bump, s: State<'a>| {
|
// force that we pare until the end of the input
|
||||||
// this parses just the defs
|
skip_second!(zero_or_more!(space0_around(loc(def(0)), 0)), end_of_file())
|
||||||
let defs = zero_or_more!(space0_around(loc(def(0)), 0));
|
|
||||||
|
|
||||||
let result = skip_second!(defs, end_of_file()).parse(a, s);
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ProvidesTo<'a> {
|
struct ProvidesTo<'a> {
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl<'a> State<'a> {
|
||||||
|
|
||||||
/// Returns whether the parser has reached the end of the input
|
/// Returns whether the parser has reached the end of the input
|
||||||
pub fn has_reached_end(&self) -> bool {
|
pub fn has_reached_end(&self) -> bool {
|
||||||
self.bytes.len() == 0
|
self.bytes.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Increments the line, then resets column, indent_col, and is_indenting.
|
/// Increments the line, then resets column, indent_col, and is_indenting.
|
||||||
|
@ -274,7 +274,7 @@ pub enum ContextStack<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ContextStack<'a> {
|
impl<'a> ContextStack<'a> {
|
||||||
fn to_vec(self) -> std::vec::Vec<ContextItem> {
|
fn into_vec(self) -> std::vec::Vec<ContextItem> {
|
||||||
let mut result = std::vec::Vec::new();
|
let mut result = std::vec::Vec::new();
|
||||||
let mut next = &self;
|
let mut next = &self;
|
||||||
|
|
||||||
|
@ -338,15 +338,15 @@ impl<'a> Bag<'a> {
|
||||||
self.0.pop()
|
self.0.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_parse_problem<'b>(
|
pub fn into_parse_problem(
|
||||||
mut self,
|
mut self,
|
||||||
filename: std::path::PathBuf,
|
filename: std::path::PathBuf,
|
||||||
bytes: &'b [u8],
|
bytes: &[u8],
|
||||||
) -> ParseProblem<'b> {
|
) -> ParseProblem<'_> {
|
||||||
match self.pop() {
|
match self.pop() {
|
||||||
None => unreachable!("there is a parse error, but no problem"),
|
None => unreachable!("there is a parse error, but no problem"),
|
||||||
Some(dead_end) => {
|
Some(dead_end) => {
|
||||||
let context_stack = dead_end.context_stack.to_vec();
|
let context_stack = dead_end.context_stack.into_vec();
|
||||||
|
|
||||||
ParseProblem {
|
ParseProblem {
|
||||||
line: dead_end.line,
|
line: dead_end.line,
|
||||||
|
@ -792,8 +792,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err((element_progress, fail, new_state)) => match element_progress {
|
Err((element_progress, fail, new_state)) => match element_progress {
|
||||||
MadeProgress => return Err((MadeProgress, fail, new_state)),
|
MadeProgress => Err((MadeProgress, fail, new_state)),
|
||||||
NoProgress => return Ok((NoProgress, Vec::new_in(arena), new_state)),
|
NoProgress => Ok((NoProgress, Vec::new_in(arena), new_state)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -849,8 +849,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err((element_progress, fail, new_state)) => match element_progress {
|
Err((element_progress, fail, new_state)) => match element_progress {
|
||||||
MadeProgress => return Err((MadeProgress, fail, new_state)),
|
MadeProgress => Err((MadeProgress, fail, new_state)),
|
||||||
NoProgress => return Ok((NoProgress, Vec::new_in(arena), new_state)),
|
NoProgress => Ok((NoProgress, Vec::new_in(arena), new_state)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ mod test_reporting {
|
||||||
|
|
||||||
let alloc = RocDocAllocator::new(&src_lines, home, &interns);
|
let alloc = RocDocAllocator::new(&src_lines, home, &interns);
|
||||||
|
|
||||||
let problem = fail.to_parse_problem(filename.clone(), src.as_bytes());
|
let problem = fail.into_parse_problem(filename.clone(), src.as_bytes());
|
||||||
let doc = parse_problem(&alloc, filename, 0, problem);
|
let doc = parse_problem(&alloc, filename, 0, problem);
|
||||||
|
|
||||||
callback(doc.pretty(&alloc).append(alloc.line()), buf)
|
callback(doc.pretty(&alloc).append(alloc.line()), buf)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue