syntax::print -> new crate rustc_ast_pretty

This commit is contained in:
Mazdak Farrokhzad 2020-01-11 17:02:46 +01:00
parent 98fd6a5c88
commit e233331a51
62 changed files with 129 additions and 81 deletions

View File

@ -3093,6 +3093,7 @@ dependencies = [
"rustc-rayon",
"rustc-rayon-core",
"rustc_apfloat",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3359,6 +3360,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
@ -3375,6 +3377,7 @@ name = "rustc_ast_passes"
version = "0.0.0"
dependencies = [
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3385,10 +3388,21 @@ dependencies = [
"syntax",
]
[[package]]
name = "rustc_ast_pretty"
version = "0.0.0"
dependencies = [
"log",
"rustc_data_structures",
"rustc_span",
"syntax",
]
[[package]]
name = "rustc_attr"
version = "0.0.0"
dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
@ -3406,6 +3420,7 @@ version = "0.0.0"
dependencies = [
"fmt_macros",
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3526,6 +3541,7 @@ dependencies = [
"lazy_static 1.4.0",
"log",
"rustc",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_error_codes",
@ -3572,6 +3588,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc_ast_passes",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3602,6 +3619,7 @@ version = "0.0.0"
name = "rustc_hir"
version = "0.0.0"
dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
@ -3693,6 +3711,7 @@ version = "0.0.0"
dependencies = [
"log",
"rustc",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3734,6 +3753,7 @@ dependencies = [
"log",
"memmap",
"rustc",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3762,6 +3782,7 @@ dependencies = [
"polonius-engine",
"rustc",
"rustc_apfloat",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3805,6 +3826,7 @@ version = "0.0.0"
dependencies = [
"bitflags",
"log",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3872,6 +3894,7 @@ dependencies = [
"log",
"rustc",
"rustc_ast_lowering",
"rustc_ast_pretty",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@ -3893,6 +3916,7 @@ dependencies = [
"rls-data",
"rls-span",
"rustc",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_hir",

View File

@ -21,6 +21,8 @@ rustc-rayon = "0.3.0"
rustc-rayon-core = "0.3.0"
polonius-engine = "0.11.0"
rustc_apfloat = { path = "../librustc_apfloat" }
# FIXME(Centril): remove this dependency when stuff is moved to rustc_lint.
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_feature = { path = "../librustc_feature" }
rustc_hir = { path = "../librustc_hir" }

View File

@ -12,6 +12,7 @@ doctest = false
[dependencies]
log = { version = "0.4", features = ["release_max_level_info", "std"] }
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_hir = { path = "../librustc_hir" }
rustc_target = { path = "../librustc_target" }
rustc_data_structures = { path = "../librustc_data_structures" }

View File

@ -38,6 +38,7 @@ use rustc::dep_graph::DepGraph;
use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
use rustc::hir::map::Map;
use rustc::{bug, span_bug};
use rustc_ast_pretty::pprust;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
@ -60,7 +61,6 @@ use syntax::ast;
use syntax::ast::*;
use syntax::attr;
use syntax::node_id::NodeMap;
use syntax::print::pprust;
use syntax::token::{self, Nonterminal, Token};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::visit::{self, Visitor};

View File

@ -10,6 +10,7 @@ path = "lib.rs"
[dependencies]
log = "0.4"
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }

View File

@ -6,6 +6,7 @@
// This pass is supposed to perform only simple checks not requiring name resolution
// or type checking or some other kind of complex analysis.
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Applicability, FatalError};
use rustc_parse::validate_attr;
@ -19,7 +20,6 @@ use std::mem;
use syntax::ast::*;
use syntax::attr;
use syntax::expand::is_proc_macro_attr;
use syntax::print::pprust;
use syntax::visit::{self, Visitor};
use syntax::walk_list;

View File

@ -0,0 +1,16 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustc_ast_pretty"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_ast_pretty"
path = "lib.rs"
doctest = false
[dependencies]
log = "0.4"
rustc_span = { path = "../librustc_span" }
rustc_data_structures = { path = "../librustc_data_structures" }
syntax = { path = "../libsyntax" }

View File

@ -1,4 +1,4 @@
use crate::print::pp::Printer;
use crate::pp::Printer;
use std::borrow::Cow;
impl Printer {

View File

@ -0,0 +1,6 @@
#![feature(bool_to_option)]
#![feature(crate_visibility_modifier)]
mod helpers;
pub mod pp;
pub mod pprust;

View File

@ -1,21 +1,20 @@
use crate::ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
use crate::ast::{Attribute, GenericArg, MacArgs};
use crate::ast::{GenericBound, SelfKind, TraitBoundModifier};
use crate::attr;
use crate::print::pp::Breaks::{Consistent, Inconsistent};
use crate::print::pp::{self, Breaks};
use crate::ptr::P;
use crate::token::{self, BinOpToken, DelimToken, Nonterminal, Token, TokenKind};
use crate::tokenstream::{self, TokenStream, TokenTree};
use crate::util::classify;
use crate::util::comments;
use crate::util::parser::{self, AssocOp, Fixity};
use crate::pp::Breaks::{Consistent, Inconsistent};
use crate::pp::{self, Breaks};
use rustc_data_structures::sync::Once;
use rustc_span::edition::Edition;
use rustc_span::source_map::{dummy_spanned, SourceMap, Spanned};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, FileName, Span};
use syntax::ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
use syntax::ast::{Attribute, GenericArg, MacArgs};
use syntax::ast::{GenericBound, SelfKind, TraitBoundModifier};
use syntax::attr;
use syntax::ptr::P;
use syntax::token::{self, BinOpToken, DelimToken, Nonterminal, Token, TokenKind};
use syntax::tokenstream::{self, TokenStream, TokenTree};
use syntax::util::parser::{self, AssocOp, Fixity};
use syntax::util::{classify, comments};
use std::borrow::Cow;

View File

@ -1,9 +1,9 @@
use super::*;
use crate::ast;
use crate::with_default_globals;
use rustc_span;
use rustc_span::source_map::{dummy_spanned, respan};
use syntax::ast;
use syntax::attr::with_default_globals;
fn fun_to_string(
decl: &ast::FnDecl,

View File

@ -10,6 +10,7 @@ path = "lib.rs"
doctest = false
[dependencies]
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_errors = { path = "../librustc_errors" }
rustc_span = { path = "../librustc_span" }

View File

@ -2,6 +2,7 @@
use super::{find_by_name, mark_used};
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, Handler};
use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
use rustc_macros::HashStable_Generic;
@ -10,7 +11,6 @@ use rustc_span::hygiene::Transparency;
use rustc_span::{symbol::sym, symbol::Symbol, Span};
use std::num::NonZeroU32;
use syntax::ast::{self, Attribute, MetaItem, MetaItemKind, NestedMetaItem};
use syntax::print::pprust;
pub fn is_builtin_attr(attr: &Attribute) -> bool {
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()

View File

@ -12,6 +12,7 @@ doctest = false
[dependencies]
fmt_macros = { path = "../libfmt_macros" }
log = "0.4"
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }

View File

@ -1,11 +1,11 @@
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_ast_pretty::pprust;
use rustc_expand::base::*;
use rustc_parse::parser::Parser;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
use syntax::ast::{self, *};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, TokenKind};
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};

View File

@ -1,6 +1,6 @@
use rustc_ast_pretty::pprust;
use rustc_expand::base;
use rustc_span;
use syntax::print;
use syntax::tokenstream::TokenStream;
pub fn expand_log_syntax<'cx>(
@ -8,7 +8,7 @@ pub fn expand_log_syntax<'cx>(
sp: rustc_span::Span,
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
println!("{}", print::pprust::tts_to_string(tts));
println!("{}", pprust::tts_to_string(tts));
// any so that `log_syntax` can be invoked as an expression and item.
base::DummyResult::any_valid(sp)

View File

@ -1,5 +1,6 @@
use std::mem;
use rustc_ast_pretty::pprust;
use rustc_expand::base::{ExtCtxt, Resolver};
use rustc_expand::expand::{AstFragment, ExpansionConfig};
use rustc_session::parse::ParseSess;
@ -10,7 +11,6 @@ use smallvec::smallvec;
use syntax::ast::{self, Ident};
use syntax::attr;
use syntax::expand::is_proc_macro_attr;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::visit::{self, Visitor};

View File

@ -1,3 +1,4 @@
use rustc_ast_pretty::pprust;
use rustc_expand::base::{self, *};
use rustc_expand::panictry;
use rustc_parse::{self, new_sub_parser_from_file, parser::Parser, DirectoryOwnership};
@ -5,7 +6,6 @@ use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
use rustc_span::symbol::Symbol;
use rustc_span::{self, Pos, Span};
use syntax::ast;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;
use syntax::tokenstream::TokenStream;

View File

@ -2,13 +2,13 @@
/// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
use crate::util::check_builtin_macro_attribute;
use rustc_ast_pretty::pprust;
use rustc_expand::base::*;
use rustc_span::source_map::respan;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use std::iter;

View File

@ -14,6 +14,7 @@ lazy_static = "1.0"
log = "0.4"
env_logger = { version = "0.7", default-features = false }
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_target = { path = "../librustc_target" }
rustc_lint = { path = "../librustc_lint" }
rustc_data_structures = { path = "../librustc_data_structures" }

View File

@ -5,14 +5,13 @@ use rustc::session::config::{Input, PpMode, PpSourceMode};
use rustc::session::Session;
use rustc::ty::{self, TyCtxt};
use rustc::util::common::ErrorReported;
use rustc_ast_pretty::pprust;
use rustc_hir as hir;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::print as pprust_hir;
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
use rustc_span::FileName;
use syntax::ast;
use syntax::print::pprust;
use std::cell::Cell;
use std::fs::File;

View File

@ -14,6 +14,7 @@ doctest = false
rustc_serialize = { path = "../libserialize", package = "serialize" }
log = "0.4"
rustc_span = { path = "../librustc_span" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_ast_passes = { path = "../librustc_ast_passes" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }

View File

@ -5,6 +5,7 @@ use crate::mbe::macro_rules::annotate_err_with_kind;
use crate::placeholders::{placeholder, PlaceholderExpander};
use crate::proc_macro::collect_derives;
use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, is_builtin_attr, HasAttrs};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, FatalError, PResult};
@ -20,7 +21,6 @@ use rustc_span::{FileName, Span, DUMMY_SP};
use syntax::ast::{self, AttrItem, Block, Ident, LitKind, NodeId, PatKind, Path};
use syntax::ast::{ItemKind, MacArgs, MacStmtStyle, StmtKind};
use syntax::mut_visit::*;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;
use syntax::tokenstream::{TokenStream, TokenTree};

View File

@ -76,12 +76,12 @@ use TokenTreeOrTokenTreeSlice::*;
use crate::mbe::{self, TokenTree};
use rustc_ast_pretty::pprust;
use rustc_parse::parser::{FollowedByType, Parser, PathStyle};
use rustc_parse::Directory;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::{kw, sym, Symbol};
use syntax::ast::{Ident, Name};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, DocComment, Nonterminal, Token};
use syntax::tokenstream::TokenStream;

View File

@ -8,6 +8,7 @@ use crate::mbe::macro_parser::{Error, Failure, Success};
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
use crate::mbe::transcribe::transcribe;
use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, TransparencyError};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
@ -21,7 +22,6 @@ use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
use syntax::ast;
use syntax::print::pprust;
use syntax::token::{self, NtTT, Token, TokenKind::*};
use syntax::tokenstream::{DelimSpan, TokenStream};

View File

@ -1,10 +1,10 @@
use crate::mbe::macro_parser;
use crate::mbe::{Delimited, KleeneOp, KleeneToken, SequenceRepetition, TokenTree};
use rustc_ast_pretty::pprust;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::kw;
use syntax::ast;
use syntax::print::pprust;
use syntax::token::{self, Token};
use syntax::tokenstream;

View File

@ -1,5 +1,6 @@
use crate::base::ExtCtxt;
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::Diagnostic;
use rustc_parse::lexer::nfc_normalize;
@ -8,7 +9,6 @@ use rustc_session::parse::ParseSess;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span};
use syntax::ast;
use syntax::print::pprust;
use syntax::token;
use syntax::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
use syntax::util::comments;

View File

@ -10,6 +10,7 @@ path = "lib.rs"
doctest = false
[dependencies]
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_target = { path = "../librustc_target" }
rustc_macros = { path = "../librustc_macros" }
rustc_data_structures = { path = "../librustc_data_structures" }

View File

@ -1,11 +1,11 @@
use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent};
use rustc_ast_pretty::pp::{self, Breaks};
use rustc_ast_pretty::pprust::{self, Comments, PrintState};
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::symbol::kw;
use rustc_span::{self, BytePos, FileName};
use rustc_target::spec::abi::Abi;
use syntax::ast;
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
use syntax::print::pp::{self, Breaks};
use syntax::print::pprust::{self, Comments, PrintState};
use syntax::util::parser::{self, AssocOp, Fixity};
use crate::hir;

View File

@ -12,6 +12,7 @@ path = "lib.rs"
log = "0.4"
unicode-security = "0.0.2"
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_errors = { path = "../librustc_errors" }
rustc_hir = { path = "../librustc_hir" }

View File

@ -25,6 +25,7 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}
use rustc::hir::map::Map;
use rustc::traits::misc::can_type_implement_copy;
use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt};
use rustc_ast_pretty::pprust::{self, expr_to_string};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_feature::Stability;
@ -41,7 +42,6 @@ use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, Span};
use syntax::ast::{self, Expr};
use syntax::attr::{self, HasAttrs};
use syntax::print::pprust::{self, expr_to_string};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::visit::FnKind;

