diff --git a/sv-parser-parser/src/expressions/strings.rs b/sv-parser-parser/src/expressions/strings.rs index ed86aca..1c0115d 100644 --- a/sv-parser-parser/src/expressions/strings.rs +++ b/sv-parser-parser/src/expressions/strings.rs @@ -31,11 +31,9 @@ pub(crate) fn string_literal_impl(s: Span) -> IResult { let a = if let Some(b) = ret { let a = concat(a, b).unwrap(); - let a = concat(a, c).unwrap(); - a + concat(a, c).unwrap() } else { - let a = concat(a, c).unwrap(); - a + concat(a, c).unwrap() }; Ok((s, into_locate(a))) diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index 5b99949..2f2de25 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -51,7 +51,7 @@ pub(crate) fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, S #[cfg(not(feature = "trace"))] pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, Symbol> { move |s: Span<'a>| { - let (s, x) = map(no_ws(map(tag(t.clone()), |x: Span| into_locate(x))), |x| { + let (s, x) = map(no_ws(map(tag(t.clone()), into_locate)), |x| { Symbol { nodes: x } })(s)?; Ok((s, x)) @@ -63,7 +63,7 @@ pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult| { let (depth, s) = nom_tracable::forward_trace(s, &format!("symbol(\"{}\")", t)); let body = || { - let (s, x) = map(no_ws(map(tag(t.clone()), |x: Span| into_locate(x))), |x| { + let (s, x) = map(no_ws(map(tag(t.clone()), into_locate)), |x| { Symbol { nodes: x } })(s)?; Ok((s, x)) @@ -78,9 +78,9 @@ pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, move |s: Span<'a>| { let (s, x) = map( ws(alt(( - all_consuming(map(tag(t.clone()), |x: Span| into_locate(x))), + all_consuming(map(tag(t.clone()), into_locate)), terminated( - map(tag(t.clone()), |x: Span| into_locate(x)), + map(tag(t.clone()), into_locate), peek(none_of(AZ09_)), ), ))), @@ -97,9 +97,9 @@ pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult, let body = || { let (s, x) = map( ws(alt(( - all_consuming(map(tag(t.clone()), |x: Span| into_locate(x))), + all_consuming(map(tag(t.clone()), into_locate)), terminated( - map(tag(t.clone()), |x: Span| into_locate(x)), + map(tag(t.clone()), into_locate), peek(none_of(AZ09_)), ), ))), @@ -281,16 +281,12 @@ where { move |s: Span<'a>| { let (s, a) = g(s)?; - let mut s = s.clone(); + let mut s = s; let mut ret = Vec::new(); - loop { - if let Ok((t, b)) = f(s) { - if let Ok((u, c)) = g(t) { - s = u; - ret.push((b, c)); - } else { - break; - } + while let Ok((t, b)) = f(s) { + if let Ok((u, c)) = g(t) { + s = u; + ret.push((b, c)); } else { break; } @@ -353,10 +349,7 @@ thread_local!( ); pub(crate) fn in_directive() -> bool { - IN_DIRECTIVE.with(|x| match x.borrow().last() { - Some(_) => true, - None => false, - }) + IN_DIRECTIVE.with(|x| x.borrow().last().is_some()) } pub(crate) fn begin_directive() { diff --git a/sv-parser-pp/src/preprocess.rs b/sv-parser-pp/src/preprocess.rs index 6a917cb..828e778 100644 --- a/sv-parser-pp/src/preprocess.rs +++ b/sv-parser-pp/src/preprocess.rs @@ -393,19 +393,19 @@ fn resolve_text_macro_usage, U: AsRef>( let (replaced, new_defines) = preprocess_str(&replaced, path.as_ref(), &defines, include_paths)?; - return Ok(( + Ok(( String::from(replaced.text()), define.path.clone(), *range, new_defines, - )); + )) } else { - return Err(ErrorKind::DefineTextNotFound(String::from(id)).into()); + Err(ErrorKind::DefineTextNotFound(String::from(id)).into()) } } else if let Some(_) = define { - return Err(ErrorKind::DefineTextNotFound(String::from(id)).into()); + Err(ErrorKind::DefineTextNotFound(String::from(id)).into()) } else { - return Err(ErrorKind::DefineNotFound(String::from(id)).into()); + Err(ErrorKind::DefineNotFound(String::from(id)).into()) } }