Skip to content

Commit 745b194

Browse files
committed
Small cleanup for check_proc_macro.rs
1 parent 8dda974 commit 745b194

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

clippy_utils/src/check_proc_macro.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ use rustc_session::Session;
2424
use rustc_span::{Span, Symbol};
2525
use rustc_target::spec::abi::Abi;
2626

27+
/// The search pattern to look for. Used by `span_matches_pat`
2728
#[derive(Clone, Copy)]
2829
pub enum Pat {
30+
/// A single string.
2931
Str(&'static str),
32+
/// Any of the given strings.
3033
MultiStr(&'static [&'static str]),
34+
/// The string representation of the symbol.
3135
Sym(Symbol),
36+
/// Any decimal or hexadecimal digit depending on the location.
3237
Num,
3338
}
3439

@@ -108,9 +113,9 @@ fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
108113
ExprKind::Box(e) => (Pat::Str("box"), expr_search_pat(tcx, e).1),
109114
ExprKind::ConstBlock(_) => (Pat::Str("const"), Pat::Str("}")),
110115
ExprKind::Tup([]) => (Pat::Str(")"), Pat::Str("(")),
111-
ExprKind::Unary(UnOp::Deref, _) => (Pat::Str("*"), expr_search_pat(tcx, e).1),
112-
ExprKind::Unary(UnOp::Not, _) => (Pat::Str("!"), expr_search_pat(tcx, e).1),
113-
ExprKind::Unary(UnOp::Neg, _) => (Pat::Str("-"), expr_search_pat(tcx, e).1),
116+
ExprKind::Unary(UnOp::Deref, e) => (Pat::Str("*"), expr_search_pat(tcx, e).1),
117+
ExprKind::Unary(UnOp::Not, e) => (Pat::Str("!"), expr_search_pat(tcx, e).1),
118+
ExprKind::Unary(UnOp::Neg, e) => (Pat::Str("-"), expr_search_pat(tcx, e).1),
114119
ExprKind::Lit(ref lit) => lit_search_pat(&lit.node),
115120
ExprKind::Array(_) | ExprKind::Repeat(..) => (Pat::Str("["), Pat::Str("]")),
116121
ExprKind::Call(e, []) | ExprKind::MethodCall(_, [e], _) => (expr_search_pat(tcx, e).0, Pat::Str("(")),
@@ -154,6 +159,7 @@ fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
154159
ExprKind::Continue(Destination { label: None, .. }) => (Pat::Str("continue"), Pat::Str("continue")),
155160
ExprKind::Continue(Destination { label: Some(name), .. }) => (Pat::Str("continue"), Pat::Sym(name.ident.name)),
156161
ExprKind::Ret(None) => (Pat::Str("return"), Pat::Str("return")),
162+
ExprKind::Ret(Some(e)) => (Pat::Str("return"), expr_search_pat(tcx, e).1),
157163
ExprKind::Struct(path, _, _) => (qpath_search_pat(path).0, Pat::Str("}")),
158164
ExprKind::Yield(e, YieldSource::Yield) => (Pat::Str("yield"), expr_search_pat(tcx, e).1),
159165
_ => (Pat::Str(""), Pat::Str("")),

0 commit comments

Comments
 (0)