View File

@ -1,10 +1,10 @@
use crate::context::{CheckLintNameResult, LintStore};
use crate::late::unerased_lint_store;
use rustc::hir::map::Map;
use rustc::lint::struct_lint_level;
use rustc::lint::{LintLevelMap, LintLevelSets, LintSet, LintSource};
use rustc::lint::{struct_lint_level, LintLevelMap, LintLevelSets, LintSet, LintSource};
use rustc::ty::query::Providers;
use rustc::ty::TyCtxt;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
@ -17,7 +17,6 @@ use rustc_span::source_map::MultiSpan;
use rustc_span::symbol::{sym, Symbol};
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use syntax::unwrap_or;
use std::cmp;

View File

@ -1,6 +1,7 @@
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc::ty::adjustment;
use rustc::ty::{self, Ty};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{pluralize, Applicability};
use rustc_feature::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
@ -13,7 +14,6 @@ use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span};
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use syntax::util::parser;
use log::debug;

View File

@ -15,6 +15,7 @@ log = "0.4"
memmap = "0.7"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }

View File

@ -1236,7 +1236,7 @@ impl EncodeContext<'tcx> {
/// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef<'_>) {
use syntax::print::pprust;
use rustc_ast_pretty::pprust;
let def_id = self.tcx.hir().local_def_id(macro_def.hir_id);
record!(self.per_def.kind[def_id] <- EntryKind::MacroDef(self.lazy(MacroDef {
body: pprust::tts_to_string(macro_def.body.clone()),

View File

@ -17,6 +17,7 @@ log = "0.4"
log_settings = "0.1.1"
polonius-engine = "0.11.0"
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }

View File

@ -1,6 +1,6 @@
use rustc_ast_pretty::pprust;
use rustc_span::symbol::{sym, Symbol};
use syntax::ast::{self, MetaItem};
use syntax::print::pprust;
use rustc_data_structures::work_queue::WorkQueue;
use rustc_index::bit_set::{BitSet, HybridBitSet};

View File

@ -12,6 +12,7 @@ doctest = false
[dependencies]
bitflags = "1.0"
log = "0.4"
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_feature = { path = "../librustc_feature" }

View File

@ -1,9 +1,9 @@
use super::{StringReader, UnmatchedBrace};
use rustc_ast_pretty::pprust::token_to_string;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::PResult;
use rustc_span::Span;
use syntax::print::pprust::token_to_string;
use syntax::token::{self, Token};
use syntax::tokenstream::{
DelimSpan,

View File

@ -4,12 +4,12 @@
#![feature(crate_visibility_modifier)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Diagnostic, FatalError, Level, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::{FileName, SourceFile, Span};
use syntax::ast;
use syntax::print::pprust;
use syntax::token::{self, Nonterminal};
use syntax::tokenstream::{self, TokenStream, TokenTree};

View File

@ -1,9 +1,9 @@
use super::{Parser, PathStyle, TokenType};
use rustc_ast_pretty::pprust;
use rustc_errors::PResult;
use rustc_span::{Span, Symbol};
use syntax::ast;
use syntax::attr;
use syntax::print::pprust;
use syntax::token::{self, Nonterminal};
use syntax::util::comments;

View File

@ -1,5 +1,6 @@
use super::{BlockMode, Parser, PathStyle, SemiColonMode, SeqSep, TokenExpectType, TokenType};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, struct_span_err};
use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult};
@ -10,7 +11,6 @@ use syntax::ast::{
self, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, Param,
};
use syntax::ast::{AttrVec, ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, token_can_begin_expr, TokenKind};
use syntax::util::parser::AssocOp;

View File

@ -3,6 +3,7 @@ use super::{BlockMode, Parser, PathStyle, PrevTokenKind, Restrictions, TokenType
use super::{SemiColonMode, SeqSep, TokenExpectType};
use crate::maybe_recover_from_interpolated_ty_qpath;
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, PResult};
use rustc_span::source_map::{self, Span, Spanned};
use rustc_span::symbol::{kw, sym, Symbol};
@ -12,7 +13,6 @@ use syntax::ast::{
AnonConst, BinOp, BinOpKind, FnDecl, FunctionRetTy, Mac, Param, Ty, TyKind, UnOp,
};
use syntax::ast::{Arm, BlockCheckMode, Expr, ExprKind, IsAsync, Label, Movability, RangeLimits};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, Token, TokenKind};
use syntax::util::classify;

View File

@ -3,6 +3,7 @@ use super::{FollowedByType, Parser, PathStyle};
use crate::maybe_whole;
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult, StashKey};
use rustc_span::source_map::{self, respan, Span};
use rustc_span::symbol::{kw, sym, Symbol};
@ -13,7 +14,6 @@ use syntax::ast::{BindingMode, Block, FnDecl, FnSig, Mac, MacArgs, MacDelimiter,
use syntax::ast::{Constness, Defaultness, Extern, IsAsync, IsAuto, PathSegment, StrLit, Unsafety};
use syntax::ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData};
use syntax::ast::{FnHeader, ForeignItem, ForeignItemKind, Mutability, Visibility, VisibilityKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree};

