From c22e161f7bd97d4f6c063513cc051f6af2683d84 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 17 Mar 2020 23:01:35 +0000 Subject: Run clippy --- dhall/src/semantics/resolve/env.rs | 2 +- dhall/src/semantics/resolve/hir.rs | 6 +++--- dhall/src/semantics/resolve/resolve.rs | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'dhall/src/semantics/resolve') diff --git a/dhall/src/semantics/resolve/env.rs b/dhall/src/semantics/resolve/env.rs index 5a7f139..fe8c178 100644 --- a/dhall/src/semantics/resolve/env.rs +++ b/dhall/src/semantics/resolve/env.rs @@ -51,7 +51,7 @@ impl NameEnv { .nth(*idx)?; Some(AlphaVar::new(idx)) } - pub fn label_var(&self, var: &AlphaVar) -> V { + pub fn label_var(&self, var: AlphaVar) -> V { let name = &self.names[self.names.len() - 1 - var.idx()]; let idx = self .names diff --git a/dhall/src/semantics/resolve/hir.rs b/dhall/src/semantics/resolve/hir.rs index 317708a..fa2989f 100644 --- a/dhall/src/semantics/resolve/hir.rs +++ b/dhall/src/semantics/resolve/hir.rs @@ -30,7 +30,7 @@ impl AlphaVar { pub(crate) fn new(idx: usize) -> Self { AlphaVar { idx } } - pub(crate) fn idx(&self) -> usize { + pub(crate) fn idx(self) -> usize { self.idx } } @@ -100,7 +100,7 @@ fn hir_to_expr( ) -> NormalizedExpr { let kind = match hir.kind() { HirKind::Var(v) if opts.alpha => ExprKind::Var(V("_".into(), v.idx())), - HirKind::Var(v) => ExprKind::Var(env.label_var(v)), + HirKind::Var(v) => ExprKind::Var(env.label_var(*v)), HirKind::Import(hir, _) => { return hir_to_expr(hir, opts, &mut NameEnv::new()) } @@ -110,7 +110,7 @@ fn hir_to_expr( env.insert_mut(l); } let e = hir_to_expr(hir, opts, env); - if let Some(_) = l { + if l.is_some() { env.remove_mut(); } e diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs index d29271d..f3fda4b 100644 --- a/dhall/src/semantics/resolve/resolve.rs +++ b/dhall/src/semantics/resolve/resolve.rs @@ -46,13 +46,13 @@ impl ImportLocation { ) -> Result { Ok(match target { ImportTarget::Local(prefix, path) => { - self.chain_local(prefix, path)? + self.chain_local(*prefix, path)? } ImportTarget::Remote(remote) => { if sanity_check { if let ImportLocation::Remote(..) = self { // TODO: allow if CORS check passes - Err(ImportError::SanityCheck)? + return Err(ImportError::SanityCheck.into()); } } let mut url = Url::parse(&format!( @@ -66,7 +66,7 @@ impl ImportLocation { ImportTarget::Env(var_name) => { if sanity_check { if let ImportLocation::Remote(..) = self { - Err(ImportError::SanityCheck)? + return Err(ImportError::SanityCheck.into()); } } ImportLocation::Env(var_name.clone()) @@ -77,7 +77,7 @@ impl ImportLocation { fn chain_local( &self, - prefix: &FilePrefix, + prefix: FilePrefix, path: &FilePath, ) -> Result { Ok(match self { @@ -146,11 +146,11 @@ impl ImportLocation { ImportLocation::Env(var_name) => { let val = match env::var(var_name) { Ok(val) => val, - Err(_) => Err(ImportError::MissingEnvVar)?, + Err(_) => return Err(ImportError::MissingEnvVar.into()), }; Parsed::parse_str(&val)? } - ImportLocation::Missing => Err(ImportError::Missing)?, + ImportLocation::Missing => return Err(ImportError::Missing.into()), }) } @@ -162,9 +162,9 @@ impl ImportLocation { } ImportLocation::Env(var_name) => match env::var(var_name) { Ok(val) => val, - Err(_) => Err(ImportError::MissingEnvVar)?, + Err(_) => return Err(ImportError::MissingEnvVar.into()), }, - ImportLocation::Missing => Err(ImportError::Missing)?, + ImportLocation::Missing => return Err(ImportError::Missing.into()), }) } @@ -199,7 +199,7 @@ fn make_aslocation_uniontype() -> Expr { let mut union = DupTreeMap::default(); union.insert("Local".into(), Some(text_type.clone())); union.insert("Remote".into(), Some(text_type.clone())); - union.insert("Environment".into(), Some(text_type.clone())); + union.insert("Environment".into(), Some(text_type)); union.insert("Missing".into(), None); mkexpr(ExprKind::UnionType(union)) } @@ -298,7 +298,7 @@ fn traverse_resolve_expr( name_env.insert_mut(l); } let hir = traverse_resolve_expr(name_env, e, f)?; - if let Some(_) = l { + if l.is_some() { name_env.remove_mut(); } Ok::<_, Error>(hir) @@ -395,7 +395,7 @@ impl Canonicalize for ImportTarget { authority: url.authority.clone(), path: url.path.canonicalize(), query: url.query.clone(), - headers: url.headers.clone(), + headers: url.headers, }), ImportTarget::Env(name) => ImportTarget::Env(name.to_string()), ImportTarget::Missing => ImportTarget::Missing, -- cgit v1.2.3