refactor: rename libsyntax --> rustc_ast

This commit is contained in:
Caleb Cartwright 2020-03-27 22:29:12 -05:00
parent c1a66e1e22
commit b173b42354
29 changed files with 70 additions and 70 deletions

View file

@ -63,6 +63,10 @@ lazy_static = "1.0.0"
# for more information.
rustc-workspace-hack = "1.0.0"
[dependencies.rustc_ast]
package = "rustc-ap-rustc_ast"
version = "650.0.0"
[dependencies.rustc_ast_pretty]
package = "rustc-ap-rustc_ast_pretty"
version = "650.0.0"
@ -94,7 +98,3 @@ version = "650.0.0"
[dependencies.rustc_target]
package = "rustc-ap-rustc_target"
version = "650.0.0"
[dependencies.syntax]
package = "rustc-ap-rustc_ast"
version = "650.0.0"

View file

@ -1,7 +1,7 @@
//! Format attributes and meta items.
use rustc_ast::ast;
use rustc_span::{symbol::sym, BytePos, Span, DUMMY_SP};
use syntax::ast;
use self::doc_comment::DocCommentFormatter;
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};

View file

@ -58,8 +58,8 @@
use std::borrow::Cow;
use std::cmp::min;
use rustc_ast::{ast, ptr};
use rustc_span::{BytePos, Span};
use syntax::{ast, ptr};
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
use crate::config::IndentStyle;

View file

@ -1,5 +1,5 @@
use rustc_ast::{ast, ptr};
use rustc_span::Span;
use syntax::{ast, ptr};
use crate::attr::get_attrs_from_stmt;
use crate::config::lists::*;

View file