View File

@ -16,6 +16,7 @@ use crate::lexer::UnmatchedBrace;
use crate::{Directory, DirectoryOwnership};
use log::debug;
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, FatalError, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::respan;
@ -23,7 +24,6 @@ use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
use syntax::ast::{self, AttrStyle, AttrVec, CrateSugar, Extern, Ident, Unsafety, DUMMY_NODE_ID};
use syntax::ast::{IsAsync, MacArgs, MacDelimiter, Mutability, StrLit, Visibility, VisibilityKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, DelimToken, Token, TokenKind};
use syntax::tokenstream::{self, DelimSpan, TokenStream, TokenTree, TreeAndJoint};

View File

@ -1,12 +1,12 @@
use super::{Parser, PathStyle};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult};
use rustc_span::source_map::{respan, Span, Spanned};
use rustc_span::symbol::{kw, sym};
use syntax::ast::{self, AttrVec, Attribute, FieldPat, Mac, Pat, PatKind, RangeEnd, RangeSyntax};
use syntax::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf};
use syntax::mut_visit::{noop_visit_mac, noop_visit_pat, MutVisitor};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token;

View File

@ -17,6 +17,7 @@ syntax = { path = "../libsyntax" }
arena = { path = "../libarena" }
rustc = { path = "../librustc" }
rustc_ast_lowering = { path = "../librustc_ast_lowering" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }

