aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs34
1 files changed, 2 insertions, 32 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index d5a5f69cc..cf93205b6 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -671,41 +671,11 @@ fn highlight_element(
671 T![ref] => { 671 T![ref] => {
672 let modifier: Option<HighlightModifier> = (|| { 672 let modifier: Option<HighlightModifier> = (|| {
673 let bind_pat = element.parent().and_then(ast::BindPat::cast)?; 673 let bind_pat = element.parent().and_then(ast::BindPat::cast)?;
674 let parent = bind_pat.syntax().parent()?; 674 if sema.is_unsafe_pat(&ast::Pat::BindPat(bind_pat)) {
675 675 Some(HighlightModifier::Unsafe)
676 let ty = if let Some(pat_list) =
677 ast::RecordFieldPatList::cast(parent.clone())
678 {
679 let record_pat =
680 pat_list.syntax().parent().and_then(ast::RecordPat::cast)?;
681 sema.type_of_pat(&ast::Pat::RecordPat(record_pat))
682 } else if let Some(let_stmt) = ast::LetStmt::cast(parent.clone()) {
683 let field_expr =
684 if let ast::Expr::FieldExpr(field_expr) = let_stmt.initializer()? {
685 field_expr
686 } else {
687 return None;
688 };
689
690 sema.type_of_expr(&field_expr.expr()?)
691 } else if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent) {
692 let record_pat = record_field_pat
693 .syntax()
694 .parent()
695 .and_then(ast::RecordFieldPatList::cast)?
696 .syntax()
697 .parent()
698 .and_then(ast::RecordPat::cast)?;
699 sema.type_of_pat(&ast::Pat::RecordPat(record_pat))
700 } else { 676 } else {
701 None 677 None
702 }?;
703
704 if !ty.is_packed(db) {
705 return None;
706 } 678 }
707
708 Some(HighlightModifier::Unsafe)
709 })(); 679 })();
710 680
711 if let Some(modifier) = modifier { 681 if let Some(modifier) = modifier {