diff --git a/crates/hir_def/src/expr.rs b/crates/hir_def/src/expr.rs index e8e73f79fe..f1e66d9f68 100644 --- a/crates/hir_def/src/expr.rs +++ b/crates/hir_def/src/expr.rs @@ -219,7 +219,7 @@ pub enum ArithOp { BitAnd, } -pub use syntax::ast::PrefixOp as UnaryOp; +pub use syntax::ast::UnaryOp; #[derive(Debug, Clone, Eq, PartialEq)] pub enum Array { ElementList(Vec), diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 5a7683c577..f82566d978 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -126,7 +126,7 @@ pub(super) fn element( let ty = sema.type_of_expr(&expr)?.original; if ty.is_raw_ptr() { HlTag::Operator(HlOperator::Other) | HlMod::Unsafe - } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() { + } else if let Some(ast::UnaryOp::Deref) = prefix_expr.op_kind() { HlOperator::Other.into() } else { HlPunct::Other.into() diff --git a/crates/ide_assists/src/handlers/apply_demorgan.rs b/crates/ide_assists/src/handlers/apply_demorgan.rs index cafc4297fd..b8822595d4 100644 --- a/crates/ide_assists/src/handlers/apply_demorgan.rs +++ b/crates/ide_assists/src/handlers/apply_demorgan.rs @@ -85,7 +85,7 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( .and_then(|paren_expr| paren_expr.syntax().parent()) .and_then(ast::PrefixExpr::cast) .and_then(|prefix_expr| { - if prefix_expr.op_kind().unwrap() == ast::PrefixOp::Not { + if prefix_expr.op_kind().unwrap() == ast::UnaryOp::Not { Some(prefix_expr) } else { None diff --git a/crates/ide_assists/src/handlers/pull_assignment_up.rs b/crates/ide_assists/src/handlers/pull_assignment_up.rs index f07b8a6c0d..4d0041e424 100644 --- a/crates/ide_assists/src/handlers/pull_assignment_up.rs +++ b/crates/ide_assists/src/handlers/pull_assignment_up.rs @@ -173,8 +173,8 @@ fn is_equivalent( } } (ast::Expr::PrefixExpr(prefix0), ast::Expr::PrefixExpr(prefix1)) - if prefix0.op_kind() == Some(ast::PrefixOp::Deref) - && prefix1.op_kind() == Some(ast::PrefixOp::Deref) => + if prefix0.op_kind() == Some(ast::UnaryOp::Deref) + && prefix1.op_kind() == Some(ast::UnaryOp::Deref) => { cov_mark::hit!(test_pull_assignment_up_deref); if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) { diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs index 256ddb8c9b..476525d1be 100644 --- a/crates/ide_assists/src/utils.rs +++ b/crates/ide_assists/src/utils.rs @@ -233,7 +233,7 @@ fn invert_special_case(expr: &ast::Expr) -> Option { }; Some(make::expr_method_call(receiver, make::name_ref(method), arg_list)) } - ast::Expr::PrefixExpr(pe) if pe.op_kind()? == ast::PrefixOp::Not => { + ast::Expr::PrefixExpr(pe) if pe.op_kind()? == ast::UnaryOp::Not => { if let ast::Expr::ParenExpr(parexpr) = pe.expr()? { parexpr.expr() } else { diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs index c1513f97da..17db6d3c19 100644 --- a/crates/ide_assists/src/utils/suggest_name.rs +++ b/crates/ide_assists/src/utils/suggest_name.rs @@ -110,7 +110,7 @@ pub(crate) fn for_variable(expr: &ast::Expr, sema: &Semantics<'_, RootDatabase>) } ast::Expr::ParenExpr(inner) => next_expr = inner.expr(), ast::Expr::TryExpr(inner) => next_expr = inner.expr(), - ast::Expr::PrefixExpr(prefix) if prefix.op_kind() == Some(ast::PrefixOp::Deref) => { + ast::Expr::PrefixExpr(prefix) if prefix.op_kind() == Some(ast::UnaryOp::Deref) => { next_expr = prefix.expr() } _ => break, diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs index fce09851d9..2dcbcccc10 100644 --- a/crates/syntax/src/ast.rs +++ b/crates/syntax/src/ast.rs @@ -24,7 +24,7 @@ pub use self::{ AttrKind, AttrsOwnerNode, FieldKind, Macro, NameLike, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind, TypeBoundKind, VisibilityKind, }, - operators::{PrefixOp, RangeOp}, + operators::{RangeOp, UnaryOp}, token_ext::{ CommentKind, CommentPlacement, CommentShape, HasFormatSpecifier, IsString, QuoteOffsets, Radix, diff --git a/crates/syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs index f482a45dbe..3ebb85fc83 100644 --- a/crates/syntax/src/ast/expr_ext.rs +++ b/crates/syntax/src/ast/expr_ext.rs @@ -5,7 +5,7 @@ use rowan::WalkEvent; use crate::{ ast::{ self, - operators::{PrefixOp, RangeOp}, + operators::{RangeOp, UnaryOp}, support, AstChildren, AstNode, }, AstToken, @@ -198,11 +198,11 @@ impl ast::IfExpr { } impl ast::PrefixExpr { - pub fn op_kind(&self) -> Option { + pub fn op_kind(&self) -> Option { let res = match self.op_token()?.kind() { - T![*] => PrefixOp::Deref, - T![!] => PrefixOp::Not, - T![-] => PrefixOp::Neg, + T![*] => UnaryOp::Deref, + T![!] => UnaryOp::Not, + T![-] => UnaryOp::Neg, _ => return None, }; Some(res) diff --git a/crates/syntax/src/ast/operators.rs b/crates/syntax/src/ast/operators.rs index 03fd7da840..e8eaf743ba 100644 --- a/crates/syntax/src/ast/operators.rs +++ b/crates/syntax/src/ast/operators.rs @@ -1,5 +1,5 @@ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum PrefixOp { +pub enum UnaryOp { /// The `*` operator for dereferencing Deref, /// The `!` operator for logical inversion