]> git.lizzy.rs Git - rust.git/commitdiff
Inline and remove `MetaItemLit::from_lit_kind`.
authorNicholas Nethercote <n.nethercote@gmail.com>
Tue, 29 Nov 2022 07:42:40 +0000 (18:42 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Tue, 29 Nov 2022 07:42:40 +0000 (18:42 +1100)
It has a single call site.

compiler/rustc_ast/src/attr/mod.rs
compiler/rustc_ast/src/util/literal.rs

index 7a86b471ba298a988f7f61b89ecbf8d6b56c3e29..e08be6970ebaee2402f0b7378fb085068aad7e64 100644 (file)
@@ -333,8 +333,8 @@ pub fn mk_name_value_item_str(ident: Ident, str: Symbol, str_span: Span) -> Meta
     mk_name_value_item(ident, lit_kind, str_span)
 }
 
-pub fn mk_name_value_item(ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem {
-    let lit = MetaItemLit::from_lit_kind(lit_kind, lit_span);
+pub fn mk_name_value_item(ident: Ident, kind: LitKind, lit_span: Span) -> MetaItem {
+    let lit = MetaItemLit { token_lit: kind.to_token_lit(), kind, span: lit_span };
     let span = ident.span.to(lit_span);
     MetaItem { path: Path::from_ident(ident), span, kind: MetaItemKind::NameValue(lit) }
 }
index 42cba07fcef8d41c6044d15f8e4571b97aeb00c7..14ee4d481209c02b7b3355781ea6c5956c05ba9e 100644 (file)
@@ -207,13 +207,6 @@ pub fn from_token(token: &Token) -> Option<MetaItemLit> {
             .and_then(|token_lit| MetaItemLit::from_token_lit(token_lit, token.span).ok())
     }
 
-    /// Attempts to create a meta item literal from a `LitKind`.
-    /// This function is used when the original token doesn't exist (e.g. the literal is created
-    /// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
-    pub fn from_lit_kind(kind: LitKind, span: Span) -> MetaItemLit {
-        MetaItemLit { token_lit: kind.to_token_lit(), kind, span }
-    }
-
     /// Losslessly convert a meta item literal into a token.
     pub fn to_token(&self) -> Token {
         let kind = match self.token_lit.kind {