@ -2,9 +2,9 @@ use std::borrow::Cow;
use std::cmp::min;
use itertools::Itertools;
use rustc_ast::token::{DelimToken, LitKind};
use rustc_ast::{ast, ptr};
use rustc_span::{BytePos, Span};
use syntax::token::{DelimToken, LitKind};
use syntax::{ast, ptr};
use crate::chains::rewrite_chain;
use crate::closures;
@ -1314,7 +1314,7 @@ pub(crate) fn can_be_overflowed_expr(
}
ast::ExprKind::MacCall(ref mac) => {
match (
syntax::ast::MacDelimiter::from_token(mac.args.delim()),
rustc_ast::ast::MacDelimiter::from_token(mac.args.delim()),
context.config.overflow_delimited_expr(),
) {
(Some(ast::MacDelimiter::Bracket), true)

View file

@ -4,8 +4,8 @@ use std::collections::HashMap;
use std::io::{self, Write};
use std::time::{Duration, Instant};
use rustc_ast::ast;
use rustc_span::Span;
use syntax::ast;
use self::newline_style::apply_newline_style;
use crate::comment::{CharClasses, FullCodeCharKind};
@ -29,7 +29,7 @@ impl<'b, T: Write + 'b> Session<'b, T> {
return Err(ErrorKind::VersionMismatch);
}
syntax::with_globals(self.config.edition().to_libsyntax_pos_edition(), || {
rustc_ast::with_globals(self.config.edition().to_libsyntax_pos_edition(), || {
if self.config.disable_all_formatting() {
// When the input is from stdin, echo back the input.
if let Input::Text(ref buf) = input {

View file

@ -2,8 +2,8 @@ use std::borrow::Cow;
use std::cmp::Ordering;
use std::fmt;
use rustc_ast::ast::{self, UseTreeKind};
use rustc_span::{source_map, symbol::sym, BytePos, Span, DUMMY_SP};
use syntax::ast::{self, UseTreeKind};
use crate::comment::combine_strs_with_missing_comments;
use crate::config::lists::*;

View file

@ -4,9 +4,9 @@ use std::borrow::Cow;
use std::cmp::{max, min, Ordering};
use regex::Regex;
use rustc_ast::visit;
use rustc_ast::{ast, ptr};
use rustc_span::{source_map, symbol, BytePos, Span, DUMMY_SP};
use syntax::visit;
use syntax::{ast, ptr};
use crate::attr::filter_inline_attrs;
use crate::comment::{
@ -594,7 +594,7 @@ impl<'a> FmtVisitor<'a> {
self.buffer.clear();
}
fn is_type(ty: &Option<syntax::ptr::P<ast::Ty>>) -> bool {
fn is_type(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
match ty {
None => true,
Some(lty) => match lty.kind.opaque_top_hack() {
@ -604,7 +604,7 @@ impl<'a> FmtVisitor<'a> {
}
}
fn is_opaque(ty: &Option<syntax::ptr::P<ast::Ty>>) -> bool {
fn is_opaque(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
match ty {
None => false,
Some(lty) => match lty.kind.opaque_top_hack() {
@ -615,15 +615,15 @@ impl<'a> FmtVisitor<'a> {
}
fn both_type(
a: &Option<syntax::ptr::P<ast::Ty>>,
b: &Option<syntax::ptr::P<ast::Ty>>,
a: &Option<rustc_ast::ptr::P<ast::Ty>>,
b: &Option<rustc_ast::ptr::P<ast::Ty>>,
) -> bool {
is_type(a) && is_type(b)
}
fn both_opaque(
a: &Option<syntax::ptr::P<ast::Ty>>,
b: &Option<syntax::ptr::P<ast::Ty>>,
a: &Option<rustc_ast::ptr::P<ast::Ty>>,
b: &Option<rustc_ast::ptr::P<ast::Ty>>,
) -> bool {
is_opaque(a) && is_opaque(b)
}

View file

@ -19,7 +19,7 @@ use std::rc::Rc;
use failure::Fail;
use ignore;
use syntax::ast;
use rustc_ast::ast;
use crate::comment::LineClasses;
use crate::emitter::Emitter;

View file

@ -12,12 +12,12 @@
use std::collections::HashMap;
use std::panic::{catch_unwind, AssertUnwindSafe};
use rustc_ast::token::{BinOpToken, DelimToken, Token, TokenKind};
use rustc_ast::tokenstream::{Cursor, TokenStream, TokenTree};
use rustc_ast::{ast, ptr};
use rustc_ast_pretty::pprust;
use rustc_parse::{new_parser_from_tts, parser::Parser};
use rustc_span::{symbol::kw, BytePos, Span, Symbol, DUMMY_SP};
use syntax::token::{BinOpToken, DelimToken, Token, TokenKind};
use syntax::tokenstream::{Cursor, TokenStream, TokenTree};
use syntax::{ast, ptr};
use crate::comment::{
contains_comment, CharClasses, FindUncommented, FullCodeCharKind, LineClasses,

View file

@ -2,8 +2,8 @@
use std::iter::repeat;
use rustc_ast::{ast, ptr};
use rustc_span::{BytePos, Span};
use syntax::{ast, ptr};
use crate::comment::{combine_strs_with_missing_comments, rewrite_comment};
use crate::config::lists::*;

View file

@ -2,9 +2,9 @@ use std::borrow::Cow;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use rustc_ast::ast;
use rustc_ast::visit::Visitor;
use rustc_span::symbol::{sym, Symbol};
use syntax::ast;
use syntax::visit::Visitor;
use crate::attr::MetaVisitor;
use crate::config::FileName;

View file

@ -1,6 +1,6 @@
use rustc_ast::ast;
use rustc_ast::visit::Visitor;
use rustc_span::Symbol;
use syntax::ast;
use syntax::visit::Visitor;
use crate::attr::MetaVisitor;
use crate::syntux::parser::Parser;

View file

@ -3,9 +3,9 @@
use std::cmp::min;
use itertools::Itertools;
use rustc_ast::token::DelimToken;
use rustc_ast::{ast, ptr};
use rustc_span::Span;
use syntax::token::DelimToken;
use syntax::{ast, ptr};
use crate::closures;
use crate::config::lists::*;

View file

@ -1,4 +1,4 @@
use syntax::ast;
use rustc_ast::ast;
use crate::config::lists::*;
use crate::config::IndentStyle;

View file

@ -1,6 +1,6 @@
use rustc_ast::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
use rustc_ast::ptr;
use rustc_span::{BytePos, Span};
use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
use syntax::ptr;
use crate::comment::{combine_strs_with_missing_comments, FindUncommented};
use crate::config::lists::*;

View file

@ -8,8 +8,8 @@
use std::cmp::{Ord, Ordering};
use rustc_ast::{ast, attr};
use rustc_span::{symbol::sym, Span};
use syntax::{ast, attr};
use crate::config::Config;
use crate::imports::{merge_use_trees, UseTree};

View file

@ -3,8 +3,8 @@
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use rustc_ast::ptr;
use rustc_span::Span;
use syntax::ptr;
use crate::config::{Config, IndentStyle};
use crate::shape::Shape;

View file

@ -1,7 +1,7 @@
//! Module that contains skip related stuffs.
use rustc_ast::ast;
use rustc_ast_pretty::pprust;
use syntax::ast;
/// Take care of skip name stack. You can update it by attributes slice or
/// 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> {
let mut skip_names = vec![];
let path = format!("{}::{}::{}", RUSTFMT, SKIP, kind);
for attr in attrs {
// syntax::ast::Path is implemented partialEq
// rustc_ast::ast::Path is implemented partialEq
// but it is designed for segments.len() == 1
if let ast::AttrKind::Normal(attr_item) = &attr.kind {
if pprust::path_to_string(&attr_item.path) != path {

View file

@ -1,7 +1,7 @@
use std::cmp::max;
use rustc_ast::{ast, ptr};
use rustc_span::{source_map, Span};
use syntax::{ast, ptr};
use crate::macros::MacroArg;
use crate::utils::{mk_sp, outer_attributes};

View file

@ -1,5 +1,5 @@
use rustc_ast::ast;
use rustc_span::Span;
use syntax::ast;
use crate::comment::recover_comment_removed;
use crate::config::Version;

View file

@ -1,11 +1,11 @@
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::path::{Path, PathBuf};
use rustc_ast::ast;
use rustc_ast::token::{DelimToken, TokenKind};
use rustc_errors::{Diagnostic, PResult};
use rustc_parse::{new_parser_from_file, parser::Parser as RawParser};
use rustc_span::{symbol::kw, Span};
use syntax::ast;
use syntax::token::{DelimToken, TokenKind};
use crate::syntux::session::ParseSess;
use crate::{Config, Input};
@ -121,8 +121,8 @@ impl<'a> Parser<'a> {
}
TokenKind::DocComment(s) => {
// we need to get the position of this token before we bump.
let attr = syntax::attr::mk_doc_comment(
syntax::util::comments::doc_comment_style(&s.as_str()),
let attr = rustc_ast::attr::mk_doc_comment(
rustc_ast::util::comments::doc_comment_style(&s.as_str()),
s,
parser.token.span,
);

View file

@ -2,6 +2,7 @@ use std::cell::RefCell;
use std::path::Path;
use std::rc::Rc;
use rustc_ast::ast;
use rustc_data_structures::sync::{Lrc, Send};
use rustc_errors::emitter::{Emitter, EmitterWriter};
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel};
@ -10,7 +11,6 @@ use rustc_span::{
source_map::{FilePathMapping, SourceMap},
BytePos, Span,
};
use syntax::ast;
use crate::config::file_lines::LineRange;
use crate::ignore_path::IgnorePathSet;

View file

@ -1,8 +1,8 @@
use std::iter::ExactSizeIterator;
use std::ops::Deref;
use rustc_ast::ast::{self, FnRetTy, Mutability};
use rustc_span::{symbol::kw, BytePos, Span};
use syntax::ast::{self, FnRetTy, Mutability};
use crate::config::lists::*;
use crate::config::{IndentStyle, TypeDensity, Version};
@ -551,7 +551,7 @@ impl Rewrite for ast::GenericParam {
_ => (),
}
if let syntax::ast::GenericParamKind::Const { ref ty } = &self.kind {
if let rustc_ast::ast::GenericParamKind::Const { ref ty } = &self.kind {
result.push_str("const ");
result.push_str(rewrite_ident(context, self.ident));
result.push_str(": ");

View file

@ -1,13 +1,13 @@
use std::borrow::Cow;
use rustc_ast_pretty::pprust;
use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext};
use rustc_target::spec::abi;
use syntax::ast::{
use rustc_ast::ast::{
self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility,
VisibilityKind,
};
use syntax::ptr;
use rustc_ast::ptr;
use rustc_ast_pretty::pprust;
use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext};
use rustc_target::spec::abi;
use unicode_width::UnicodeWidthStr;
use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
@ -157,7 +157,7 @@ pub(crate) fn format_extern(
}
#[inline]
// Transform `Vec<syntax::ptr::P<T>>` into `Vec<&T>`
// Transform `Vec<rustc_ast::ptr::P<T>>` into `Vec<&T>`
pub(crate) fn ptr_vec_to_ref_vec<T>(vec: &[ptr::P<T>]) -> Vec<&T> {
vec.iter().map(|x| &**x).collect::<Vec<_>>()
}

View file

@ -3,8 +3,8 @@
use std::cmp;
use itertools::Itertools;
use rustc_ast::ast;
use rustc_span::{BytePos, Span};
use syntax::ast;
use crate::comment::combine_strs_with_missing_comments;
use crate::config::lists::*;

View file

@ -1,9 +1,9 @@
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use rustc_ast::token::DelimToken;
use rustc_ast::{ast, visit};
use rustc_span::{BytePos, Pos, Span};
use syntax::token::DelimToken;
use syntax::{ast, visit};
use crate::attr::*;
use crate::comment::{rewrite_comment, CodeCharKind, CommentCodeSlices};

View file

@ -3,7 +3,7 @@
// Imports.
// Long import.
use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefaultImpl};
use rustc_ast::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefaultImpl};
use exceedingly::looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{ItemA, ItemB};
use exceedingly::loooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{ItemA, ItemB};
@ -15,30 +15,30 @@ use list::{
use test::{ Other /* C */ , /* A */ self /* B */ };
use syntax::{self};
use rustc_ast::{self};
use {/* Pre-comment! */
Foo, Bar /* comment */};
use Foo::{Bar, Baz};
pub use syntax::ast::{Expr_, Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath};
pub use rustc_ast::ast::{Expr_, Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath};
use syntax::some::{};
use rustc_ast::some::{};
use self;
use std::io::{self};
use std::io::self;
mod Foo {
pub use syntax::ast::{
pub use rustc_ast::ast::{
ItemForeignMod,
ItemImpl,
ItemImpl,
ItemMac,
ItemMod,
ItemStatic,
ItemStatic,
ItemDefaultImpl
};
mod Foo2 {
pub use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, self, ItemDefaultImpl};
pub use rustc_ast::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, self, ItemDefaultImpl};
}
}

View file

@ -9,7 +9,7 @@ use exceedingly::loooooooooooooooooooooooooooooooooooooooooooooooooooooooong::im
use exceedingly::looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong::import::path::{
ItemA, ItemB,
};
use syntax::ast::{ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic};
use rustc_ast::ast::{ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic};
use list::{
// Another item
@ -22,8 +22,8 @@ use list::{
use test::{/* A */ self /* B */, Other /* C */};
pub use syntax::ast::{Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath, Expr_};
use syntax::{self};
pub use rustc_ast::ast::{Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath, Expr_};
use rustc_ast::{self};
use Foo::{Bar, Baz};
use {Bar /* comment */, /* Pre-comment! */ Foo};
@ -31,12 +31,12 @@ use std::io;
use std::io::{self};
mod Foo {
pub use syntax::ast::{
pub use rustc_ast::ast::{
ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic,
};
mod Foo2 {
pub use syntax::ast::{
pub use rustc_ast::ast::{
self, ItemDefaultImpl, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic,
};
}