mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
internal: make naming consistent
This commit is contained in:
parent
faa420fc32
commit
6df00f8495
9 changed files with 14 additions and 14 deletions
|
@ -219,7 +219,7 @@ pub enum ArithOp {
|
||||||
BitAnd,
|
BitAnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use syntax::ast::PrefixOp as UnaryOp;
|
pub use syntax::ast::UnaryOp;
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub enum Array {
|
pub enum Array {
|
||||||
ElementList(Vec<ExprId>),
|
ElementList(Vec<ExprId>),
|
||||||
|
|
|
@ -126,7 +126,7 @@ pub(super) fn element(
|
||||||
let ty = sema.type_of_expr(&expr)?.original;
|
let ty = sema.type_of_expr(&expr)?.original;
|
||||||
if ty.is_raw_ptr() {
|
if ty.is_raw_ptr() {
|
||||||
HlTag::Operator(HlOperator::Other) | HlMod::Unsafe
|
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()
|
HlOperator::Other.into()
|
||||||
} else {
|
} else {
|
||||||
HlPunct::Other.into()
|
HlPunct::Other.into()
|
||||||
|
|
|
@ -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(|paren_expr| paren_expr.syntax().parent())
|
||||||
.and_then(ast::PrefixExpr::cast)
|
.and_then(ast::PrefixExpr::cast)
|
||||||
.and_then(|prefix_expr| {
|
.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)
|
Some(prefix_expr)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -173,8 +173,8 @@ fn is_equivalent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(ast::Expr::PrefixExpr(prefix0), ast::Expr::PrefixExpr(prefix1))
|
(ast::Expr::PrefixExpr(prefix0), ast::Expr::PrefixExpr(prefix1))
|
||||||
if prefix0.op_kind() == Some(ast::PrefixOp::Deref)
|
if prefix0.op_kind() == Some(ast::UnaryOp::Deref)
|
||||||
&& prefix1.op_kind() == Some(ast::PrefixOp::Deref) =>
|
&& prefix1.op_kind() == Some(ast::UnaryOp::Deref) =>
|
||||||
{
|
{
|
||||||
cov_mark::hit!(test_pull_assignment_up_deref);
|
cov_mark::hit!(test_pull_assignment_up_deref);
|
||||||
if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) {
|
if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) {
|
||||||
|
|
|
@ -233,7 +233,7 @@ fn invert_special_case(expr: &ast::Expr) -> Option<ast::Expr> {
|
||||||
};
|
};
|
||||||
Some(make::expr_method_call(receiver, make::name_ref(method), arg_list))
|
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()? {
|
if let ast::Expr::ParenExpr(parexpr) = pe.expr()? {
|
||||||
parexpr.expr()
|
parexpr.expr()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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::ParenExpr(inner) => next_expr = inner.expr(),
|
||||||
ast::Expr::TryExpr(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()
|
next_expr = prefix.expr()
|
||||||
}
|
}
|
||||||
_ => break,
|
_ => break,
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub use self::{
|
||||||
AttrKind, AttrsOwnerNode, FieldKind, Macro, NameLike, NameOrNameRef, PathSegmentKind,
|
AttrKind, AttrsOwnerNode, FieldKind, Macro, NameLike, NameOrNameRef, PathSegmentKind,
|
||||||
SelfParamKind, SlicePatComponents, StructKind, TypeBoundKind, VisibilityKind,
|
SelfParamKind, SlicePatComponents, StructKind, TypeBoundKind, VisibilityKind,
|
||||||
},
|
},
|
||||||
operators::{PrefixOp, RangeOp},
|
operators::{RangeOp, UnaryOp},
|
||||||
token_ext::{
|
token_ext::{
|
||||||
CommentKind, CommentPlacement, CommentShape, HasFormatSpecifier, IsString, QuoteOffsets,
|
CommentKind, CommentPlacement, CommentShape, HasFormatSpecifier, IsString, QuoteOffsets,
|
||||||
Radix,
|
Radix,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rowan::WalkEvent;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
operators::{PrefixOp, RangeOp},
|
operators::{RangeOp, UnaryOp},
|
||||||
support, AstChildren, AstNode,
|
support, AstChildren, AstNode,
|
||||||
},
|
},
|
||||||
AstToken,
|
AstToken,
|
||||||
|
@ -198,11 +198,11 @@ impl ast::IfExpr {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::PrefixExpr {
|
impl ast::PrefixExpr {
|
||||||
pub fn op_kind(&self) -> Option<PrefixOp> {
|
pub fn op_kind(&self) -> Option<UnaryOp> {
|
||||||
let res = match self.op_token()?.kind() {
|
let res = match self.op_token()?.kind() {
|
||||||
T![*] => PrefixOp::Deref,
|
T![*] => UnaryOp::Deref,
|
||||||
T![!] => PrefixOp::Not,
|
T![!] => UnaryOp::Not,
|
||||||
T![-] => PrefixOp::Neg,
|
T![-] => UnaryOp::Neg,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some(res)
|
Some(res)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum PrefixOp {
|
pub enum UnaryOp {
|
||||||
/// The `*` operator for dereferencing
|
/// The `*` operator for dereferencing
|
||||||
Deref,
|
Deref,
|
||||||
/// The `!` operator for logical inversion
|
/// The `!` operator for logical inversion
|
||||||
|
|
Loading…
Reference in a new issue