1
Fork 0

rustc_expand: remove ref patterns

This commit is contained in:
Maybe Waffle 2022-12-23 17:34:23 +00:00
parent fc6cda8603
commit bddbf38af2
8 changed files with 75 additions and 82 deletions

View file

@ -176,9 +176,9 @@ fn get_spans_of_pat_idents(src: &str) -> Vec<Span> {
}
impl<'a> visit::Visitor<'a> for PatIdentVisitor {
fn visit_pat(&mut self, p: &'a ast::Pat) {
match p.kind {
PatKind::Ident(_, ref ident, _) => {
self.spans.push(ident.span.clone());
match &p.kind {
PatKind::Ident(_, ident, _) => {
self.spans.push(ident.span);
}
_ => {
visit::walk_pat(self, p);
@ -290,10 +290,8 @@ fn ttdelim_span() {
)
.unwrap();
let tts: Vec<_> = match expr.kind {
ast::ExprKind::MacCall(ref mac) => mac.args.tokens.clone().into_trees().collect(),
_ => panic!("not a macro"),
};
let ast::ExprKind::MacCall(mac) = &expr.kind else { panic!("not a macro") };
let tts: Vec<_> = mac.args.tokens.clone().into_trees().collect();
let span = tts.iter().rev().next().unwrap().span();
@ -318,11 +316,8 @@ fn out_of_line_mod() {
.unwrap()
.unwrap();
if let ast::ItemKind::Mod(_, ref mod_kind) = item.kind {
assert!(matches!(mod_kind, ast::ModKind::Loaded(items, ..) if items.len() == 2));
} else {
panic!();
}
let ast::ItemKind::Mod(_, mod_kind) = &item.kind else { panic!() };
assert!(matches!(mod_kind, ast::ModKind::Loaded(items, ..) if items.len() == 2));
});
}