rust: run clippy

This commit is contained in:
Alain Zscheile 2023-10-31 15:12:58 +01:00
parent 0d07940cc1
commit e6cda8b525
6 changed files with 12 additions and 8 deletions

View file

@ -169,14 +169,14 @@ impl Expr {
// lambdas and their dependent types are CSR introducers // lambdas and their dependent types are CSR introducers
Ek::Lambda(csr, inner) => Ek::Lambda( Ek::Lambda(csr, inner) => Ek::Lambda(
Rc::clone(csr), Rc::clone(csr),
inner.deep_clone_intern(hmexpr, &*Self::subst_prune_csr(hsvars, csr)), inner.deep_clone_intern(hmexpr, &Self::subst_prune_csr(hsvars, csr)),
), ),
Ek::TyLambda { argty, arg, exp } => Ek::TyLambda { Ek::TyLambda { argty, arg, exp } => Ek::TyLambda {
// we don't need to prune the CSR from the argty because it does not bind it // we don't need to prune the CSR from the argty because it does not bind it
argty: argty.deep_clone_intern(hmexpr, hsvars), argty: argty.deep_clone_intern(hmexpr, hsvars),
arg: Rc::clone(arg), arg: Rc::clone(arg),
exp: exp.deep_clone_intern(hmexpr, &*Self::subst_prune_csr(hsvars, arg)), exp: exp.deep_clone_intern(hmexpr, &Self::subst_prune_csr(hsvars, arg)),
}, },
Ek::Apply(lhs, rhs) => Ek::Apply( Ek::Apply(lhs, rhs) => Ek::Apply(
@ -531,7 +531,7 @@ impl Expr {
// we don't really care if the hsvar was already in use (which might happen when recursing) // we don't really care if the hsvar was already in use (which might happen when recursing)
// `deep_clone` filters CSRs at lambda bindings, all is well. // `deep_clone` filters CSRs at lambda bindings, all is well.
// NOTE: we implement lazy evaluation here, the lambda argument is only evaluated if needed // NOTE: we implement lazy evaluation here, the lambda argument is only evaluated if needed
hsvars.insert(Rc::as_ptr(&csr) as usize, rhs); hsvars.insert(Rc::as_ptr(csr) as usize, rhs);
// we need to subst variables because otherwise lazyness might mess stuff up // we need to subst variables because otherwise lazyness might mess stuff up
// (e.g. using wrong value when recursing) // (e.g. using wrong value when recursing)

View file

@ -35,10 +35,10 @@ pub struct Lexer<'a, Kw> {
} }
impl<Kw> Clone for Lexer<'_, Kw> { impl<Kw> Clone for Lexer<'_, Kw> {
#[inline] #[inline(always)]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
inner: self.inner.clone(), inner: self.inner,
_kw: PhantomData, _kw: PhantomData,
} }
} }

View file

@ -19,6 +19,10 @@ impl EvEqSourceSpan {
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.0.len() self.0.len()
} }
#[inline(always)]
pub fn is_empty(&self) -> bool {
self.0.len() == 0
}
} }
impl cmp::PartialEq for EvEqSourceSpan { impl cmp::PartialEq for EvEqSourceSpan {

View file

@ -115,7 +115,7 @@ impl MaybeParse<Kw> for SelIdent {
let Token { span, kind } = none_up!(env.lxr.next())?; let Token { span, kind } = none_up!(env.lxr.next())?;
if let Tok::Ident(name) = kind { if let Tok::Ident(name) = kind {
match env.lookup(&*name) { match env.lookup(&name) {
Some(dbidx) => Ok(Some(SelIdent { span, dbidx })), Some(dbidx) => Ok(Some(SelIdent { span, dbidx })),
None => Err(parser::Error { None => Err(parser::Error {
span, span,

View file

@ -410,7 +410,7 @@ impl Expr {
}; };
i.simplify()?; i.simplify()?;
kvs.push((pat.clone(), span.0.offset(), i.clone())); kvs.push((pat.clone(), span.0.offset(), i.clone()));
lam_t = (&**exp).clone(); lam_t = (**exp).clone();
lam_t.simplify()?; lam_t.simplify()?;
} }
return Expr::LetBind { return Expr::LetBind {

View file

@ -13,7 +13,7 @@ fn main() -> miette::Result<()> {
for i in std::env::args().skip(1) { for i in std::env::args().skip(1) {
println!("=== {}", i); println!("=== {}", i);
let fh = read_from_file(std::fs::File::open(&i)).expect("unable to open example file"); let fh = read_from_file(std::fs::File::open(&i)).expect("unable to open example file");
let code = core::str::from_utf8(&*fh).expect("unable to parse example file (UTF-8)"); let code = core::str::from_utf8(&fh).expect("unable to parse example file (UTF-8)");
let mut penv = ParseEnv::new(Lexer::new(code)); let mut penv = ParseEnv::new(Lexer::new(code));
let mut expr = ync::Expr::parse(&mut penv).map_err(|e| e.with_code(&i, code))?; let mut expr = ync::Expr::parse(&mut penv).map_err(|e| e.with_code(&i, code))?;
println!("{:#?}", expr); println!("{:#?}", expr);