diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index c3730d0bbd9..565d0c02cfe 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -521,8 +521,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "cyclic deps: {} -> {}, alternative path: {}", - render(&self.from()), - render(&self.to()), + render(self.from()), + render(self.to()), path ) } diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 36604b81cb4..a636d865025 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -339,12 +339,7 @@ fn run(self) -> io::Result { cargo_metadata::Message::CompilerMessage(msg) => { self.sender.send(CargoMessage::Diagnostic(msg.message)).unwrap() } - - cargo_metadata::Message::CompilerArtifact(_) - | cargo_metadata::Message::BuildScriptExecuted(_) - | cargo_metadata::Message::BuildFinished(_) - | cargo_metadata::Message::TextLine(_) - | _ => (), + _ => (), }, JsonMessage::Rustc(message) => { self.sender.send(CargoMessage::Diagnostic(message)).unwrap() diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs index 3a014545138..a3f4a655132 100644 --- a/crates/hir/src/has_source.rs +++ b/crates/hir/src/has_source.rs @@ -60,9 +60,9 @@ impl HasSource for Adt { type Ast = ast::Adt; fn source(self, db: &dyn HirDatabase) -> Option> { match self { - Adt::Struct(s) => Some(s.source(db)?.map(|s| ast::Adt::Struct(s))), - Adt::Union(u) => Some(u.source(db)?.map(|u| ast::Adt::Union(u))), - Adt::Enum(e) => Some(e.source(db)?.map(|e| ast::Adt::Enum(e))), + Adt::Struct(s) => Some(s.source(db)?.map(ast::Adt::Struct)), + Adt::Union(u) => Some(u.source(db)?.map(ast::Adt::Union)), + Adt::Enum(e) => Some(e.source(db)?.map(ast::Adt::Enum)), } } } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 544312f6fc3..62c634b549f 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2960,9 +2960,9 @@ pub fn krate(&self, db: &dyn HirDatabase) -> Option { impl From for ScopeDef { fn from(item: ItemInNs) -> Self { match item { - ItemInNs::Types(id) => ScopeDef::ModuleDef(id.into()), - ItemInNs::Values(id) => ScopeDef::ModuleDef(id.into()), - ItemInNs::Macros(id) => ScopeDef::MacroDef(id.into()), + ItemInNs::Types(id) => ScopeDef::ModuleDef(id), + ItemInNs::Values(id) => ScopeDef::ModuleDef(id), + ItemInNs::Macros(id) => ScopeDef::MacroDef(id), } } } diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 9f03c6467bf..06a26f89eed 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -864,7 +864,7 @@ fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool { } fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool { - if !ident_pat.ref_token().is_some() { + if ident_pat.ref_token().is_none() { return false; } diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 2f9e33b6adc..d385bcaf66f 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -264,8 +264,7 @@ fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleField) -> Field { let name = Name::new_tuple_field(idx); let visibility = self.lower_visibility(field); let type_ref = self.lower_type_ref_opt(field.ty()); - let res = Field { name, type_ref, visibility }; - res + Field { name, type_ref, visibility } } fn lower_union(&mut self, union: &ast::Union) -> Option> { diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 209eedb005c..b376f9a2531 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -384,7 +384,7 @@ fn collect(&mut self) { self.unresolved_imports.extend(partial_resolved); self.resolve_imports(); - let unresolved_imports = std::mem::replace(&mut self.unresolved_imports, Vec::new()); + let unresolved_imports = std::mem::take(&mut self.unresolved_imports); // show unresolved imports in completion, etc for directive in &unresolved_imports { self.record_resolved_import(directive) @@ -417,7 +417,7 @@ fn collect(&mut self) { fn reseed_with_unresolved_attribute(&mut self) -> ReachedFixedPoint { cov_mark::hit!(unresolved_attribute_fallback); - let mut unresolved_macros = std::mem::replace(&mut self.unresolved_macros, Vec::new()); + let mut unresolved_macros = std::mem::take(&mut self.unresolved_macros); let pos = unresolved_macros.iter().position(|directive| { if let MacroDirectiveKind::Attr { ast_id, mod_item, attr } = &directive.kind { self.skip_attrs.insert(ast_id.ast_id.with_value(*mod_item), attr.id); @@ -689,7 +689,7 @@ fn import_all_macros_exported(&mut self, current_module_id: LocalModuleId, krate /// Tries to resolve every currently unresolved import. fn resolve_imports(&mut self) -> ReachedFixedPoint { let mut res = ReachedFixedPoint::Yes; - let imports = std::mem::replace(&mut self.unresolved_imports, Vec::new()); + let imports = std::mem::take(&mut self.unresolved_imports); let imports = imports .into_iter() .filter_map(|mut directive| { @@ -1005,7 +1005,7 @@ fn update_recursive( } fn resolve_macros(&mut self) -> ReachedFixedPoint { - let mut macros = std::mem::replace(&mut self.unresolved_macros, Vec::new()); + let mut macros = std::mem::take(&mut self.unresolved_macros); let mut resolved = Vec::new(); let mut res = ReachedFixedPoint::Yes; macros.retain(|directive| { @@ -1279,13 +1279,12 @@ fn finish(mut self) -> DefMap { for directive in &self.unresolved_imports { if let ImportSource::Import { id: import, use_tree } = &directive.import.source { - match (directive.import.path.segments().first(), &directive.import.path.kind) { - (Some(krate), PathKind::Plain | PathKind::Abs) => { - if diagnosed_extern_crates.contains(krate) { - continue; - } + if let (Some(krate), PathKind::Plain | PathKind::Abs) = + (directive.import.path.segments().first(), &directive.import.path.kind) + { + if diagnosed_extern_crates.contains(krate) { + continue; } - _ => {} } self.def_map.diagnostics.push(DefDiagnostic::unresolved_import( @@ -1579,13 +1578,13 @@ fn collect_module(&mut self, module: &Mod, attrs: &Attrs) { { Ok((file_id, is_mod_rs, mod_dir)) => { let item_tree = db.file_item_tree(file_id.into()); - if item_tree + let is_enabled = item_tree .top_level_attrs(db, self.def_collector.def_map.krate) .cfg() .map_or(true, |cfg| { self.def_collector.cfg_options.check(&cfg) != Some(false) - }) - { + }); + if is_enabled { let module_id = self.push_child_module( module.name.clone(), ast_id, diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs index 052f1bf20e5..81a40185bc2 100644 --- a/crates/hir_expand/src/eager.rs +++ b/crates/hir_expand/src/eager.rs @@ -107,7 +107,7 @@ pub fn expand_eager_macro( mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError), ) -> Result { let parsed_args = diagnostic_sink.option_with( - || Some(mbe::syntax_node_to_token_tree(¯o_call.value.token_tree()?.syntax()).0), + || Some(mbe::syntax_node_to_token_tree(macro_call.value.token_tree()?.syntax()).0), || err("malformed macro invocation"), )?; diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index d26a0293db8..8723e24bf65 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs @@ -205,10 +205,7 @@ fn opaque_ty_data(&self, id: chalk_ir::OpaqueTyId) -> Arc Option { diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index f26150b77fa..ea9b54af63c 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs @@ -63,7 +63,7 @@ pub(super) fn validate_item(&mut self, item: ModuleDefId) { ModuleDefId::AdtId(adt) => self.validate_adt(adt), ModuleDefId::ConstId(const_id) => self.validate_const(const_id), ModuleDefId::StaticId(static_id) => self.validate_static(static_id), - _ => return, + _ => (), } } diff --git a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs index 6dc6e12903f..ecaa3daeafd 100644 --- a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs +++ b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs @@ -82,10 +82,10 @@ pub(super) struct IntRange { impl IntRange { #[inline] fn is_integral(ty: &Ty) -> bool { - match ty.kind(&Interner) { - TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) => true, - _ => false, - } + matches!( + ty.kind(&Interner), + TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) + ) } fn is_singleton(&self) -> bool { @@ -729,16 +729,12 @@ pub(super) fn apply(self, pcx: PatCtxt<'_>, ctor: &Constructor) -> Pat { }) .collect(); - if let Some((adt, substs)) = pcx.ty.as_adt() { - if let hir_def::AdtId::EnumId(_) = adt { - let enum_variant = match ctor { - &Variant(id) => id, - _ => unreachable!(), - }; - PatKind::Variant { substs: substs.clone(), enum_variant, subpatterns } - } else { - PatKind::Leaf { subpatterns } - } + if let Some((hir_def::AdtId::EnumId(_), substs)) = pcx.ty.as_adt() { + let enum_variant = match ctor { + &Variant(id) => id, + _ => unreachable!(), + }; + PatKind::Variant { substs: substs.clone(), enum_variant, subpatterns } } else { PatKind::Leaf { subpatterns } } diff --git a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs index 088c0b0586b..b5d238116ff 100644 --- a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs +++ b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs @@ -686,17 +686,17 @@ fn fill_subpats( SubPatSet::Empty => panic!("bug"), SubPatSet::Full => {} SubPatSet::Seq { subpats } => { - for (_, sub_set) in subpats { + for sub_set in subpats.values() { fill_subpats(sub_set, unreachable_pats, cx); } } SubPatSet::Alt { subpats, pat, alt_count, .. } => { let expanded = pat.expand_or_pat(cx); - for i in 0..*alt_count { + for (i, &expanded) in expanded.iter().enumerate().take(*alt_count) { let sub_set = subpats.get(&i).unwrap_or(&SubPatSet::Empty); if sub_set.is_empty() { // Found an unreachable subpattern. - unreachable_pats.push(expanded[i]); + unreachable_pats.push(expanded); } else { fill_subpats(sub_set, unreachable_pats, cx); } diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 91c705afb78..bce24b825c4 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -666,7 +666,7 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { let substs = generics.type_params_subst(f.db); let bounds = f.db.generic_predicates(id.parent) - .into_iter() + .iter() .map(|pred| pred.clone().substitute(&Interner, &substs)) .filter(|wc| match &wc.skip_binders() { WhereClause::Implemented(tr) => { diff --git a/crates/hir_ty/src/infer/closure.rs b/crates/hir_ty/src/infer/closure.rs index 94dcff7f2a6..d305cda70f6 100644 --- a/crates/hir_ty/src/infer/closure.rs +++ b/crates/hir_ty/src/infer/closure.rs @@ -1,6 +1,6 @@ //! Inference of closure parameter types based on the closure's expected type. -use chalk_ir::{cast::Cast, AliasTy, FnSubst, WhereClause}; +use chalk_ir::{cast::Cast, AliasEq, AliasTy, FnSubst, WhereClause}; use hir_def::{expr::ExprId, HasModule}; use smallvec::SmallVec; @@ -42,46 +42,38 @@ fn deduce_sig_from_dyn_ty(&self, dyn_ty: &DynTy) -> Option { let fn_traits: SmallVec<[ChalkTraitId; 3]> = utils::fn_traits(self.db.upcast(), self.owner.module(self.db.upcast()).krate()) - .map(|tid| to_chalk_trait_id(tid)) + .map(to_chalk_trait_id) .collect(); let self_ty = TyKind::Error.intern(&Interner); let bounds = dyn_ty.bounds.clone().substitute(&Interner, &[self_ty.cast(&Interner)]); for bound in bounds.iter(&Interner) { // NOTE(skip_binders): the extracted types are rebound by the returned `FnPointer` - match bound.skip_binders() { - WhereClause::AliasEq(eq) => match &eq.alias { - AliasTy::Projection(projection) => { - let assoc_data = self.db.associated_ty_data(projection.associated_ty_id); - if !fn_traits.contains(&assoc_data.trait_id) { - return None; - } + if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) = + bound.skip_binders() + { + let assoc_data = self.db.associated_ty_data(projection.associated_ty_id); + if !fn_traits.contains(&assoc_data.trait_id) { + return None; + } - // Skip `Self`, get the type argument. - let arg = projection.substitution.as_slice(&Interner).get(1)?; - if let Some(subst) = arg.ty(&Interner)?.as_tuple() { - let generic_args = subst.as_slice(&Interner); - let mut sig_tys = Vec::new(); - for arg in generic_args { - sig_tys.push(arg.ty(&Interner)?.clone()); - } - sig_tys.push(eq.ty.clone()); - - cov_mark::hit!(dyn_fn_param_informs_call_site_closure_signature); - return Some(FnPointer { - num_binders: bound.len(&Interner), - sig: FnSig { - abi: (), - safety: chalk_ir::Safety::Safe, - variadic: false, - }, - substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys)), - }); - } + // Skip `Self`, get the type argument. + let arg = projection.substitution.as_slice(&Interner).get(1)?; + if let Some(subst) = arg.ty(&Interner)?.as_tuple() { + let generic_args = subst.as_slice(&Interner); + let mut sig_tys = Vec::new(); + for arg in generic_args { + sig_tys.push(arg.ty(&Interner)?.clone()); } - AliasTy::Opaque(_) => {} - }, - _ => {} + sig_tys.push(ty.clone()); + + cov_mark::hit!(dyn_fn_param_informs_call_site_closure_signature); + return Some(FnPointer { + num_binders: bound.len(&Interner), + sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false }, + substitution: FnSubst(Substitution::from_iter(&Interner, sig_tys)), + }); + } } } diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index ceb5eeeccb3..ea71cdd8102 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -63,7 +63,7 @@ pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> /// Return the type after possible coercion. pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty { let ty = self.infer_expr_inner(expr, expected); - let ty = if let Some(target) = expected.only_has_type(&mut self.table) { + if let Some(target) = expected.only_has_type(&mut self.table) { match self.coerce(Some(expr), &ty, &target) { Ok(res) => res.value, Err(_) => { @@ -77,9 +77,7 @@ pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) } } else { ty - }; - - ty + } } fn callable_sig_from_fn_trait(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec, Ty)> { @@ -899,9 +897,7 @@ fn infer_overloadable_binop( if let Some(builtin_rhs) = self.builtin_binary_op_rhs_expectation(op, lhs_ty.clone()) { self.unify(&builtin_rhs, &rhs_ty); } - if let Some(builtin_ret) = - self.builtin_binary_op_return_ty(op, lhs_ty.clone(), rhs_ty.clone()) - { + if let Some(builtin_ret) = self.builtin_binary_op_return_ty(op, lhs_ty, rhs_ty) { self.unify(&builtin_ret, &ret_ty); } @@ -942,7 +938,7 @@ fn infer_block( } } - let ty = if let Some(expr) = tail { + if let Some(expr) = tail { self.infer_expr_coerce(expr, expected) } else { // Citing rustc: if there is no explicit tail expression, @@ -961,8 +957,7 @@ fn infer_block( } TyBuilder::unit() } - }; - ty + } } fn infer_method_call( @@ -1032,7 +1027,7 @@ fn expected_inputs_for_expected_output( inputs: Vec, ) -> Vec { if let Some(expected_ty) = expected_output.to_option(&mut self.table) { - let result = self.table.fudge_inference(|table| { + self.table.fudge_inference(|table| { if table.try_unify(&expected_ty, &output).is_ok() { table.resolve_with_fallback(inputs, |var, kind, _, _| match kind { chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner), @@ -1046,8 +1041,7 @@ fn expected_inputs_for_expected_output( } else { Vec::new() } - }); - result + }) } else { Vec::new() } diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 5cd760393f4..957cd829aac 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -245,8 +245,7 @@ pub(super) fn infer_pat( Pat::Wild => expected.clone(), Pat::Range { start, end } => { let start_ty = self.infer_expr(*start, &Expectation::has_type(expected.clone())); - let end_ty = self.infer_expr(*end, &Expectation::has_type(start_ty)); - end_ty + self.infer_expr(*end, &Expectation::has_type(start_ty)) } Pat::Lit(expr) => self.infer_expr(*expr, &Expectation::has_type(expected.clone())), Pat::Box { inner } => match self.resolve_boxed_box() { @@ -297,10 +296,7 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool { // FIXME: ConstBlock/Path/Lit might actually evaluate to ref, but inference is unimplemented. Pat::Path(..) => true, Pat::ConstBlock(..) => true, - Pat::Lit(expr) => match body[*expr] { - Expr::Literal(Literal::String(..)) => false, - _ => true, - }, + Pat::Lit(expr) => !matches!(body[*expr], Expr::Literal(Literal::String(..))), Pat::Bind { mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated, subpat: Some(subpat), diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index bb87e83ca05..9f1253825ef 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -460,12 +460,9 @@ fn fold_inference_const( self.new_type_var().inference_var(&Interner).expect("inference_var"); let result = f(self); self.rollback_to(snapshot); - - let result = result - .fold_with(&mut VarFudger { table: self, highest_known_var }, DebruijnIndex::INNERMOST) - .expect("fold_with with VarFudger"); - result + .fold_with(&mut VarFudger { table: self, highest_known_var }, DebruijnIndex::INNERMOST) + .expect("fold_with with VarFudger") } /// This checks whether any of the free variables in the `canonicalized` diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 8cac285cb19..0e1afe866e2 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -387,15 +387,17 @@ pub(crate) fn lower_ty_relative_path( res: Option, remaining_segments: PathSegments<'_>, ) -> (Ty, Option) { - if remaining_segments.len() == 1 { - // resolve unselected assoc types - let segment = remaining_segments.first().unwrap(); - (self.select_associated_type(res, segment), None) - } else if remaining_segments.len() > 1 { - // FIXME report error (ambiguous associated type) - (TyKind::Error.intern(&Interner), None) - } else { - (ty, res) + match remaining_segments.len() { + 0 => (ty, res), + 1 => { + // resolve unselected assoc types + let segment = remaining_segments.first().unwrap(); + (self.select_associated_type(res, segment), None) + } + _ => { + // FIXME report error (ambiguous associated type) + (TyKind::Error.intern(&Interner), None) + } } } diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 507742c22a9..a90e3bee68a 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -141,7 +141,7 @@ pub(crate) fn trait_impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) - let crate_def_map = db.crate_def_map(krate); impls.collect_def_map(db, &crate_def_map); - return Arc::new(impls); + Arc::new(impls) } pub(crate) fn trait_impls_in_block_query( @@ -154,7 +154,7 @@ pub(crate) fn trait_impls_in_block_query( let block_def_map = db.block_def_map(block)?; impls.collect_def_map(db, &block_def_map); - return Some(Arc::new(impls)); + Some(Arc::new(impls)) } fn collect_def_map(&mut self, db: &dyn HirDatabase, def_map: &DefMap) { diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 976c1308e7a..4b89fd5a853 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -130,8 +130,7 @@ fn solve( let solution = if is_chalk_print() { let logging_db = LoggingRustIrDatabaseLoggingOnDrop(LoggingRustIrDatabase::new(context)); - let solution = solver.solve_limited(&logging_db.0, goal, &should_continue); - solution + solver.solve_limited(&logging_db.0, goal, &should_continue) } else { solver.solve_limited(&context, goal, &should_continue) }; @@ -143,10 +142,11 @@ fn solve( // don't set the TLS for Chalk unless Chalk debugging is active, to make // extra sure we only use it for debugging - let solution = - if is_chalk_debug() { crate::tls::set_current_program(db, solve) } else { solve() }; - - solution + if is_chalk_debug() { + crate::tls::set_current_program(db, solve) + } else { + solve() + } } struct LoggingRustIrDatabaseLoggingOnDrop<'a>(LoggingRustIrDatabase>); diff --git a/crates/hir_ty/src/walk.rs b/crates/hir_ty/src/walk.rs index 6ef1d53368b..9cacc521d46 100644 --- a/crates/hir_ty/src/walk.rs +++ b/crates/hir_ty/src/walk.rs @@ -86,11 +86,8 @@ fn walk(&self, f: &mut impl FnMut(&Ty)) { impl TypeWalk for GenericArg { fn walk(&self, f: &mut impl FnMut(&Ty)) { - match &self.interned() { - GenericArgData::Ty(ty) => { - ty.walk(f); - } - _ => {} + if let GenericArgData::Ty(ty) = &self.interned() { + ty.walk(f); } } } diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index c2a1696b3d0..bf85186609f 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs @@ -241,7 +241,7 @@ struct Struct { field: () } "##; - let source_file = ast::SourceFile::parse(&source).ok().unwrap(); + let source_file = ast::SourceFile::parse(source).ok().unwrap(); let item = source_file.items().next().unwrap(); let attr = item.attrs().nth(1).unwrap(); @@ -258,7 +258,7 @@ struct Struct { field: () } "##; - let source_file = ast::SourceFile::parse(&source).ok().unwrap(); + let source_file = ast::SourceFile::parse(source).ok().unwrap(); let item = source_file.items().next().unwrap(); let attr = item.attrs().nth(1).unwrap();