Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rustc-ap-syntax to 306.0 #3236

Merged
merged 1 commit into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 43 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ env_logger = "0.5"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.6"
rustc-ap-rustc_target = "297.0.0"
rustc-ap-syntax = "297.0.0"
rustc-ap-syntax_pos = "297.0.0"
rustc-ap-rustc_target = "306.0.0"
rustc-ap-syntax = "306.0.0"
rustc-ap-syntax_pos = "306.0.0"
failure = "0.1.1"
bytecount = "0.4"

Expand Down
6 changes: 3 additions & 3 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1102,7 +1102,6 @@ fn next_space(tok: &Token) -> SpaceState {
| Token::DotDot
| Token::DotDotDot
| Token::DotDotEq
| Token::DotEq
| Token::Question => SpaceState::Punctuation,

Token::ModSep
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 13 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::*;
Expand Down