View File

@ -4,6 +4,7 @@ use log::debug;
use rustc::bug;
use rustc::session::Session;
use rustc::ty::{self, DefIdTree};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
use rustc_feature::BUILTIN_ATTRIBUTES;
@ -16,7 +17,6 @@ use rustc_span::source_map::SourceMap;
use rustc_span::symbol::{kw, Symbol};
use rustc_span::{BytePos, MultiSpan, Span};
use syntax::ast::{self, Ident, Path};
use syntax::print::pprust;
use syntax::util::lev_distance::find_best_match_for_name;
use crate::imports::{ImportDirective, ImportDirectiveSubclass, ImportResolver};

View File

@ -25,6 +25,7 @@ use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn};
use rustc::span_bug;
use rustc::ty::query::Providers;
use rustc::ty::{self, DefIdTree, ResolverOutputs};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::ptr_key::PtrKey;
use rustc_data_structures::sync::Lrc;
@ -47,7 +48,6 @@ use syntax::ast::{Crate, CRATE_NODE_ID};
use syntax::ast::{ItemKind, Path};
use syntax::attr;
use syntax::node_id::{NodeMap, NodeSet};
use syntax::print::pprust;
use syntax::unwrap_or;
use syntax::visit::{self, Visitor};

View File

@ -10,6 +10,7 @@ use rustc::middle::stability;
use rustc::session::parse::feature_err;
use rustc::session::Session;
use rustc::{lint, span_bug, ty};
use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, StabilityLevel};
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::SyntaxExtension;
@ -24,7 +25,6 @@ use rustc_span::hygiene::{self, ExpnData, ExpnId, ExpnKind};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
use syntax::ast::{self, Ident, NodeId};
use syntax::print::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_span::hygiene::{AstPass, MacroKind};

