Skip to content

Commit 8222381

Browse files
authored
Merge pull request #3236 from kngwyu/upd-syntax
Update rustc-ap-syntax to 306.0
2 parents 3ccc1f8 + fd27eab commit 8222381

File tree

6 files changed

+65
-68
lines changed

6 files changed

+65
-68
lines changed

Cargo.lock

+43-56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ env_logger = "0.5"
4848
getopts = "0.2"
4949
derive-new = "0.5"
5050
cargo_metadata = "0.6"
51-
rustc-ap-rustc_target = "297.0.0"
52-
rustc-ap-syntax = "297.0.0"
53-
rustc-ap-syntax_pos = "297.0.0"
51+
rustc-ap-rustc_target = "306.0.0"
52+
rustc-ap-syntax = "306.0.0"
53+
rustc-ap-syntax_pos = "306.0.0"
5454
failure = "0.1.1"
5555
bytecount = "0.4"
5656

src/closures.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use overflow::OverflowableItem;
2020
use rewrite::{Rewrite, RewriteContext};
2121
use shape::Shape;
2222
use source_map::SpanUtils;
23-
use utils::{last_line_width, left_most_sub_expr, stmt_expr};
23+
use utils::{last_line_width, left_most_sub_expr, stmt_expr, NodeIdExt};
2424

2525
// This module is pretty messy because of the rules around closures and blocks:
2626
// FIXME - the below is probably no longer true in full.
@@ -150,11 +150,11 @@ fn rewrite_closure_with_block(
150150

151151
let block = ast::Block {
152152
stmts: vec![ast::Stmt {
153-
id: ast::NodeId::new(0),
153+
id: ast::NodeId::root(),
154154
node: ast::StmtKind::Expr(ptr::P(body.clone())),
155155
span: body.span,
156156
}],
157-
id: ast::NodeId::new(0),
157+
id: ast::NodeId::root(),
158158
rules: ast::BlockCheckMode::Default,
159159
span: body.span,
160160
recovered: false,

src/macros.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use source_map::SpanUtils;
4242
use spanned::Spanned;
4343
use utils::{
4444
format_visibility, is_empty_line, mk_sp, remove_trailing_white_spaces, rewrite_ident,
45-
trim_left_preserve_layout, wrap_str,
45+
trim_left_preserve_layout, wrap_str, NodeIdExt,
4646
};
4747
use visitor::FmtVisitor;
4848

@@ -1102,7 +1102,6 @@ fn next_space(tok: &Token) -> SpaceState {
11021102
| Token::DotDot
11031103
| Token::DotDotDot
11041104
| Token::DotDotEq
1105-
| Token::DotEq
11061105
| Token::Question => SpaceState::Punctuation,
11071106

11081107
Token::ModSep
@@ -1127,7 +1126,7 @@ pub fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext) -> Option<ast::
11271126
let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
11281127

11291128
Some(ast::Expr {
1130-
id: ast::NodeId::new(0), // dummy value
1129+
id: ast::NodeId::root(), // dummy value
11311130
node: ast::ExprKind::Try(parser.parse_expr().ok()?),
11321131
span: mac.span, // incorrect span, but shouldn't matter too much
11331132
attrs: ThinVec::new(),

src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ where
114114

115115
for segment in iter {
116116
// Indicates a global path, shouldn't be rendered.
117-
if segment.ident.name == keywords::CrateRoot.name() {
117+
if segment.ident.name == keywords::PathRoot.name() {
118118
continue;
119119
}
120120
if first {

src/utils.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ use bytecount;
1414

1515
use rustc_target::spec::abi;
1616
use syntax::ast::{
17-
self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind, Path,
18-
Visibility, VisibilityKind,
17+
self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind,
18+
NodeId, Path, Visibility, VisibilityKind,
1919
};
2020
use syntax::ptr;
2121
use syntax::source_map::{BytePos, Span, NO_EXPANSION};
22+
use syntax_pos::Mark;
2223

2324
use comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
2425
use config::Config;
@@ -582,6 +583,16 @@ fn get_prefix_space_width(config: &Config, s: &str) -> usize {
582583
width
583584
}
584585

586+
pub(crate) trait NodeIdExt {
587+
fn root() -> Self;
588+
}
589+
590+
impl NodeIdExt for NodeId {
591+
fn root() -> NodeId {
592+
NodeId::placeholder_from_mark(Mark::root())
593+
}
594+
}
595+
585596
#[cfg(test)]
586597
mod test {
587598
use super::*;

0 commit comments

Comments
 (0)