about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/closures.rs6
-rw-r--r--src/macros.rs5
-rw-r--r--src/types.rs2
-rw-r--r--src/utils.rs15
4 files changed, 19 insertions, 9 deletions
diff --git a/src/closures.rs b/src/closures.rs
index fa656cc351e..e29a412a515 100644
--- a/src/closures.rs
+++ b/src/closures.rs
@@ -20,7 +20,7 @@ use overflow::OverflowableItem;
 use rewrite::{Rewrite, RewriteContext};
 use shape::Shape;
 use source_map::SpanUtils;
-use utils::{last_line_width, left_most_sub_expr, stmt_expr};
+use utils::{last_line_width, left_most_sub_expr, stmt_expr, NodeIdExt};
 
 // This module is pretty messy because of the rules around closures and blocks:
 // FIXME - the below is probably no longer true in full.
@@ -150,11 +150,11 @@ fn rewrite_closure_with_block(
 
     let block = ast::Block {
         stmts: vec![ast::Stmt {
-            id: ast::NodeId::new(0),
+            id: ast::NodeId::root(),
             node: ast::StmtKind::Expr(ptr::P(body.clone())),
             span: body.span,
         }],
-        id: ast::NodeId::new(0),
+        id: ast::NodeId::root(),
         rules: ast::BlockCheckMode::Default,
         span: body.span,
         recovered: false,
diff --git a/src/macros.rs b/src/macros.rs
index 8d3b45da0d2..2a4774149ca 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -42,7 +42,7 @@ use source_map::SpanUtils;
 use spanned::Spanned;
 use utils::{
     format_visibility, is_empty_line, mk_sp, remove_trailing_white_spaces, rewrite_ident,
-    trim_left_preserve_layout, wrap_str,
+    trim_left_preserve_layout, wrap_str, NodeIdExt,
 };
 use visitor::FmtVisitor;
 
@@ -1102,7 +1102,6 @@ fn next_space(tok: &Token) -> SpaceState {
         | Token::DotDot
         | Token::DotDotDot
         | Token::DotDotEq
-        | Token::DotEq
         | Token::Question => SpaceState::Punctuation,
 
         Token::ModSep
@@ -1127,7 +1126,7 @@ pub fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext) -> Option<ast::
         let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
 
         Some(ast::Expr {
-            id: ast::NodeId::new(0), // dummy value
+            id: ast::NodeId::root(), // dummy value
             node: ast::ExprKind::Try(parser.parse_expr().ok()?),
             span: mac.span, // incorrect span, but shouldn't matter too much
             attrs: ThinVec::new(),
diff --git a/src/types.rs b/src/types.rs
index 7b23cd51915..1c2c386932a 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -114,7 +114,7 @@ where
 
     for segment in iter {
         // Indicates a global path, shouldn't be rendered.
-        if segment.ident.name == keywords::CrateRoot.name() {
+        if segment.ident.name == keywords::PathRoot.name() {
             continue;
         }
         if first {
diff --git a/src/utils.rs b/src/utils.rs
index c5f9a5eda5e..7f1bc284180 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -14,11 +14,12 @@ use bytecount;
 
 use rustc_target::spec::abi;
 use syntax::ast::{
-    self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind, Path,
-    Visibility, VisibilityKind,
+    self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind,
+    NodeId, Path, Visibility, VisibilityKind,
 };
 use syntax::ptr;
 use syntax::source_map::{BytePos, Span, NO_EXPANSION};
+use syntax_pos::Mark;
 
 use comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
 use config::Config;
@@ -582,6 +583,16 @@ fn get_prefix_space_width(config: &Config, s: &str) -> usize {
     width
 }
 
+pub(crate) trait NodeIdExt {
+    fn root() -> Self;
+}
+
+impl NodeIdExt for NodeId {
+    fn root() -> NodeId {
+        NodeId::placeholder_from_mark(Mark::root())
+    }
+}
+
 #[cfg(test)]
 mod test {
     use super::*;