diff options
author | Kirill Bulatov <[email protected]> | 2020-02-18 12:53:02 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-02-18 14:03:08 +0000 |
commit | b8ddcb0652f3ec8683023afc1e1f5166d6a712f4 (patch) | |
tree | ea95a1e2083280d84e99f274e5b2b8b269545297 /crates/ra_hir_ty/src/infer/expr.rs | |
parent | eab80cd961919b9321e1d34343ae3f3adb0502e5 (diff) |
Run cargo +nightly fix --clippy -Z unstable-options
Diffstat (limited to 'crates/ra_hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 39d8bc0ca..0af94ae32 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -127,10 +127,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
127 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, | 127 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, |
128 | Substs(sig_tys.into()), | 128 | Substs(sig_tys.into()), |
129 | ); | 129 | ); |
130 | let closure_ty = Ty::apply_one( | 130 | let closure_ty = |
131 | TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr }, | 131 | Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty); |
132 | sig_ty, | ||
133 | ); | ||
134 | 132 | ||
135 | // Eagerly try to relate the closure type with the expected | 133 | // Eagerly try to relate the closure type with the expected |
136 | // type, otherwise we often won't have enough information to | 134 | // type, otherwise we often won't have enough information to |
@@ -165,7 +163,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
165 | Expr::Match { expr, arms } => { | 163 | Expr::Match { expr, arms } => { |
166 | let input_ty = self.infer_expr(*expr, &Expectation::none()); | 164 | let input_ty = self.infer_expr(*expr, &Expectation::none()); |
167 | 165 | ||
168 | let mut result_ty = if arms.len() == 0 { | 166 | let mut result_ty = if arms.is_empty() { |
169 | Ty::simple(TypeCtor::Never) | 167 | Ty::simple(TypeCtor::Never) |
170 | } else { | 168 | } else { |
171 | self.table.new_type_var() | 169 | self.table.new_type_var() |
@@ -188,7 +186,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
188 | } | 186 | } |
189 | Expr::Path(p) => { | 187 | Expr::Path(p) => { |
190 | // FIXME this could be more efficient... | 188 | // FIXME this could be more efficient... |
191 | let resolver = resolver_for_expr(self.db, self.owner.into(), tgt_expr); | 189 | let resolver = resolver_for_expr(self.db, self.owner, tgt_expr); |
192 | self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) | 190 | self.infer_path(&resolver, p, tgt_expr.into()).unwrap_or(Ty::Unknown) |
193 | } | 191 | } |
194 | Expr::Continue => Ty::simple(TypeCtor::Never), | 192 | Expr::Continue => Ty::simple(TypeCtor::Never), |
@@ -217,8 +215,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
217 | self.unify(&ty, &expected.ty); | 215 | self.unify(&ty, &expected.ty); |
218 | 216 | ||
219 | let substs = ty.substs().unwrap_or_else(Substs::empty); | 217 | let substs = ty.substs().unwrap_or_else(Substs::empty); |
220 | let field_types = | 218 | let field_types = def_id.map(|it| self.db.field_types(it)).unwrap_or_default(); |
221 | def_id.map(|it| self.db.field_types(it.into())).unwrap_or_default(); | ||
222 | let variant_data = def_id.map(|it| variant_data(self.db, it)); | 219 | let variant_data = def_id.map(|it| variant_data(self.db, it)); |
223 | for (field_idx, field) in fields.iter().enumerate() { | 220 | for (field_idx, field) in fields.iter().enumerate() { |
224 | let field_def = | 221 | let field_def = |
@@ -264,7 +261,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
264 | .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), | 261 | .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), |
265 | TypeCtor::Adt(AdtId::StructId(s)) => { | 262 | TypeCtor::Adt(AdtId::StructId(s)) => { |
266 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { | 263 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { |
267 | let field = StructFieldId { parent: s.into(), local_id }.into(); | 264 | let field = StructFieldId { parent: s.into(), local_id }; |
268 | self.write_field_resolution(tgt_expr, field); | 265 | self.write_field_resolution(tgt_expr, field); |
269 | self.db.field_types(s.into())[field.local_id] | 266 | self.db.field_types(s.into())[field.local_id] |
270 | .clone() | 267 | .clone() |
@@ -700,10 +697,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
700 | // construct a TraitDef | 697 | // construct a TraitDef |
701 | let substs = | 698 | let substs = |
702 | a_ty.parameters.prefix(generics(self.db, trait_.into()).len()); | 699 | a_ty.parameters.prefix(generics(self.db, trait_.into()).len()); |
703 | self.obligations.push(Obligation::Trait(TraitRef { | 700 | self.obligations.push(Obligation::Trait(TraitRef { trait_, substs })); |
704 | trait_: trait_.into(), | ||
705 | substs, | ||
706 | })); | ||
707 | } | 701 | } |
708 | } | 702 | } |
709 | CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {} | 703 | CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {} |