mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 07:50:04 +00:00
Clean up naming in rustc syntax tree manipulation
This commit is contained in:
parent
ecacc475dd
commit
3e915e5c98
@ -704,7 +704,7 @@ fn is_escaped_literal_token(token: &Token, unescaped: Symbol) -> bool {
|
||||
kind: TokenKind::Literal(lit),
|
||||
span: _,
|
||||
} => match MetaItemLit::from_token_lit(*lit, DUMMY_SP) {
|
||||
Ok(lit) => is_escaped_literal_ast_lit(&lit, unescaped),
|
||||
Ok(lit) => is_escaped_literal_meta_item_lit(&lit, unescaped),
|
||||
Err(_) => false,
|
||||
},
|
||||
Token {
|
||||
@ -712,7 +712,7 @@ fn is_escaped_literal_token(token: &Token, unescaped: Symbol) -> bool {
|
||||
span: _,
|
||||
} => match nonterminal.as_ref() {
|
||||
Nonterminal::NtExpr(expr) => match &expr.kind {
|
||||
ExprKind::Lit(lit) => is_escaped_literal_token_lit(lit, unescaped),
|
||||
ExprKind::Lit(lit) => is_escaped_lit(lit, unescaped),
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
@ -721,17 +721,17 @@ fn is_escaped_literal_token(token: &Token, unescaped: Symbol) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_escaped_literal_macro_arg(arg: &AttrArgsEq, unescaped: Symbol) -> bool {
|
||||
match arg {
|
||||
fn is_escaped_literal_attr_args(value: &AttrArgsEq, unescaped: Symbol) -> bool {
|
||||
match value {
|
||||
AttrArgsEq::Ast(expr) => match &expr.kind {
|
||||
ExprKind::Lit(lit) => is_escaped_literal_token_lit(lit, unescaped),
|
||||
ExprKind::Lit(lit) => is_escaped_lit(lit, unescaped),
|
||||
_ => false,
|
||||
},
|
||||
AttrArgsEq::Hir(lit) => is_escaped_literal_ast_lit(lit, unescaped),
|
||||
AttrArgsEq::Hir(lit) => is_escaped_literal_meta_item_lit(lit, unescaped),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_escaped_literal_ast_lit(lit: &MetaItemLit, unescaped: Symbol) -> bool {
|
||||
fn is_escaped_literal_meta_item_lit(lit: &MetaItemLit, unescaped: Symbol) -> bool {
|
||||
match lit {
|
||||
MetaItemLit {
|
||||
token_lit:
|
||||
@ -742,26 +742,26 @@ fn is_escaped_literal_ast_lit(lit: &MetaItemLit, unescaped: Symbol) -> bool {
|
||||
},
|
||||
kind,
|
||||
span: _,
|
||||
} => is_escaped_literal_lit_kind(kind, unescaped),
|
||||
} => is_escaped_lit_kind(kind, unescaped),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_escaped_literal_token_lit(lit: &Lit, unescaped: Symbol) -> bool {
|
||||
fn is_escaped_lit(lit: &Lit, unescaped: Symbol) -> bool {
|
||||
match lit {
|
||||
Lit {
|
||||
kind: token::LitKind::Str,
|
||||
symbol: _,
|
||||
suffix: None,
|
||||
} => match LitKind::from_token_lit(*lit) {
|
||||
Ok(lit_kind) => is_escaped_literal_lit_kind(&lit_kind, unescaped),
|
||||
Ok(lit_kind) => is_escaped_lit_kind(&lit_kind, unescaped),
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_escaped_literal_lit_kind(kind: &LitKind, unescaped: Symbol) -> bool {
|
||||
fn is_escaped_lit_kind(kind: &LitKind, unescaped: Symbol) -> bool {
|
||||
match kind {
|
||||
LitKind::Str(symbol, StrStyle::Cooked) => {
|
||||
symbol.as_str().replace('\r', "") == unescaped.as_str().replace('\r', "")
|
||||
@ -795,8 +795,8 @@ impl SpanlessEq for AttrKind {
|
||||
SpanlessEq::eq(&path, &normal2.item.path)
|
||||
&& match &normal2.item.args {
|
||||
AttrArgs::Empty | AttrArgs::Delimited(_) => false,
|
||||
AttrArgs::Eq(_span, token) => {
|
||||
is_escaped_literal_macro_arg(token, *unescaped)
|
||||
AttrArgs::Eq(_span, value) => {
|
||||
is_escaped_literal_attr_args(value, *unescaped)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user