Skip to content

Commit d8d91b6

Browse files
committed
Rename PatKind::Lit to Expr
1 parent 0514808 commit d8d91b6

File tree

45 files changed

+78
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+78
-78
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ impl Pat {
623623
PatKind::Wild
624624
| PatKind::Rest
625625
| PatKind::Never
626-
| PatKind::Lit(_)
626+
| PatKind::Expr(_)
627627
| PatKind::Range(..)
628628
| PatKind::Ident(..)
629629
| PatKind::Path(..)
@@ -801,8 +801,8 @@ pub enum PatKind {
801801
/// A reference pattern (e.g., `&mut (a, b)`).
802802
Ref(P<Pat>, Mutability),
803803

804-
/// A literal.
805-
Lit(P<Expr>),
804+
/// A literal, const block or path.
805+
Expr(P<Expr>),
806806

807807
/// A range pattern (e.g., `1...2`, `1..2`, `1..`, `..2`, `1..=2`, `..=2`).
808808
Range(Option<P<Expr>>, Option<P<Expr>>, Spanned<RangeEnd>),

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
15121512
vis.visit_ident(ident);
15131513
visit_opt(sub, |sub| vis.visit_pat(sub));
15141514
}
1515-
PatKind::Lit(e) => vis.visit_expr(e),
1515+
PatKind::Expr(e) => vis.visit_expr(e),
15161516
PatKind::TupleStruct(qself, path, elems) => {
15171517
vis.visit_qself(qself);
15181518
vis.visit_path(path);

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
680680
try_visit!(visitor.visit_ident(ident));
681681
visit_opt!(visitor, visit_pat, optional_subpattern);
682682
}
683-
PatKind::Lit(expression) => try_visit!(visitor.visit_expr(expression)),
683+
PatKind::Expr(expression) => try_visit!(visitor.visit_expr(expression)),
684684
PatKind::Range(lower_bound, upper_bound, _end) => {
685685
visit_opt!(visitor, visit_expr, lower_bound);
686686
visit_opt!(visitor, visit_expr, upper_bound);

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3838
lower_sub,
3939
);
4040
}
41-
PatKind::Lit(e) => {
42-
break hir::PatKind::Lit(self.lower_expr_within_pat(e, false));
41+
PatKind::Expr(e) => {
42+
break hir::PatKind::Expr(self.lower_expr_within_pat(e, false));
4343
}
4444
PatKind::TupleStruct(qself, path, pats) => {
4545
let qpath = self.lower_qpath(

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ impl<'a> State<'a> {
17011701
self.print_pat(inner);
17021702
}
17031703
}
1704-
PatKind::Lit(e) => self.print_expr(e, FixupContext::default()),
1704+
PatKind::Expr(e) => self.print_expr(e, FixupContext::default()),
17051705
PatKind::Range(begin, end, Spanned { node: end_kind, .. }) => {
17061706
if let Some(e) = begin {
17071707
self.print_expr(e, FixupContext::default());

compiler/rustc_expand/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl MacResult for MacEager {
522522
return Some(P(ast::Pat {
523523
id: ast::DUMMY_NODE_ID,
524524
span: e.span,
525-
kind: PatKind::Lit(e),
525+
kind: PatKind::Expr(e),
526526
tokens: None,
527527
}));
528528
}

compiler/rustc_expand/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl<'a> ExtCtxt<'a> {
486486
self.pat(span, PatKind::Wild)
487487
}
488488
pub fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> {
489-
self.pat(span, PatKind::Lit(expr))
489+
self.pat(span, PatKind::Expr(expr))
490490
}
491491
pub fn pat_ident(&self, span: Span, ident: Ident) -> P<ast::Pat> {
492492
self.pat_ident_binding_mode(span, ident, ast::BindingMode::NONE)

compiler/rustc_hir/src/hir.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ impl<'hir> Pat<'hir> {
13861386

13871387
use PatKind::*;
13881388
match self.kind {
1389-
Wild | Never | Lit(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => true,
1389+
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => true,
13901390
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_short_(it),
13911391
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
13921392
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
@@ -1413,7 +1413,7 @@ impl<'hir> Pat<'hir> {
14131413

14141414
use PatKind::*;
14151415
match self.kind {
1416-
Wild | Never | Lit(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => {}
1416+
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => {}
14171417
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_(it),
14181418
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
14191419
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
@@ -1583,8 +1583,8 @@ pub enum PatKind<'hir> {
15831583
/// A reference pattern (e.g., `&mut (a, b)`).
15841584
Ref(&'hir Pat<'hir>, Mutability),
15851585

1586-
/// A literal.
1587-
Lit(&'hir PatExpr<'hir>),
1586+
/// A literal, const block or path.
1587+
Expr(&'hir PatExpr<'hir>),
15881588

15891589
/// A range pattern (e.g., `1..=2` or `1..2`).
15901590
Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V:
688688
try_visit!(visitor.visit_ident(ident));
689689
visit_opt!(visitor, visit_pat, optional_subpattern);
690690
}
691-
PatKind::Lit(ref expression) => try_visit!(visitor.visit_pat_expr(expression)),
691+
PatKind::Expr(ref expression) => try_visit!(visitor.visit_pat_expr(expression)),
692692
PatKind::Range(ref lower_bound, ref upper_bound, _) => {
693693
visit_opt!(visitor, visit_pat_expr, lower_bound);
694694
visit_opt!(visitor, visit_pat_expr, upper_bound);

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ fn resolve_local<'tcx>(
701701
| PatKind::Wild
702702
| PatKind::Never
703703
| PatKind::Path(_)
704-
| PatKind::Lit(_)
704+
| PatKind::Expr(_)
705705
| PatKind::Range(_, _, _)
706706
| PatKind::Err(_) => false,
707707
}

0 commit comments

Comments
 (0)