Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer.rs')
| -rw-r--r-- | crates/hir-ty/src/infer.rs | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index 2aff53a4ac..c3ef6c9b35 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -88,7 +88,7 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<Infer DefWithBodyId::StaticId(s) => ctx.collect_static(&db.static_data(s)), DefWithBodyId::VariantId(v) => { ctx.return_ty = TyBuilder::builtin( - match db.enum_data(v.lookup(db.upcast()).parent.into()).variant_body_type() { + match db.enum_data(v.lookup(db.upcast()).parent).variant_body_type() { hir_def::layout::IntegerType::Pointer(signed) => match signed { true => BuiltinType::Int(BuiltinInt::Isize), false => BuiltinType::Uint(BuiltinUint::Usize), @@ -156,8 +156,9 @@ pub(crate) fn normalize(db: &dyn HirDatabase, trait_env: Arc<TraitEnvironment>, /// Binding modes inferred for patterns. /// <https://doc.rust-lang.org/reference/patterns.html#binding-modes> -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] pub enum BindingMode { + #[default] Move, Ref(Mutability), } @@ -172,12 +173,6 @@ impl BindingMode { } } -impl Default for BindingMode { - fn default() -> Self { - BindingMode::Move - } -} - #[derive(Debug)] pub(crate) struct InferOk<T> { value: T, @@ -572,10 +567,10 @@ enum BreakableKind { Border, } -fn find_breakable<'c>( - ctxs: &'c mut [BreakableContext], +fn find_breakable( + ctxs: &mut [BreakableContext], label: Option<LabelId>, -) -> Option<&'c mut BreakableContext> { +) -> Option<&mut BreakableContext> { let mut ctxs = ctxs .iter_mut() .rev() @@ -586,10 +581,10 @@ fn find_breakable<'c>( } } -fn find_continuable<'c>( - ctxs: &'c mut [BreakableContext], +fn find_continuable( + ctxs: &mut [BreakableContext], label: Option<LabelId>, -) -> Option<&'c mut BreakableContext> { +) -> Option<&mut BreakableContext> { match label { Some(_) => find_breakable(ctxs, label).filter(|it| matches!(it.kind, BreakableKind::Loop)), None => find_breakable(ctxs, label), @@ -825,8 +820,8 @@ impl<'a> InferenceContext<'a> { ImplTraitId::ReturnTypeImplTrait(_, idx) => idx, _ => unreachable!(), }; - let bounds = (*rpits) - .map_ref(|rpits| rpits.impl_traits[idx].bounds.map_ref(|it| it.into_iter())); + let bounds = + (*rpits).map_ref(|rpits| rpits.impl_traits[idx].bounds.map_ref(|it| it.iter())); let var = self.table.new_type_var(); let var_subst = Substitution::from1(Interner, var.clone()); for bound in bounds { |