Skip to content

Commit b173b42

Browse files
refactor: rename libsyntax --> rustc_ast
1 parent c1a66e1 commit b173b42

29 files changed

+70
-70
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ lazy_static = "1.0.0"
6363
# for more information.
6464
rustc-workspace-hack = "1.0.0"
6565

66+
[dependencies.rustc_ast]
67+
package = "rustc-ap-rustc_ast"
68+
version = "650.0.0"
69+
6670
[dependencies.rustc_ast_pretty]
6771
package = "rustc-ap-rustc_ast_pretty"
6872
version = "650.0.0"
@@ -94,7 +98,3 @@ version = "650.0.0"
9498
[dependencies.rustc_target]
9599
package = "rustc-ap-rustc_target"
96100
version = "650.0.0"
97-
98-
[dependencies.syntax]
99-
package = "rustc-ap-rustc_ast"
100-
version = "650.0.0"

src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Format attributes and meta items.
22
3+
use rustc_ast::ast;
34
use rustc_span::{symbol::sym, BytePos, Span, DUMMY_SP};
4-
use syntax::ast;
55

66
use self::doc_comment::DocCommentFormatter;
77
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};

src/chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
use std::borrow::Cow;
5959
use std::cmp::min;
6060

61+
use rustc_ast::{ast, ptr};
6162
use rustc_span::{BytePos, Span};
62-
use syntax::{ast, ptr};
6363

6464
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
6565
use crate::config::IndentStyle;

src/closures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use rustc_ast::{ast, ptr};
12
use rustc_span::Span;
2-
use syntax::{ast, ptr};
33

44
use crate::attr::get_attrs_from_stmt;
55
use crate::config::lists::*;

src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::borrow::Cow;
22
use std::cmp::min;
33

44
use itertools::Itertools;
5+
use rustc_ast::token::{DelimToken, LitKind};
6+
use rustc_ast::{ast, ptr};
57
use rustc_span::{BytePos, Span};
6-
use syntax::token::{DelimToken, LitKind};
7-
use syntax::{ast, ptr};
88

