about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-11-23 15:39:42 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-11-28 15:18:49 +1100
commite4a9150872a08db286208d07f5a6a90e466ca39c (patch)
tree4ccd691623b0747027b11cebbadb2804ee9ee0e2 /compiler/rustc_parse/src/parser/expr.rs
parentaa10aad1ac5058e8278d8871c1cb4473134d3d54 (diff)
downloadrust-e4a9150872a08db286208d07f5a6a90e466ca39c.tar.gz
rust-e4a9150872a08db286208d07f5a6a90e466ca39c.zip
Rename `ast::Lit` as `ast::MetaItemLit`.
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 9f2267efb82..e0443a697b5 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -33,10 +33,10 @@ use rustc_ast::util::case::Case;
 use rustc_ast::util::classify;
 use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity};
 use rustc_ast::visit::Visitor;
-use rustc_ast::{self as ast, AttrStyle, AttrVec, CaptureBy, ExprField, Lit, UnOp, DUMMY_NODE_ID};
+use rustc_ast::{self as ast, AttrStyle, AttrVec, CaptureBy, ExprField, UnOp, DUMMY_NODE_ID};
 use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind};
 use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
-use rustc_ast::{ClosureBinder, StmtKind};
+use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind};
 use rustc_ast_pretty::pprust;
 use rustc_errors::{
     Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult,
@@ -1631,7 +1631,7 @@ impl<'a> Parser<'a> {
         &self,
         lifetime: Ident,
         err: impl FnOnce(&Self) -> DiagnosticBuilder<'a, ErrorGuaranteed>,
-    ) -> ast::Lit {
+    ) -> ast::MetaItemLit {
         if let Some(mut diag) =
             self.sess.span_diagnostic.steal_diagnostic(lifetime.span, StashKey::LifetimeIsChar)
         {
@@ -1653,7 +1653,7 @@ impl<'a> Parser<'a> {
                 .emit();
         }
         let name = lifetime.without_first_quote().name;
-        ast::Lit {
+        ast::MetaItemLit {
             token_lit: token::Lit::new(token::LitKind::Char, name, None),
             kind: ast::LitKind::Char(name.as_str().chars().next().unwrap_or('_')),
             span: lifetime.span,
@@ -1768,8 +1768,8 @@ impl<'a> Parser<'a> {
     /// Returns a string literal if the next token is a string literal.
     /// In case of error returns `Some(lit)` if the next token is a literal with a wrong kind,
     /// and returns `None` if the next token is not literal at all.
-    pub fn parse_str_lit(&mut self) -> Result<ast::StrLit, Option<Lit>> {
-        match self.parse_opt_ast_lit() {
+    pub fn parse_str_lit(&mut self) -> Result<ast::StrLit, Option<MetaItemLit>> {
+        match self.parse_opt_meta_item_lit() {
             Some(lit) => match lit.kind {
                 ast::LitKind::Str(symbol_unescaped, style) => Ok(ast::StrLit {
                     style,
@@ -1784,7 +1784,7 @@ impl<'a> Parser<'a> {
         }
     }
 
-    fn handle_missing_lit(&mut self) -> PResult<'a, Lit> {
+    fn handle_missing_lit(&mut self) -> PResult<'a, MetaItemLit> {
         if let token::Interpolated(inner) = &self.token.kind {
             let expr = match inner.as_ref() {
                 token::NtExpr(expr) => Some(expr),
@@ -1820,8 +1820,8 @@ impl<'a> Parser<'a> {
             .or_else(|()| self.handle_missing_lit().map(|lit| (lit.token_lit, lit.span)))
     }
 
-    pub(super) fn parse_ast_lit(&mut self) -> PResult<'a, Lit> {
-        self.parse_opt_ast_lit().ok_or(()).or_else(|()| self.handle_missing_lit())
+    pub(super) fn parse_meta_item_lit(&mut self) -> PResult<'a, MetaItemLit> {
+        self.parse_opt_meta_item_lit().ok_or(()).or_else(|()| self.handle_missing_lit())
     }
 
     fn recover_after_dot(&mut self) -> Option<Token> {
@@ -1867,12 +1867,12 @@ impl<'a> Parser<'a> {
 
     /// Matches `lit = true | false | token_lit`.
     /// Returns `None` if the next token is not a literal.
-    pub(super) fn parse_opt_ast_lit(&mut self) -> Option<Lit> {
+    pub(super) fn parse_opt_meta_item_lit(&mut self) -> Option<MetaItemLit> {
         let recovered = self.recover_after_dot();
         let token = recovered.as_ref().unwrap_or(&self.token);
         match token::Lit::from_token(token) {
             Some(token_lit) => {
-                match Lit::from_token_lit(token_lit, token.span) {
+                match MetaItemLit::from_token_lit(token_lit, token.span) {
                     Ok(lit) => {
                         self.bump();
                         Some(lit)
@@ -1889,7 +1889,10 @@ impl<'a> Parser<'a> {
                         let suffixless_lit = token::Lit::new(lit.kind, lit.symbol, None);
                         let symbol = Symbol::intern(&suffixless_lit.to_string());
                         let lit = token::Lit::new(token::Err, symbol, lit.suffix);
-                        Some(Lit::from_token_lit(lit, span).unwrap_or_else(|_| unreachable!()))
+                        Some(
+                            MetaItemLit::from_token_lit(lit, span)
+                                .unwrap_or_else(|_| unreachable!()),
+                        )
                     }
                 }
             }