diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index f706a186e..9697c7082 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -281,26 +281,26 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
281 | self.imp.assert_contains_node(node) | 281 | self.imp.assert_contains_node(node) |
282 | } | 282 | } |
283 | 283 | ||
284 | pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> Option<()> { | 284 | pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool { |
285 | let expr = method_call_expr.expr()?; | 285 | method_call_expr |
286 | let field_expr = | 286 | .expr() |
287 | if let ast::Expr::FieldExpr(field_expr) = expr { field_expr } else { return None }; | 287 | .and_then(|expr| { |
288 | let ty = self.type_of_expr(&field_expr.expr()?)?; | 288 | let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr { |
289 | if !ty.is_packed(self.db) { | 289 | field_expr |
290 | return None; | 290 | } else { |
291 | } | 291 | return None; |
292 | }; | ||
293 | let ty = self.type_of_expr(&field_expr.expr()?)?; | ||
294 | if !ty.is_packed(self.db) { | ||
295 | return None; | ||
296 | } | ||
292 | 297 | ||
293 | let func = self.resolve_method_call(&method_call_expr)?; | 298 | let func = self.resolve_method_call(&method_call_expr)?; |
294 | if func.has_self_param(self.db) { | 299 | let is_unsafe = func.has_self_param(self.db) |
295 | let params = func.params(self.db); | 300 | && matches!(func.params(self.db).first(), Some(TypeRef::Reference(..))); |
296 | if matches!(params.into_iter().next(), Some(TypeRef::Reference(..))) { | 301 | Some(is_unsafe) |
297 | Some(()) | 302 | }) |
298 | } else { | 303 | .unwrap_or(false) |
299 | None | ||
300 | } | ||
301 | } else { | ||
302 | None | ||
303 | } | ||
304 | } | 304 | } |
305 | 305 | ||
306 | pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool { | 306 | pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool { |