collapsible_match
This commit is contained in:
parent
657376858f
commit
4184c6af0d
@ -169,7 +169,6 @@ new_ret_no_self = "allow"
|
||||
## Following lints should be tackled at some point
|
||||
borrowed_box = "allow"
|
||||
borrow_deref_ref = "allow"
|
||||
collapsible_match = "allow"
|
||||
clone_on_copy = "allow"
|
||||
derivable_impls = "allow"
|
||||
derived_hash_with_manual_eq = "allow"
|
||||
|
@ -334,12 +334,10 @@ impl InferenceContext<'_> {
|
||||
match &self.body[tgt_expr] {
|
||||
Expr::Path(p) => {
|
||||
let resolver = resolver_for_expr(self.db.upcast(), self.owner, tgt_expr);
|
||||
if let Some(r) = resolver.resolve_path_in_value_ns(self.db.upcast(), p) {
|
||||
if let ResolveValueResult::ValueNs(v, _) = r {
|
||||
if let ValueNs::LocalBinding(b) = v {
|
||||
return Some(HirPlace { local: b, projections: vec![] });
|
||||
}
|
||||
}
|
||||
if let Some(ResolveValueResult::ValueNs(ValueNs::LocalBinding(b), _)) =
|
||||
resolver.resolve_path_in_value_ns(self.db.upcast(), p)
|
||||
{
|
||||
return Some(HirPlace { local: b, projections: vec![] });
|
||||
}
|
||||
}
|
||||
Expr::Field { expr, name: _ } => {
|
||||
|
@ -1387,10 +1387,7 @@ impl Evaluator<'_> {
|
||||
| CastKind::PointerFromExposedAddress => {
|
||||
let current_ty = self.operand_ty(operand, locals)?;
|
||||
let is_signed = match current_ty.kind(Interner) {
|
||||
TyKind::Scalar(s) => match s {
|
||||
chalk_ir::Scalar::Int(_) => true,
|
||||
_ => false,
|
||||
},
|
||||
TyKind::Scalar(chalk_ir::Scalar::Int(_)) => true,
|
||||
_ => false,
|
||||
};
|
||||
let current = pad16(self.eval_operand(operand, locals)?.get(self)?, is_signed);
|
||||
|
@ -160,57 +160,53 @@ impl MirLowerCtx<'_> {
|
||||
_ => try_rvalue(self),
|
||||
}
|
||||
}
|
||||
Expr::UnaryOp { expr, op } => match op {
|
||||
hir_def::hir::UnaryOp::Deref => {
|
||||
let is_builtin = match self.expr_ty_without_adjust(*expr).kind(Interner) {
|
||||
TyKind::Ref(..) | TyKind::Raw(..) => true,
|
||||
TyKind::Adt(id, _) => {
|
||||
if let Some(lang_item) = self.db.lang_attr(id.0.into()) {
|
||||
lang_item == LangItem::OwnedBox
|
||||
} else {
|
||||
false
|
||||
}
|
||||
Expr::UnaryOp { expr, op: hir_def::hir::UnaryOp::Deref } => {
|
||||
let is_builtin = match self.expr_ty_without_adjust(*expr).kind(Interner) {
|
||||
TyKind::Ref(..) | TyKind::Raw(..) => true,
|
||||
TyKind::Adt(id, _) => {
|
||||
if let Some(lang_item) = self.db.lang_attr(id.0.into()) {
|
||||
lang_item == LangItem::OwnedBox
|
||||
} else {
|
||||
false
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
if !is_builtin {
|
||||
let Some((p, current)) = self.lower_expr_as_place(current, *expr, true)?
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
return self.lower_overloaded_deref(
|
||||
current,
|
||||
p,
|
||||
self.expr_ty_after_adjustments(*expr),
|
||||
self.expr_ty_without_adjust(expr_id),
|
||||
expr_id.into(),
|
||||
'b: {
|
||||
if let Some((f, _)) = self.infer.method_resolution(expr_id) {
|
||||
if let Some(deref_trait) =
|
||||
self.resolve_lang_item(LangItem::DerefMut)?.as_trait()
|
||||
{
|
||||
if let Some(deref_fn) = self
|
||||
.db
|
||||
.trait_data(deref_trait)
|
||||
.method_by_name(&name![deref_mut])
|
||||
{
|
||||
break 'b deref_fn == f;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
},
|
||||
);
|
||||
}
|
||||
let Some((mut r, current)) = self.lower_expr_as_place(current, *expr, true)?
|
||||
else {
|
||||
_ => false,
|
||||
};
|
||||
if !is_builtin {
|
||||
let Some((p, current)) = self.lower_expr_as_place(current, *expr, true)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
r = r.project(ProjectionElem::Deref, &mut self.result.projection_store);
|
||||
Ok(Some((r, current)))
|
||||
return self.lower_overloaded_deref(
|
||||
current,
|
||||
p,
|
||||
self.expr_ty_after_adjustments(*expr),
|
||||
self.expr_ty_without_adjust(expr_id),
|
||||
expr_id.into(),
|
||||
'b: {
|
||||
if let Some((f, _)) = self.infer.method_resolution(expr_id) {
|
||||
if let Some(deref_trait) =
|
||||
self.resolve_lang_item(LangItem::DerefMut)?.as_trait()
|
||||
{
|
||||
if let Some(deref_fn) = self
|
||||
.db
|
||||
.trait_data(deref_trait)
|
||||
.method_by_name(&name![deref_mut])
|
||||
{
|
||||
break 'b deref_fn == f;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
},
|
||||
);
|
||||
}
|
||||
_ => try_rvalue(self),
|
||||
},
|
||||
let Some((mut r, current)) = self.lower_expr_as_place(current, *expr, true)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
r = r.project(ProjectionElem::Deref, &mut self.result.projection_store);
|
||||
Ok(Some((r, current)))
|
||||
}
|
||||
Expr::UnaryOp { .. } => try_rvalue(self),
|
||||
Expr::Field { expr, .. } => {
|
||||
let Some((mut r, current)) = self.lower_expr_as_place(current, *expr, true)? else {
|
||||
return Ok(None);
|
||||
|
@ -331,10 +331,8 @@ impl MirLowerCtx<'_> {
|
||||
break 'b (c, x.1);
|
||||
}
|
||||
}
|
||||
if let ResolveValueResult::ValueNs(v, _) = pr {
|
||||
if let ValueNs::ConstId(c) = v {
|
||||
break 'b (c, Substitution::empty(Interner));
|
||||
}
|
||||
if let ResolveValueResult::ValueNs(ValueNs::ConstId(c), _) = pr {
|
||||
break 'b (c, Substitution::empty(Interner));
|
||||
}
|
||||
not_supported!("path in pattern position that is not const or variant")
|
||||
};
|
||||
|
@ -796,8 +796,7 @@ fn classify_name_ref(
|
||||
ast::AssocTypeArg(arg) => {
|
||||
let trait_ = ast::PathSegment::cast(arg.syntax().parent()?.parent()?)?;
|
||||
match sema.resolve_path(&trait_.parent_path().top_path())? {
|
||||
hir::PathResolution::Def(def) => match def {
|
||||
hir::ModuleDef::Trait(trait_) => {
|
||||
hir::PathResolution::Def(hir::ModuleDef::Trait(trait_)) => {
|
||||
let arg_name = arg.name_ref()?;
|
||||
let arg_name = arg_name.text();
|
||||
let trait_items = trait_.items_with_supertraits(sema.db);
|
||||
@ -810,8 +809,6 @@ fn classify_name_ref(
|
||||
})?;
|
||||
sema.source(*assoc_ty)?.value.generic_param_list()
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user