99
use crate::chains::rewrite_chain;
1010
use crate::closures;
@@ -1314,7 +1314,7 @@ pub(crate) fn can_be_overflowed_expr(
13141314
}
13151315
ast::ExprKind::MacCall(ref mac) => {
13161316
match (
1317-
syntax::ast::MacDelimiter::from_token(mac.args.delim()),
1317+
rustc_ast::ast::MacDelimiter::from_token(mac.args.delim()),
13181318
context.config.overflow_delimited_expr(),
13191319
) {
13201320
(Some(ast::MacDelimiter::Bracket), true)

src/formatting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::collections::HashMap;
44
use std::io::{self, Write};
55
use std::time::{Duration, Instant};
66

7+
use rustc_ast::ast;
78
use rustc_span::Span;
8-
use syntax::ast;
99

1010
use self::newline_style::apply_newline_style;
1111
use crate::comment::{CharClasses, FullCodeCharKind};
@@ -29,7 +29,7 @@ impl<'b, T: Write + 'b> Session<'b, T> {
2929
return Err(ErrorKind::VersionMismatch);
3030
}
3131

32-
syntax::with_globals(self.config.edition().to_libsyntax_pos_edition(), || {
32+
rustc_ast::with_globals(self.config.edition().to_libsyntax_pos_edition(), || {
3333
if self.config.disable_all_formatting() {
3434
// When the input is from stdin, echo back the input.
3535
if let Input::Text(ref buf) = input {

src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::borrow::Cow;
22
use std::cmp::Ordering;
33
use std::fmt;
44

5+
use rustc_ast::ast::{self, UseTreeKind};
56
use rustc_span::{source_map, symbol::sym, BytePos, Span, DUMMY_SP};
6-
use syntax::ast::{self, UseTreeKind};
77

88
use crate::comment::combine_strs_with_missing_comments;
99
use crate::config::lists::*;

src/items.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use std::borrow::Cow;
44
use std::cmp::{max, min, Ordering};
55

66
use regex::Regex;
7+
use rustc_ast::visit;
8+
use rustc_ast::{ast, ptr};
79
use rustc_span::{source_map, symbol, BytePos, Span, DUMMY_SP};
8-
use syntax::visit;
9-
use syntax::{ast, ptr};
1010

1111
use crate::attr::filter_inline_attrs;
1212
use crate::comment::{
@@ -594,7 +594,7 @@ impl<'a> FmtVisitor<'a> {
594594
self.buffer.clear();
595595
}
596596

597-
fn is_type(ty: &Option<syntax::ptr::P<ast::Ty>>) -> bool {
597+
fn is_type(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
598598
match ty {
599599
None => true,
600600
Some(lty) => match lty.kind.opaque_top_hack() {
@@ -604,7 +604,7 @@ impl<'a> FmtVisitor<'a> {
604604
}
605605
}
606606

607-
fn is_opaque(ty: &Option<syntax::ptr::P<ast::Ty>>) -> bool {
607+
fn is_opaque(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
608608
match ty {
609609
None => false,
610610
Some(lty) => match lty.kind.opaque_top_hack() {
@@ -615,15 +615,15 @@ impl<'a> FmtVisitor<'a> {
615615
}
616616

617617
fn both_type(
618-
a: &Option<syntax::ptr::P<ast::Ty>>,
619-
b: &Option<syntax::ptr::P<ast::Ty>>,
618+
a: &Option<rustc_ast::ptr::P<ast::Ty>>,
619+
b: &Option<rustc_ast::ptr::P<ast::Ty>>,
620620
) -> bool {
621621
is_type(a) && is_type(b)
622622
}
623623

624624
fn both_opaque(
625-
a: &Option<syntax::ptr::P<ast::Ty>>,
626-
b: &Option<syntax::ptr::P<ast::Ty>>,
625+
a: &Option<rustc_ast::ptr::P<ast::Ty>>,
626+
b: &Option<rustc_ast::ptr::P<ast::Ty>>,
627627
) -> bool {
628628
is_opaque(a) && is_opaque(b)
629629
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::rc::Rc;
1919

2020
use failure::Fail;
2121
use ignore;
22-
use syntax::ast;
22+
use rustc_ast::ast;
2323

2424
use crate::comment::LineClasses;
2525
use crate::emitter::Emitter;

src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
use std::collections::HashMap;
1313
use std::panic::{catch_unwind, AssertUnwindSafe};
1414

15+
use rustc_ast::token::{BinOpToken, DelimToken, Token, TokenKind};
16+
use rustc_ast::tokenstream::{Cursor, TokenStream, TokenTree};
17+
use rustc_ast::{ast, ptr};
1518
use rustc_ast_pretty::pprust;
1619
use rustc_parse::{new_parser_from_tts, parser::Parser};
1720
use rustc_span::{symbol::kw, BytePos, Span, Symbol, DUMMY_SP};
18-
use syntax::token::{BinOpToken, DelimToken, Token, TokenKind};
19-
use syntax::tokenstream::{Cursor, TokenStream, TokenTree};
20-
use syntax::{ast, ptr};
2121

2222
use crate::comment::{
2323
contains_comment, CharClasses, FindUncommented, FullCodeCharKind, LineClasses,

src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use std::iter::repeat;
44

5+
use rustc_ast::{ast, ptr};
56
use rustc_span::{BytePos, Span};
6-
use syntax::{ast, ptr};
77

88
use crate::comment::{combine_strs_with_missing_comments, rewrite_comment};
99
use crate::config::lists::*;

src/modules.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::borrow::Cow;
22
use std::collections::BTreeMap;
33
use std::path::{Path, PathBuf};
44

5+
use rustc_ast::ast;
6+
use rustc_ast::visit::Visitor;
57
use rustc_span::symbol::{sym, Symbol};
6-
use syntax::ast;
7-
use syntax::visit::Visitor;
88

99
use crate::attr::MetaVisitor;
1010
use crate::config::FileName;

src/modules/visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use rustc_ast::ast;
2+
use rustc_ast::visit::Visitor;
13
use rustc_span::Symbol;
2-
use syntax::ast;
3-
use syntax::visit::Visitor;
44

55
use crate::attr::MetaVisitor;
66
use crate::syntux::parser::Parser;

src/overflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
use std::cmp::min;
44

55
use itertools::Itertools;
6+
use rustc_ast::token::DelimToken;
7+
use rustc_ast::{ast, ptr};
68
use rustc_span::Span;
7-
use syntax::token::DelimToken;
8-
use syntax::{ast, ptr};
99

1010
use crate::closures;
1111
use crate::config::lists::*;

src/pairs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use syntax::ast;
1+
use rustc_ast::ast;
22

33
use crate::config::lists::*;
44
use crate::config::IndentStyle;

src/patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use rustc_ast::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
2+
use rustc_ast::ptr;
13
use rustc_span::{BytePos, Span};
2-
use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
3-
use syntax::ptr;
44

55
use crate::comment::{combine_strs_with_missing_comments, FindUncommented};
66
use crate::config::lists::*;

src/reorder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
use std::cmp::{Ord, Ordering};
1010

11+
use rustc_ast::{ast, attr};
1112
use rustc_span::{symbol::sym, Span};
12-
use syntax::{ast, attr};
1313

1414
use crate::config::Config;
1515
use crate::imports::{merge_use_trees, UseTree};

src/rewrite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::cell::{Cell, RefCell};
44
use std::rc::Rc;
55

6+
use rustc_ast::ptr;
67
use rustc_span::Span;
7-
use syntax::ptr;
88

99
use crate::config::{Config, IndentStyle};
1010
use crate::shape::Shape;

src/skip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Module that contains skip related stuffs.
22
3+
use rustc_ast::ast;
34
use rustc_ast_pretty::pprust;
4-
use syntax::ast;
55

66
/// Take care of skip name stack. You can update it by attributes slice or
77
/// by other context. Query this context to know if you need skip a block.
@@ -56,7 +56,7 @@ fn get_skip_names(kind: &str, attrs: &[ast::Attribute]) -> Vec<String> {
5656
let mut skip_names = vec![];
5757
let path = format!("{}::{}::{}", RUSTFMT, SKIP, kind);
5858
for attr in attrs {
59-
// syntax::ast::Path is implemented partialEq
59+
// rustc_ast::ast::Path is implemented partialEq
6060
// but it is designed for segments.len() == 1
6161
if let ast::AttrKind::Normal(attr_item) = &attr.kind {
6262
if pprust::path_to_string(&attr_item.path) != path {

src/spanned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cmp::max;
22

3+
use rustc_ast::{ast, ptr};
34
use rustc_span::{source_map, Span};
4-
use syntax::{ast, ptr};
55

66
use crate::macros::MacroArg;
77
use crate::utils::{mk_sp, outer_attributes};

src/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use rustc_ast::ast;
12
use rustc_span::Span;
2-
use syntax::ast;
33

44
use crate::comment::recover_comment_removed;
55
use crate::config::Version;

src/syntux/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::panic::{catch_unwind, AssertUnwindSafe};
22
use std::path::{Path, PathBuf};
33

4+
use rustc_ast::ast;
5+
use rustc_ast::token::{DelimToken, TokenKind};
46
use rustc_errors::{Diagnostic, PResult};
57
use rustc_parse::{new_parser_from_file, parser::Parser as RawParser};
68
use rustc_span::{symbol::kw, Span};
7-
use syntax::ast;
8-
use syntax::token::{DelimToken, TokenKind};
99

1010
use crate::syntux::session::ParseSess;
1111
use crate::{Config, Input};
@@ -121,8 +121,8 @@ impl<'a> Parser<'a> {
121121
}
122122
TokenKind::DocComment(s) => {
123123
// we need to get the position of this token before we bump.
124-
let attr = syntax::attr::mk_doc_comment(
125-
syntax::util::comments::doc_comment_style(&s.as_str()),
124+
let attr = rustc_ast::attr::mk_doc_comment(
125+
rustc_ast::util::comments::doc_comment_style(&s.as_str()),
126126
s,
127127
parser.token.span,
128128
);

src/syntux/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::cell::RefCell;
22
use std::path::Path;
33
use std::rc::Rc;
44

5+
use rustc_ast::ast;
56
use rustc_data_structures::sync::{Lrc, Send};
67
use rustc_errors::emitter::{Emitter, EmitterWriter};
78
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel};
@@ -10,7 +11,6 @@ use rustc_span::{
1011
source_map::{FilePathMapping, SourceMap},
1112
BytePos, Span,
1213
};
13-
use syntax::ast;
1414

1515
use crate::config::file_lines::LineRange;
1616
use crate::ignore_path::IgnorePathSet;

src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::iter::ExactSizeIterator;
22
use std::ops::Deref;
33

4+
use rustc_ast::ast::{self, FnRetTy, Mutability};
45
use rustc_span::{symbol::kw, BytePos, Span};
5-
use syntax::ast::{self, FnRetTy, Mutability};
66

77
use crate::config::lists::*;
88
use crate::config::{IndentStyle, TypeDensity, Version};
@@ -551,7 +551,7 @@ impl Rewrite for ast::GenericParam {
551551
_ => (),
552552
}
553553

554-
if let syntax::ast::GenericParamKind::Const { ref ty } = &self.kind {
554+
if let rustc_ast::ast::GenericParamKind::Const { ref ty } = &self.kind {
555555
result.push_str("const ");
556556
result.push_str(rewrite_ident(context, self.ident));
557557
result.push_str(": ");

src/utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::borrow::Cow;
22

3-
use rustc_ast_pretty::pprust;
4-
use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext};
5-
use rustc_target::spec::abi;
6-
use syntax::ast::{
3+
use rustc_ast::ast::{
74
self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility,
85
VisibilityKind,
96
};
10-
use syntax::ptr;
7+
use rustc_ast::ptr;
8+
use rustc_ast_pretty::pprust;
9+
use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext};
10+
use rustc_target::spec::abi;
1111
use unicode_width::UnicodeWidthStr;
1212

1313
use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
@@ -157,7 +157,7 @@ pub(crate) fn format_extern(
157157
}
158158

159159
#[inline]
160-
// Transform `Vec<syntax::ptr::P<T>>` into `Vec<&T>`
160+
// Transform `Vec<rustc_ast::ptr::P<T>>` into `Vec<&T>`
161161
pub(crate) fn ptr_vec_to_ref_vec<T>(vec: &[ptr::P<T>]) -> Vec<&T> {
162162
vec.iter().map(|x| &**x).collect::<Vec<_>>()
163163
}

src/vertical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::cmp;
44

55
use itertools::Itertools;
6+
use rustc_ast::ast;
67
use rustc_span::{BytePos, Span};
7-
use syntax::ast;
88

99
use crate::comment::combine_strs_with_missing_comments;
1010
use crate::config::lists::*;

src/visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::cell::{Cell, RefCell};
22
use std::rc::Rc;
33

4+
use rustc_ast::token::DelimToken;
5+
use rustc_ast::{ast, visit};
46
use rustc_span::{BytePos, Pos, Span};
5-
use syntax::token::DelimToken;
6-
use syntax::{ast, visit};
77

88
use crate::attr::*;
99
use crate::comment::{rewrite_comment, CodeCharKind, CommentCodeSlices};

0 commit comments

Comments
 (0)