From 39fdd41df4052cef5da4876067ae28615012476b Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 23 Jul 2020 18:31:28 -0400 Subject: Return bool from is_unsafe_method_call and cleanup usages --- crates/ra_ide/src/syntax_highlighting.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index e29f65a78..4527885e9 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -730,8 +730,9 @@ fn highlight_name( let is_unsafe = name_ref .and_then(|name_ref| name_ref.syntax().parent()) .and_then(ast::MethodCallExpr::cast) - .and_then(|method_call_expr| sema.is_unsafe_method_call(method_call_expr)); - if is_unsafe.is_some() { + .map(|method_call_expr| sema.is_unsafe_method_call(method_call_expr)) + .unwrap_or(false); + if is_unsafe { h |= HighlightModifier::Unsafe; } } @@ -809,9 +810,9 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics { let mut h = Highlight::new(HighlightTag::Function); let is_unsafe = ast::MethodCallExpr::cast(parent) - .and_then(|method_call_expr| sema.is_unsafe_method_call(method_call_expr)); - - if is_unsafe.is_some() { + .map(|method_call_expr| sema.is_unsafe_method_call(method_call_expr)) + .unwrap_or(false); + if is_unsafe { h |= HighlightModifier::Unsafe; } -- cgit v1.2.3