cargo clippy
This commit is contained in:
parent
48e02e1f4e
commit
5f59c109be
6 changed files with 34 additions and 54 deletions
|
@ -279,15 +279,9 @@ fn derive_functor_enum(
|
|||
)
|
||||
})
|
||||
.collect();
|
||||
let apply =
|
||||
fields
|
||||
.named
|
||||
.iter()
|
||||
.zip(args.clone().into_iter())
|
||||
.map(|(field, arg)| {
|
||||
let apply = fields.named.iter().zip(args.clone()).map(|(field, arg)| {
|
||||
let name = &field.ident;
|
||||
if let Some(function_name) = match_type_param(generic_types, &field.ty)
|
||||
{
|
||||
if let Some(function_name) = match_type_param(generic_types, &field.ty) {
|
||||
if as_ref {
|
||||
quote! { #name: #function_name(&#arg) }
|
||||
} else {
|
||||
|
@ -297,11 +291,7 @@ fn derive_functor_enum(
|
|||
quote! { #name: #arg }
|
||||
}
|
||||
});
|
||||
let args = fields
|
||||
.named
|
||||
.iter()
|
||||
.zip(args.into_iter())
|
||||
.map(|(field, arg)| {
|
||||
let args = fields.named.iter().zip(args).map(|(field, arg)| {
|
||||
let name = &field.ident;
|
||||
quote! { #name:#arg }
|
||||
});
|
||||
|
|
|
@ -102,9 +102,9 @@ fn parse_minexpr(env: &mut ParseEnv<'_>) -> Result<Expr, Perr> {
|
|||
Tok::Mu => {
|
||||
let pat = FullPattern::parse(env)?;
|
||||
env.lxr.expect(Tok::RArr, "mu")?;
|
||||
let inner_start = usize::try_from(env.lxr.offset()).unwrap();
|
||||
let inner_start = env.lxr.offset();
|
||||
let inner = Box::new(pat.pat.in_this_penv(env, Expr::parse)?);
|
||||
let inner_end = usize::try_from(env.lxr.offset()).unwrap();
|
||||
let inner_end = env.lxr.offset();
|
||||
return Ok(Expr::SelfRecur {
|
||||
pat,
|
||||
inner_span: (inner_start..inner_end).into(),
|
||||
|
|
|
@ -31,10 +31,6 @@ impl cmp::PartialEq for EvEqSourceSpan {
|
|||
fn eq(&self, _: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
#[inline(always)]
|
||||
fn ne(&self, _: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(usize, usize)> for EvEqSourceSpan {
|
||||
|
|
|
@ -48,7 +48,7 @@ impl PatternTrait for Pattern {
|
|||
F: FnMut(&str, Offset) -> Result<(), E>,
|
||||
{
|
||||
match self {
|
||||
Pattern::Ident(i, offs) => f(&i, *offs),
|
||||
Pattern::Ident(i, offs) => f(i, *offs),
|
||||
Pattern::Record(xs) => xs.fields[..]
|
||||
.iter()
|
||||
.try_for_each(|i| i.1.foreach_exports(f)),
|
||||
|
@ -60,7 +60,8 @@ impl PatternTrait for Pattern {
|
|||
impl Pattern {
|
||||
pub fn push_to_penv(&self, env: &mut ParseEnv<'_>) {
|
||||
self.foreach_exports::<Infallible, _>(&mut |i, _| {
|
||||
Ok(env.names.push(i.to_string().into_boxed_str()))
|
||||
env.names.push(i.to_string().into_boxed_str());
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ impl Pattern {
|
|||
pub fn extract_exports(&self, outp: &mut Vec<Box<str>>) -> Result<(), Perr> {
|
||||
self.foreach_exports::<Perr, _>(&mut |i, loc| {
|
||||
let i2 = i.to_string().into_boxed_str();
|
||||
if outp.iter().find(|&j| i == &**j).is_some() {
|
||||
if outp.iter().any(|j| i == &**j) {
|
||||
Err(Perr {
|
||||
offset: usize::try_from(loc).unwrap(),
|
||||
kind: Pek::PatDupIdent(i2),
|
||||
|
@ -199,9 +200,9 @@ impl MaybeParse for FullPattern {
|
|||
}
|
||||
|
||||
let pty = if env.lxr.got(Tok::DubColon).is_some() {
|
||||
let start_loc = usize::try_from(env.lxr.offset()).unwrap();
|
||||
let start_loc = env.lxr.offset();
|
||||
let ptyx = Expr::parse(env)?;
|
||||
let end_loc = usize::try_from(env.lxr.offset()).unwrap();
|
||||
let end_loc = env.lxr.offset();
|
||||
Some(Box::new(((start_loc..end_loc).into(), ptyx)))
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -33,11 +33,7 @@ impl<T: Parse> MaybeParse for Record<T> {
|
|||
|
||||
if let Tok::DotIdent(i) = kind {
|
||||
if env.lxr.expect(Tok::Assign, "record =").is_ok() {
|
||||
if fields
|
||||
.iter()
|
||||
.find(|(j, _)| j.as_ref() == Some(&i))
|
||||
.is_some()
|
||||
{
|
||||
if fields.iter().any(|(j, _)| j.as_ref() == Some(&i)) {
|
||||
env.lxr = lxrbak;
|
||||
return Err(Perr {
|
||||
offset: usize::try_from(offset).unwrap(),
|
||||
|
|
|
@ -239,7 +239,7 @@ impl Expr {
|
|||
let ret = (|| {
|
||||
for (pat, offs, value) in &mut *kvs {
|
||||
let offs = *offs;
|
||||
if let Some((pty_span, pty)) = pat.pty.as_ref().map(|x| &**x) {
|
||||
if let Some((pty_span, pty)) = pat.pty.as_deref() {
|
||||
value.type_check((offs..offs).into(), ctx, pty, *pty_span)?;
|
||||
} else {
|
||||
// the location here is bit weird, but we don't want to irritate the user too much...
|
||||
|
@ -332,14 +332,11 @@ impl Expr {
|
|||
pat.push_to_tyctx(ctx);
|
||||
let tmp = exp.type_infer(ctx);
|
||||
pat.pop_from_tyctx(ctx);
|
||||
Ok(match tmp? {
|
||||
None => None,
|
||||
Some(tmp) => Some(Expr::TyLambda {
|
||||
Ok(tmp?.map(|tmp| Expr::TyLambda {
|
||||
pat: pat.clone(),
|
||||
body_span: *body_span,
|
||||
exp: Box::new(tmp),
|
||||
}),
|
||||
})
|
||||
}))
|
||||
}
|
||||
Expr::TyLambda {
|
||||
pat,
|
||||
|
@ -364,7 +361,7 @@ impl Expr {
|
|||
let tmp = inner.type_infer(ctx);
|
||||
pat.pop_from_tyctx(ctx);
|
||||
let tmp = tmp?;
|
||||
if let (Some((loc, x)), Some(y)) = (pat.pty.as_ref().map(|x| &**x), &tmp) {
|
||||
if let (Some((loc, x)), Some(y)) = (pat.pty.as_deref(), &tmp) {
|
||||
if x != y {
|
||||
return Err(Error::TypesMismatch {
|
||||
cases: vec![(loc.into(), x.clone()), ((*inner_span).into(), y.clone())],
|
||||
|
@ -378,7 +375,7 @@ impl Expr {
|
|||
let ret = (|| {
|
||||
for (pat, offs, value) in &mut *kvs {
|
||||
let offs = *offs;
|
||||
if let Some((pty_span, pty)) = pat.pty.as_ref().map(|x| &**x) {
|
||||
if let Some((pty_span, pty)) = pat.pty.as_deref() {
|
||||
value.type_check((offs..offs).into(), ctx, pty, *pty_span)?;
|
||||
} else {
|
||||
// the location here is bit weird, but we don't want to irritate the user too much...
|
||||
|
@ -479,7 +476,7 @@ impl Expr {
|
|||
return Err(Error::InvalidSelect { span, ty: pt });
|
||||
}
|
||||
Expr::TyRecord(rcd) => {
|
||||
if let Some(ty) = rcd.lookup(RecordEntry::Name(&i)) {
|
||||
if let Some(ty) = rcd.lookup(RecordEntry::Name(i)) {
|
||||
pt = ty.clone();
|
||||
} else {
|
||||
return Err(Error::SelectNotFoundTy {
|
||||
|
|
Loading…
Reference in a new issue