]> git.lizzy.rs Git - rust.git/blobdiff - src/utils.rs
refactor: apply rustc mod parsing changes
[rust.git] / src / utils.rs
index 96d465608fad1a970538b3556408c7eeaf44ed42..d3c349fb701e18050e574a9d35e69debf5845799 100644 (file)
@@ -100,6 +100,14 @@ pub(crate) fn format_constness(constness: ast::Const) -> &'static str {
     }
 }
 
+#[inline]
+pub(crate) fn format_constness_right(constness: ast::Const) -> &'static str {
+    match constness {
+        ast::Const::Yes(..) => " const",
+        ast::Const::No => "",
+    }
+}
+
 #[inline]
 pub(crate) fn format_defaultness(defaultness: ast::Defaultness) -> &'static str {
     match defaultness {
@@ -352,6 +360,10 @@ pub(crate) fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
     Span::new(lo, hi, SyntaxContext::root())
 }
 
+pub(crate) fn mk_sp_lo_plus_one(lo: BytePos) -> Span {
+    Span::new(lo, lo + BytePos(1), SyntaxContext::root())
+}
+
 // Returns `true` if the given span does not intersect with file lines.
 macro_rules! out_of_file_lines_range {
     ($self:ident, $span:expr) => {
@@ -504,7 +516,8 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
         | ast::ExprKind::Ret(..)
         | ast::ExprKind::Tup(..)
         | ast::ExprKind::Type(..)
-        | ast::ExprKind::Yield(None) => false,
+        | ast::ExprKind::Yield(None)
+        | ast::ExprKind::Underscore => false,
     }
 }