diff options
| author | Peter <peter.wilkins@polecat.com> | 2019-12-08 23:16:18 +0000 |
|---|---|---|
| committer | Peter <peter.wilkins@polecat.com> | 2019-12-08 23:49:30 +0000 |
| commit | 8f6a06285efe12d778ff7f44067aebeed7b14428 (patch) | |
| tree | 856b9d17a8e4700c44a2794e63ec75ecf9660397 /src/libsyntax/util | |
| parent | 947772fc31b96ce90f57720f74571f14e35df66b (diff) | |
| parent | 59947fcae6a40df12e33af8c8c7291014b7603e0 (diff) | |
| download | rust-8f6a06285efe12d778ff7f44067aebeed7b14428.tar.gz rust-8f6a06285efe12d778ff7f44067aebeed7b14428.zip | |
move from non zero impls to `libcore/convert/num.rs`
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/comments.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/util/lev_distance.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/util/literal.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/util/parser.rs | 4 |
4 files changed, 12 insertions, 11 deletions
diff --git a/src/libsyntax/util/comments.rs b/src/libsyntax/util/comments.rs index 448b4f3b825..5e9b7bf8322 100644 --- a/src/libsyntax/util/comments.rs +++ b/src/libsyntax/util/comments.rs @@ -32,14 +32,14 @@ pub struct Comment { pub pos: BytePos, } -crate fn is_line_doc_comment(s: &str) -> bool { +pub fn is_line_doc_comment(s: &str) -> bool { let res = (s.starts_with("///") && *s.as_bytes().get(3).unwrap_or(&b' ') != b'/') || s.starts_with("//!"); debug!("is {:?} a doc comment? {}", s, res); res } -crate fn is_block_doc_comment(s: &str) -> bool { +pub fn is_block_doc_comment(s: &str) -> bool { // Prevent `/**/` from being parsed as a doc comment let res = ((s.starts_with("/**") && *s.as_bytes().get(3).unwrap_or(&b' ') != b'*') || s.starts_with("/*!")) && s.len() >= 5; @@ -47,7 +47,8 @@ crate fn is_block_doc_comment(s: &str) -> bool { res } -crate fn is_doc_comment(s: &str) -> bool { +// FIXME(#64197): Try to privatize this again. +pub fn is_doc_comment(s: &str) -> bool { (s.starts_with("///") && is_line_doc_comment(s)) || s.starts_with("//!") || (s.starts_with("/**") && is_block_doc_comment(s)) || s.starts_with("/*!") } diff --git a/src/libsyntax/util/lev_distance.rs b/src/libsyntax/util/lev_distance.rs index 4127a8c7fce..efb3c2396c3 100644 --- a/src/libsyntax/util/lev_distance.rs +++ b/src/libsyntax/util/lev_distance.rs @@ -77,6 +77,6 @@ pub fn find_best_match_for_name<'a, T>(iter_names: T, if let Some(candidate) = case_insensitive_match { Some(candidate) // exact case insensitive match has a higher priority } else { - if let Some((candidate, _)) = levenstein_match { Some(candidate) } else { None } + levenstein_match.map(|(candidate, _)| candidate) } } diff --git a/src/libsyntax/util/literal.rs b/src/libsyntax/util/literal.rs index d4c9b7850c5..af7afab6b9b 100644 --- a/src/libsyntax/util/literal.rs +++ b/src/libsyntax/util/literal.rs @@ -14,7 +14,7 @@ use rustc_lexer::unescape::{unescape_raw_str, unescape_raw_byte_str}; use std::ascii; -crate enum LitError { +pub enum LitError { NotLiteral, LexerError, InvalidSuffix, @@ -185,12 +185,12 @@ impl LitKind { impl Lit { /// Converts literal token into an AST literal. - crate fn from_lit_token(token: token::Lit, span: Span) -> Result<Lit, LitError> { + pub fn from_lit_token(token: token::Lit, span: Span) -> Result<Lit, LitError> { Ok(Lit { token, kind: LitKind::from_lit_token(token)?, span }) } /// Converts arbitrary token into an AST literal. - crate fn from_token(token: &Token) -> Result<Lit, LitError> { + pub fn from_token(token: &Token) -> Result<Lit, LitError> { let lit = match token.kind { token::Ident(name, false) if name.is_bool_lit() => token::Lit::new(token::Bool, name, None), @@ -217,8 +217,8 @@ impl Lit { Lit { token: kind.to_lit_token(), kind, span } } - /// Losslessly convert an AST literal into a token tree. - crate fn token_tree(&self) -> TokenTree { + /// Losslessly convert an AST literal into a token stream. + pub fn token_tree(&self) -> TokenTree { let token = match self.token.kind { token::Bool => token::Ident(self.token.symbol, false), _ => token::Literal(self.token), diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index edb708d7e97..df72fdc8014 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -69,7 +69,7 @@ pub enum Fixity { impl AssocOp { /// Creates a new AssocOP from a token - crate fn from_token(t: &Token) -> Option<AssocOp> { + pub fn from_token(t: &Token) -> Option<AssocOp> { use AssocOp::*; match t.kind { token::BinOpEq(k) => Some(AssignOp(k)), @@ -358,7 +358,7 @@ impl ExprPrecedence { } /// In `let p = e`, operators with precedence `<=` this one requires parenthesis in `e`. -crate fn prec_let_scrutinee_needs_par() -> usize { +pub fn prec_let_scrutinee_needs_par() -> usize { AssocOp::LAnd.precedence() } |
