Minor cleanups

This commit is contained in:
Aleksey Kladov 2020-08-19 13:46:34 +02:00
parent 63ac896655
commit a3b0a3aeb8

View file

@ -613,14 +613,13 @@ impl<'db> SemanticsImpl<'db> {
InFile::new(file_id, node) InFile::new(file_id, node)
} }
pub fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool { fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool {
method_call_expr method_call_expr
.expr() .expr()
.and_then(|expr| { .and_then(|expr| {
let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr { let field_expr = match expr {
field_expr ast::Expr::FieldExpr(field_expr) => field_expr,
} else { _ => return None,
return None;
}; };
let ty = self.type_of_expr(&field_expr.expr()?)?; let ty = self.type_of_expr(&field_expr.expr()?)?;
if !ty.is_packed(self.db) { if !ty.is_packed(self.db) {
@ -635,7 +634,7 @@ impl<'db> SemanticsImpl<'db> {
.unwrap_or(false) .unwrap_or(false)
} }
pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool { fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool {
ref_expr ref_expr
.expr() .expr()
.and_then(|expr| { .and_then(|expr| {
@ -654,7 +653,7 @@ impl<'db> SemanticsImpl<'db> {
// more than it should with the current implementation. // more than it should with the current implementation.
} }
pub fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> 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_some() {
return false; return false;
} }