View File

@ -11,6 +11,7 @@ path = "lib.rs"
[dependencies]
log = "0.4"
rustc = { path = "../librustc" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_hir = { path = "../librustc_hir" }

View File

@ -16,22 +16,21 @@
use rustc::session::config::Input;
use rustc::span_bug;
use rustc::ty::{self, DefIdTree, TyCtxt};
use rustc_ast_pretty::pprust::{bounds_to_string, generic_params_to_string, ty_to_string};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def::{DefKind as HirDefKind, Res};
use rustc_hir::def_id::DefId;
use std::env;
use std::path::Path;
use rustc_span::source_map::{respan, DUMMY_SP};
use rustc_span::*;
use syntax::ast::{self, Attribute, NodeId, PatKind};
use syntax::print::pprust::{bounds_to_string, generic_params_to_string, ty_to_string};
use syntax::ptr::P;
use syntax::token;
use syntax::visit::{self, Visitor};
use syntax::walk_list;
use std::env;
use std::path::Path;
use crate::dumper::{Access, Dumper};
use crate::sig;
use crate::span_utils::SpanUtils;

View File

@ -13,11 +13,17 @@ use rustc::middle::privacy::AccessLevels;
use rustc::session::config::{CrateType, Input, OutputType};
use rustc::ty::{self, DefIdTree, TyCtxt};
use rustc::{bug, span_bug};
use rustc_ast_pretty::pprust::{self, param_to_string, ty_to_string};
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind as HirDefKind, Res};
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_hir::Node;
use rustc_span::source_map::Spanned;
use rustc_span::*;
use syntax::ast::{self, Attribute, NodeId, PatKind, DUMMY_NODE_ID};
use syntax::util::comments::strip_doc_comment_decoration;
use syntax::visit::{self, Visitor};
use std::cell::Cell;
use std::default::Default;
@ -26,14 +32,6 @@ use std::fs::File;
use std::io::BufWriter;
use std::path::{Path, PathBuf};
use rustc_span::source_map::Spanned;
use rustc_span::*;
use syntax::ast::{self, Attribute, NodeId, PatKind, DUMMY_NODE_ID};
use syntax::print::pprust;
use syntax::print::pprust::{param_to_string, ty_to_string};
use syntax::util::comments::strip_doc_comment_decoration;
use syntax::visit::{self, Visitor};
use dump_visitor::DumpVisitor;
use span_utils::SpanUtils;

