From 4ccf7bac46e81ebdb040f6efe5ee354f8bcce084 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Mon, 20 Jul 2020 23:21:54 +0200 Subject: [PATCH] Fix clippy warnings --- chalk-engine/src/logic.rs | 27 ++++++------ chalk-engine/src/normalize_deep.rs | 5 +-- chalk-engine/src/slg.rs | 6 +-- chalk-engine/src/slg/aggregate.rs | 4 +- chalk-engine/src/solve.rs | 8 ++-- chalk-integration/src/lowering.rs | 42 +++++++------------ chalk-integration/src/program.rs | 2 +- chalk-ir/src/debug.rs | 2 +- chalk-ir/src/fold/binder_impls.rs | 5 +-- chalk-ir/src/visit.rs | 2 +- .../src/clauses/builtin_traits/copy.rs | 4 +- .../src/clauses/builtin_traits/sized.rs | 4 +- .../src/clauses/builtin_traits/unsize.rs | 18 ++++---- chalk-solve/src/clauses/program_clauses.rs | 16 +++---- chalk-solve/src/coherence/orphan.rs | 2 +- chalk-solve/src/coherence/solve.rs | 2 +- chalk-solve/src/display.rs | 2 +- chalk-solve/src/display/items.rs | 6 +-- chalk-solve/src/infer/unify.rs | 10 ++--- chalk-solve/src/rust_ir.rs | 4 +- src/main.rs | 13 +++--- 21 files changed, 78 insertions(+), 106 deletions(-) diff --git a/chalk-engine/src/logic.rs b/chalk-engine/src/logic.rs index 4f18ea279b7..68dd1c5f89d 100644 --- a/chalk-engine/src/logic.rs +++ b/chalk-engine/src/logic.rs @@ -492,13 +492,12 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore } = canonical_strand; let (infer, ex_clause) = context.instantiate_ex_clause(num_universes, &canonical_ex_clause); - let strand = Strand { + Strand { infer, ex_clause, - selected_subgoal: selected_subgoal.clone(), + selected_subgoal, last_pursued_time, - }; - strand + } }) }); match next_strand { @@ -598,7 +597,7 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore infer: strand.infer.clone(), ex_clause: strand.ex_clause.clone(), selected_subgoal: Some(next_subgoal), - last_pursued_time: strand.last_pursued_time.clone(), + last_pursued_time: strand.last_pursued_time, }; let table = self.stack.top().table; let canonical_next_strand = Forest::canonicalize_strand(self.context, next_strand); @@ -749,7 +748,7 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore // and maybe come back to it. self.flounder_subgoal(&mut strand.ex_clause, selected_subgoal.subgoal_index); - return false; + false } Literal::Negative(_) => { // Floundering on a negative literal isn't like a @@ -771,7 +770,7 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore // This strand has no solution. It is no longer active, // so it dropped at the end of this scope. - return true; + true } } } @@ -803,7 +802,7 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore strand.ex_clause.delayed_subgoals.push(subgoal); self.stack.top().active_strand = Some(strand); - return Ok(()); + Ok(()) } Literal::Negative(_) => { // We don't allow coinduction for negative literals @@ -961,7 +960,7 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore return NoRemainingSubgoalsResult::RootSearchFail(RootSearchFail::QuantumExceeded); } } - let floundered = strand.ex_clause.floundered_subgoals.len() > 0; + let floundered = !strand.ex_clause.floundered_subgoals.is_empty(); if floundered { debug!("all remaining subgoals floundered for the table"); } else { @@ -978,7 +977,7 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore match self.stack.pop_and_take_caller_strand() { Some(caller_strand) => { self.stack.top().active_strand = Some(caller_strand); - return NoRemainingSubgoalsResult::Success; + NoRemainingSubgoalsResult::Success } None => { // That was the root table, so we are done -- @@ -997,9 +996,9 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore self.forest.tables[table].enqueue_strand(strand); } - return NoRemainingSubgoalsResult::RootAnswerAvailable; + NoRemainingSubgoalsResult::RootAnswerAvailable } - }; + } } None => { debug!("answer is not available (or not new)"); @@ -1010,9 +1009,9 @@ impl<'forest, I: Interner, C: Context + 'forest, CO: ContextOps + 'fore // Now we yield with `QuantumExceeded` self.unwind_stack(); - return NoRemainingSubgoalsResult::RootSearchFail(RootSearchFail::QuantumExceeded); + NoRemainingSubgoalsResult::RootSearchFail(RootSearchFail::QuantumExceeded) } - }; + } } /// A "refinement" strand is used in coinduction. When the root diff --git a/chalk-engine/src/normalize_deep.rs b/chalk-engine/src/normalize_deep.rs index d31a2cf9e5e..6e37d6f7b7d 100644 --- a/chalk-engine/src/normalize_deep.rs +++ b/chalk-engine/src/normalize_deep.rs @@ -28,10 +28,7 @@ impl DeepNormalizer<'_, '_, I> { ) -> T::Result { value .fold_with( - &mut DeepNormalizer { - interner, - table: table, - }, + &mut DeepNormalizer { interner, table }, DebruijnIndex::INNERMOST, ) .unwrap() diff --git a/chalk-engine/src/slg.rs b/chalk-engine/src/slg.rs index 25890e8bdd3..640f12cc3ad 100644 --- a/chalk-engine/src/slg.rs +++ b/chalk-engine/src/slg.rs @@ -34,11 +34,11 @@ pub(crate) struct SlgContextOps<'me, I: Interner> { } impl SlgContextOps<'_, I> { - pub(crate) fn new<'p>( - program: &'p dyn RustIrDatabase, + pub(crate) fn new( + program: &dyn RustIrDatabase, max_size: usize, expected_answers: Option, - ) -> SlgContextOps<'p, I> { + ) -> SlgContextOps<'_, I> { SlgContextOps { program, max_size, diff --git a/chalk-engine/src/slg/aggregate.rs b/chalk-engine/src/slg/aggregate.rs index 8cd7881b592..d2387538cc0 100644 --- a/chalk-engine/src/slg/aggregate.rs +++ b/chalk-engine/src/slg/aggregate.rs @@ -307,7 +307,7 @@ impl AntiUnifier<'_, '_, I> { if index1 != index2 { self.new_ty_variable() } else { - TyData::Placeholder(index1.clone()).intern(interner) + TyData::Placeholder(*index1).intern(interner) } } @@ -465,7 +465,7 @@ impl AntiUnifier<'_, '_, I> { } (ConstValue::BoundVar(_), _) | (_, ConstValue::BoundVar(_)) => { - self.new_const_variable(ty.clone()) + self.new_const_variable(ty) } (ConstValue::Placeholder(_), ConstValue::Placeholder(_)) => { diff --git a/chalk-engine/src/solve.rs b/chalk-engine/src/solve.rs index 49c728cb492..3f7c9ed12ce 100644 --- a/chalk-engine/src/solve.rs +++ b/chalk-engine/src/solve.rs @@ -63,12 +63,10 @@ impl Solver for SLGSolver { AnswerResult::Answer(answer) => { if !answer.ambiguous { SubstitutionResult::Definite(answer.subst) + } else if ops.is_trivial_constrained_substitution(&answer.subst) { + SubstitutionResult::Floundered } else { - if ops.is_trivial_constrained_substitution(&answer.subst) { - SubstitutionResult::Floundered - } else { - SubstitutionResult::Ambiguous(answer.subst) - } + SubstitutionResult::Ambiguous(answer.subst) } } AnswerResult::Floundered => SubstitutionResult::Floundered, diff --git a/chalk-integration/src/lowering.rs b/chalk-integration/src/lowering.rs index aed2f9b4343..9573cd52324 100644 --- a/chalk-integration/src/lowering.rs +++ b/chalk-integration/src/lowering.rs @@ -140,7 +140,7 @@ impl<'k> Env<'k> { }); } else { return Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy { - name: chalk_ir::TypeName::FnDef(id.clone()), + name: chalk_ir::TypeName::FnDef(*id), substitution: chalk_ir::Substitution::empty(interner), }) .intern(interner) @@ -158,7 +158,7 @@ impl<'k> Env<'k> { }); } else { return Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy { - name: chalk_ir::TypeName::Closure(id.clone()), + name: chalk_ir::TypeName::Closure(*id), // See note in `program`. Unlike rustc, we store upvars separately. substitution: chalk_ir::Substitution::empty(interner), }) @@ -526,7 +526,7 @@ impl LowerProgram for Program { trait_id: TraitId(raw_id), id: lookup.id, name: assoc_ty_defn.name.str.clone(), - binders: binders, + binders, }), ); } @@ -1418,10 +1418,10 @@ trait LowerQuantifiedInlineBoundVec { impl LowerQuantifiedInlineBoundVec for [QuantifiedInlineBound] { fn lower(&self, env: &Env) -> LowerResult>> { fn trait_identifier(bound: &InlineBound) -> &Identifier { - return match bound { + match bound { InlineBound::TraitBound(tb) => &tb.trait_name, InlineBound::AliasEqBound(ab) => &ab.trait_bound.trait_name, - }; + } } let mut regular_traits = Vec::new(); @@ -1505,10 +1505,7 @@ impl LowerProjectionTy for ProjectionTy { trait_id, substitution: trait_substitution, } = trait_ref.lower(env)?; - let lookup = match env - .associated_ty_lookups - .get(&(trait_id.into(), name.str.clone())) - { + let lookup = match env.associated_ty_lookups.get(&(trait_id, name.str.clone())) { Some(lookup) => lookup, None => Err(RustIrError::MissingAssociatedType(self.name.clone()))?, }; @@ -1681,7 +1678,7 @@ impl LowerTy for Ty { .intern(interner)), Ty::Scalar { ty } => Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy { - name: chalk_ir::TypeName::Scalar(ast_scalar_to_chalk_scalar(ty.clone())), + name: chalk_ir::TypeName::Scalar(ast_scalar_to_chalk_scalar(*ty)), substitution: chalk_ir::Substitution::empty(interner), }) .intern(interner)), @@ -1708,9 +1705,7 @@ impl LowerTy for Ty { .intern(interner)), Ty::Raw { mutability, ty } => Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy { - name: chalk_ir::TypeName::Raw(ast_mutability_to_chalk_mutability( - mutability.clone(), - )), + name: chalk_ir::TypeName::Raw(ast_mutability_to_chalk_mutability(*mutability)), substitution: chalk_ir::Substitution::from_fallible( interner, std::iter::once(Ok(ty.lower(env)?)), @@ -1723,9 +1718,7 @@ impl LowerTy for Ty { lifetime, ty, } => Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy { - name: chalk_ir::TypeName::Ref(ast_mutability_to_chalk_mutability( - mutability.clone(), - )), + name: chalk_ir::TypeName::Ref(ast_mutability_to_chalk_mutability(*mutability)), substitution: chalk_ir::Substitution::from_iter( interner, &[ @@ -1772,9 +1765,7 @@ impl LowerConst for Const { } Const::Value(value) => Ok(chalk_ir::ConstData { ty: get_type_of_u32(), - value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { - interned: value.clone(), - }), + value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: *value }), } .intern(interner)), } @@ -1807,14 +1798,13 @@ impl LowerLifetime for Lifetime { match self { Lifetime::Id { name } => { let parameter = env.lookup_generic_arg(&name)?; - parameter - .lifetime(interner) - .map(|l| l.clone()) - .ok_or_else(|| RustIrError::IncorrectParameterKind { + parameter.lifetime(interner).copied().ok_or_else(|| { + RustIrError::IncorrectParameterKind { identifier: name.clone(), expected: Kind::Lifetime, actual: parameter.kind(), - }) + } + }) } } } @@ -1957,7 +1947,7 @@ impl LowerTrait for TraitDefn { let trait_datum = rust_ir::TraitDatum { id: trait_id, - binders: binders, + binders, flags: self.flags.lower(), associated_ty_ids, well_known: self.well_known.map(|t| t.lower()), @@ -2038,7 +2028,7 @@ impl<'k> LowerGoal> for Goal { // in the assumptions of an `if` goal, e.g. `if (T: Trait) { ... }` lowers to // `if (FromEnv(T: Trait)) { ... /* this part is untouched */ ... }`. let where_clauses = hyp - .into_iter() + .iter() .flat_map(|h| h.lower_clause(env).apply_result()) .map(|result| result.map(|h| h.into_from_env_clause(interner))); let where_clauses = diff --git a/chalk-integration/src/program.rs b/chalk-integration/src/program.rs index be2ee21b203..9bf1f770005 100644 --- a/chalk-integration/src/program.rs +++ b/chalk-integration/src/program.rs @@ -416,7 +416,7 @@ impl RustIrDatabase for Program { } fn well_known_trait_id(&self, well_known_trait: WellKnownTrait) -> Option> { - self.well_known_traits.get(&well_known_trait).map(|x| *x) + self.well_known_traits.get(&well_known_trait).copied() } fn program_clauses_for_env( diff --git a/chalk-ir/src/debug.rs b/chalk-ir/src/debug.rs index 12d169ac3ac..7c2f21853cd 100644 --- a/chalk-ir/src/debug.rs +++ b/chalk-ir/src/debug.rs @@ -655,7 +655,7 @@ pub struct Angle<'a, T>(pub &'a [T]); impl<'a, T: Debug> Debug for Angle<'a, T> { fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> { - if self.0.len() > 0 { + if !self.0.is_empty() { write!(fmt, "<")?; for (index, elem) in self.0.iter().enumerate() { if index > 0 { diff --git a/chalk-ir/src/fold/binder_impls.rs b/chalk-ir/src/fold/binder_impls.rs index fca122d6900..1f751f16caa 100644 --- a/chalk-ir/src/fold/binder_impls.rs +++ b/chalk-ir/src/fold/binder_impls.rs @@ -87,9 +87,6 @@ where let binders = CanonicalVarKinds { interned: TI::transfer_canonical_var_kinds(self_binders.interned().clone()), }; - Ok(Canonical { - binders: binders, - value: value, - }) + Ok(Canonical { binders, value }) } } diff --git a/chalk-ir/src/visit.rs b/chalk-ir/src/visit.rs index 06f3ca4d038..7612807dd6f 100644 --- a/chalk-ir/src/visit.rs +++ b/chalk-ir/src/visit.rs @@ -53,7 +53,7 @@ pub trait VisitResult: Sized { /// Unit type for a visitor indicates a "side-effecting" visitor that /// should visit an entire term. impl VisitResult for () { - fn new() -> () {} + fn new() -> Self {} fn return_early(&self) -> bool { false diff --git a/chalk-solve/src/clauses/builtin_traits/copy.rs b/chalk-solve/src/clauses/builtin_traits/copy.rs index 7642ef15781..81df1ac2fb2 100644 --- a/chalk-solve/src/clauses/builtin_traits/copy.rs +++ b/chalk-solve/src/clauses/builtin_traits/copy.rs @@ -58,11 +58,11 @@ pub fn add_copy_program_clauses( let upvars = upvars.substitute(db.interner(), &closure_fn_substitution); needs_impl_for_tys(db, builder, trait_ref, Some(upvars).into_iter()); } - _ => return, + _ => {} }, TyData::Function(_) => builder.push_fact(trait_ref.clone()), // TODO(areredify) // when #368 lands, extend this to handle everything accordingly - _ => return, + _ => {} }; } diff --git a/chalk-solve/src/clauses/builtin_traits/sized.rs b/chalk-solve/src/clauses/builtin_traits/sized.rs index c49a018d979..90fd6b56255 100644 --- a/chalk-solve/src/clauses/builtin_traits/sized.rs +++ b/chalk-solve/src/clauses/builtin_traits/sized.rs @@ -85,11 +85,11 @@ pub fn add_sized_program_clauses( | TypeName::Scalar(_) | TypeName::Raw(_) | TypeName::Ref(_) => builder.push_fact(trait_ref.clone()), - _ => return, + _ => {} }, TyData::Function(_) => builder.push_fact(trait_ref.clone()), // TODO(areredify) // when #368 lands, extend this to handle everything accordingly - _ => return, + _ => {} } } diff --git a/chalk-solve/src/clauses/builtin_traits/unsize.rs b/chalk-solve/src/clauses/builtin_traits/unsize.rs index c7bd4a4c17f..e2bd3f7f1e0 100644 --- a/chalk-solve/src/clauses/builtin_traits/unsize.rs +++ b/chalk-solve/src/clauses/builtin_traits/unsize.rs @@ -43,14 +43,11 @@ impl<'a, I: Interner> Visitor<'a, I> for UnsizeParameterCollector<'a, I> { fn visit_const(&mut self, constant: &Const, outer_binder: DebruijnIndex) -> Self::Result { let interner = self.interner; - match constant.data(interner).value { - ConstValue::BoundVar(bound_var) => { - // check if bound var refers to the outermost binder - if bound_var.debruijn.shifted_in() == outer_binder { - self.parameters.insert(bound_var.index); - } + if let ConstValue::BoundVar(bound_var) = constant.data(interner).value { + // check if bound var refers to the outermost binder + if bound_var.debruijn.shifted_in() == outer_binder { + self.parameters.insert(bound_var.index); } - _ => (), } } @@ -141,12 +138,11 @@ fn principal_id<'a, I: Interner>( ) -> Option> { let interner = db.interner(); - return bounds + bounds .skip_binders() .iter(interner) .filter_map(|b| b.trait_id()) - .filter(|&id| !db.trait_datum(id).is_auto_trait()) - .next(); + .find(|&id| !db.trait_datum(id).is_auto_trait()) } fn auto_trait_ids<'a, I: Interner>( @@ -384,7 +380,7 @@ pub fn add_unsize_program_clauses( let unsize_parameter_candidates = outer_binder_parameters_used(interner, &adt_tail_field); - if unsize_parameter_candidates.len() == 0 { + if unsize_parameter_candidates.is_empty() { return; } // Ensure none of the other fields mention the parameters used diff --git a/chalk-solve/src/clauses/program_clauses.rs b/chalk-solve/src/clauses/program_clauses.rs index a2eca382cb5..2f9ed502c46 100644 --- a/chalk-solve/src/clauses/program_clauses.rs +++ b/chalk-solve/src/clauses/program_clauses.rs @@ -175,7 +175,7 @@ impl ToProgramClauses for OpaqueTyDatum { // AliasEq(T<..> = !T<..>). builder.push_fact(DomainGoal::Holds( AliasEq { - alias: alias.clone(), + alias, ty: alias_placeholder_ty.clone(), } .cast(interner), @@ -243,9 +243,9 @@ fn well_formed_program_clauses<'a, I, Wc>( { let interner = builder.interner(); let appl_ty = application_ty(builder, type_name); - let ty = appl_ty.clone().intern(interner); + let ty = appl_ty.intern(interner); builder.push_clause( - WellFormed::Ty(ty.clone()), + WellFormed::Ty(ty), where_clauses .cloned() .map(|qwc| qwc.into_well_formed_goal(interner)), @@ -271,8 +271,8 @@ fn well_formed_program_clauses<'a, I, Wc>( /// /// - builder -- the clause builder. We assume all the generic types from `Foo` are in scope /// - type_name -- in our example above, the name `Foo` -fn fully_visible_program_clauses<'a, I>( - builder: &'a mut ClauseBuilder<'_, I>, +fn fully_visible_program_clauses( + builder: &mut ClauseBuilder<'_, I>, type_name: impl CastTo>, ) where I: Interner, @@ -281,7 +281,7 @@ fn fully_visible_program_clauses<'a, I>( let appl_ty = application_ty(builder, type_name); let ty = appl_ty.clone().intern(interner); builder.push_clause( - DomainGoal::IsFullyVisible(ty.clone()), + DomainGoal::IsFullyVisible(ty), appl_ty .type_parameters(interner) .map(|typ| DomainGoal::IsFullyVisible(typ).cast::>(interner)), @@ -317,7 +317,7 @@ fn implied_bounds_program_clauses<'a, I, Wc>( { let interner = builder.interner(); let appl_ty = application_ty(builder, type_name); - let ty = appl_ty.clone().intern(interner); + let ty = appl_ty.intern(interner); for qwc in where_clauses { builder.push_binders(&qwc, |builder, wc| { @@ -723,7 +723,7 @@ impl ToProgramClauses for TraitDatum { // ``` // Implemented(T: Foo) :- FromEnv(T: Foo) // ``` - builder.push_clause(trait_ref.clone(), Some(trait_ref.clone().from_env())); + builder.push_clause(trait_ref.clone(), Some(trait_ref.from_env())); }); } } diff --git a/chalk-solve/src/coherence/orphan.rs b/chalk-solve/src/coherence/orphan.rs index 116dfa0cb29..d4df4632e2b 100644 --- a/chalk-solve/src/coherence/orphan.rs +++ b/chalk-solve/src/coherence/orphan.rs @@ -37,7 +37,7 @@ pub fn perform_orphan_check, SC: Into>( if !is_allowed { let trait_id = impl_datum.trait_id(); - Err(CoherenceError::FailedOrphanCheck(trait_id))?; + return Err(CoherenceError::FailedOrphanCheck(trait_id)); } Ok(()) diff --git a/chalk-solve/src/coherence/solve.rs b/chalk-solve/src/coherence/solve.rs index 2ce13c9abb8..f144e1cb04f 100644 --- a/chalk-solve/src/coherence/solve.rs +++ b/chalk-solve/src/coherence/solve.rs @@ -41,7 +41,7 @@ impl, SC: Into + Copy> CoherenceSolver<'_, I, S, SC (true, false) => record_specialization(l_id, r_id), (false, true) => record_specialization(r_id, l_id), (_, _) => { - Err(CoherenceError::OverlappingImpls(self.trait_id))?; + return Err(CoherenceError::OverlappingImpls(self.trait_id)); } } } diff --git a/chalk-solve/src/display.rs b/chalk-solve/src/display.rs index 1e422b0fdf1..ec99d1c9741 100644 --- a/chalk-solve/src/display.rs +++ b/chalk-solve/src/display.rs @@ -31,7 +31,7 @@ where I: Interner, T: RenderAsRust, { - write!(f, "{}\n", v.display(ws)) + writeln!(f, "{}", v.display(ws)) } /// Writes stubs for items which were referenced by name, but for which we diff --git a/chalk-solve/src/display/items.rs b/chalk-solve/src/display/items.rs index 86ee19a8f39..e9b83e84a73 100644 --- a/chalk-solve/src/display/items.rs +++ b/chalk-solve/src/display/items.rs @@ -179,7 +179,7 @@ impl RenderAsRust for TraitDatum { // object safe if s.db.is_object_safe(self.id) { - write!(f, "#[object_safe]\n")?; + writeln!(f, "#[object_safe]")?; } // well-known @@ -194,7 +194,7 @@ impl RenderAsRust for TraitDatum { WellKnownTrait::Fn => "fn", WellKnownTrait::Unsize => "unsize", }; - write!(f, "#[lang({})]\n", name)?; + writeln!(f, "#[lang({})]", name)?; } // trait declaration @@ -240,7 +240,7 @@ impl RenderAsRust for ImplDatum { // ^^^^^^^^^^^ // impl Foo for Bar where T: Baz { } if self.impl_type == ImplType::External { - write!(f, "#[upstream]\n")?; + writeln!(f, "#[upstream]")?; } // impl keyword diff --git a/chalk-solve/src/infer/unify.rs b/chalk-solve/src/infer/unify.rs index 3113ada4690..57b76d5b556 100644 --- a/chalk-solve/src/infer/unify.rs +++ b/chalk-solve/src/infer/unify.rs @@ -53,8 +53,8 @@ impl<'t, I: Interner> Unifier<'t, I> { environment: &'t Environment, ) -> Self { Unifier { - environment: environment, - table: table, + environment, + table, goals: vec![], interner, } @@ -475,11 +475,7 @@ impl<'t, I: Interner> Unifier<'t, I> { )); self.goals.push(InEnvironment::new( self.environment, - WhereClause::LifetimeOutlives(LifetimeOutlives { - a: b.clone(), - b: a.clone(), - }) - .cast(self.interner), + WhereClause::LifetimeOutlives(LifetimeOutlives { a: b, b: a }).cast(self.interner), )); } } diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index 95e40347147..74fdd85b4d7 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -164,7 +164,7 @@ impl Visit for FnDefDatum { if result.return_early() { return result; } - return result.combine(self.binders.visit_with(visitor, outer_binder)); + result.combine(self.binders.visit_with(visitor, outer_binder)) } } @@ -516,7 +516,7 @@ impl Visit for AssociatedTyDatum { if result.return_early() { return result; } - return result.combine(self.binders.visit_with(visitor, outer_binder)); + result.combine(self.binders.visit_with(visitor, outer_binder)) } } diff --git a/src/main.rs b/src/main.rs index 9a8b1768c06..ca64416f4c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ use rustyline::error::ReadlineError; type Result = std::result::Result>; -const USAGE: &'static str = " +const USAGE: &str = " chalk repl Usage: @@ -140,9 +140,8 @@ fn run() -> Result<()> { // Check that a program was provided. // TODO: It's customary to print Usage info when an error like this // happens. - let prog = prog.ok_or(format!( - "error: cannot eval without a program; use `--program` to specify one." - ))?; + let prog = + prog.ok_or("error: cannot eval without a program; use `--program` to specify one.")?; // Evaluate the goal(s). If any goal returns an error, print the error // and exit. @@ -228,9 +227,9 @@ fn process( // The command is either "print", "lowered", or a goal. // Check that a program has been loaded. - let prog = prog.as_ref().ok_or(format!( - "no program currently loaded; type 'help' to see available commands" - ))?; + let prog = prog + .as_ref() + .ok_or("no program currently loaded; type 'help' to see available commands")?; // Attempt to parse the program. prog.db.with_program(|_| -> Result<()> {