View File

@ -29,9 +29,9 @@ use crate::{id_from_def_id, id_from_node_id, SaveContext};
use rls_data::{SigElement, Signature};
use rustc_ast_pretty::pprust;
use rustc_hir::def::{DefKind, Res};
use syntax::ast::{self, Extern, NodeId};
use syntax::print::pprust;
pub fn item_signature(item: &ast::Item, scx: &SaveContext<'_, '_>) -> Option<Signature> {
if !scx.config.signatures {

View File

@ -44,6 +44,7 @@ use std::sync::Arc;
use rustc::middle::privacy::AccessLevels;
use rustc::middle::stability;
use rustc_ast_pretty::pprust;
use rustc_data_structures::flock;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_feature::UnstableFeatures;
@ -57,7 +58,6 @@ use rustc_span::symbol::{sym, Symbol};
use serde::ser::SerializeSeq;
use serde::{Serialize, Serializer};
use syntax::ast;
use syntax::print::pprust;
use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy};
use crate::config::RenderOptions;

View File

@ -21,6 +21,7 @@
extern crate env_logger;
extern crate getopts;
extern crate rustc;
extern crate rustc_ast_pretty;
extern crate rustc_attr;
extern crate rustc_data_structures;
extern crate rustc_driver;

View File

@ -141,7 +141,7 @@ pub fn run(options: Options) -> i32 {
// Look for `#![doc(test(no_crate_inject))]`, used by crates in the std facade.
fn scrape_test_config(krate: &::rustc_hir::Crate) -> TestOptions {
use syntax::print::pprust;
use rustc_ast_pretty::pprust;
let mut opts =
TestOptions { no_crate_inject: false, display_warnings: false, attrs: Vec::new() };

View File

@ -1417,7 +1417,7 @@ pub enum MacDelimiter {
}
impl MacDelimiter {
crate fn to_token(self) -> DelimToken {
pub fn to_token(self) -> DelimToken {
match self {
MacDelimiter::Parenthesis => DelimToken::Paren,
MacDelimiter::Bracket => DelimToken::Bracket,
@ -1480,7 +1480,7 @@ pub struct StrLit {
}
impl StrLit {
crate fn as_lit(&self) -> Lit {
pub fn as_lit(&self) -> Lit {
let token_kind = match self.style {
StrStyle::Cooked => token::Str,
StrStyle::Raw(n) => token::StrRaw(n),

View File

@ -47,12 +47,6 @@ pub mod token;
pub mod tokenstream;
pub mod visit;
pub mod print {
mod helpers;
pub mod pp;
pub mod pprust;
}
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
/// Requirements for a `StableHashingContext` to be used in this crate.

View File

@ -1,13 +1,11 @@
pub use CommentStyle::*;
use crate::ast;
use rustc_span::source_map::SourceMap;
use rustc_span::{BytePos, CharPos, FileName, Pos};
use std::usize;
use log::debug;
use std::usize;
#[cfg(test)]
mod tests;
@ -190,7 +188,7 @@ fn split_block_comment_into_lines(text: &str, col: CharPos) -> Vec<String> {
// it appears this function is called only from pprust... that's
// probably not a good thing.
crate fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec<Comment> {
pub fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec<Comment> {
let cm = SourceMap::new(sm.path_mapping().clone());
let source_file = cm.new_source_file(path, src);
let text = (*source_file.src.as_ref().unwrap()).clone();

View File

@ -367,7 +367,7 @@ pub fn prec_let_scrutinee_needs_par() -> usize {
///
/// Conversely, suppose that we have `(let _ = a) OP b` and `order` is that of `OP`.
/// Can we print this as `let _ = a OP b`?
crate fn needs_par_as_let_scrutinee(order: i8) -> bool {
pub fn needs_par_as_let_scrutinee(order: i8) -> bool {
order <= prec_let_scrutinee_needs_par() as i8
}