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

rustc_parser: cleanup imports #67045

Merged
merged 1 commit into from
Dec 6, 2019
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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,6 @@ dependencies = [
"rustc_errors",
"rustc_feature",
"rustc_lexer",
"rustc_target",
"smallvec 1.0.0",
"syntax",
"syntax_pos",
Expand Down
9 changes: 4 additions & 5 deletions src/librustc_parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ doctest = false
[dependencies]
bitflags = "1.0"
log = "0.4"
syntax_pos = { path = "../libsyntax_pos" }
syntax = { path = "../libsyntax" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_feature = { path = "../librustc_feature" }
rustc_lexer = { path = "../librustc_lexer" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_errors = { path = "../librustc_errors" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ I never liked the errors naming, so this is nice to see.

rustc_error_codes = { path = "../librustc_error_codes" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
syntax_pos = { path = "../libsyntax_pos" }
syntax = { path = "../libsyntax" }
2 changes: 1 addition & 1 deletion src/librustc_parse/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use crate::validate_attr;
use rustc_feature::Features;
use rustc_errors::Applicability;
use syntax::attr::HasAttrs;
use syntax::feature_gate::{feature_err, get_features};
use syntax::attr;
Expand All @@ -21,7 +22,6 @@ use syntax::sess::ParseSess;
use syntax::util::map_in_place::MapInPlace;
use syntax_pos::symbol::sym;

use errors::Applicability;
use smallvec::SmallVec;

/// A folder that strips out items that do not belong in the current configuration.
Expand Down
11 changes: 5 additions & 6 deletions src/librustc_parse/lexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use rustc_data_structures::sync::Lrc;
use rustc_errors::{FatalError, DiagnosticBuilder};
use rustc_lexer::Base;
use rustc_lexer::unescape;
use syntax::token::{self, Token, TokenKind};
use syntax::sess::ParseSess;
use syntax::symbol::{sym, Symbol};
use syntax::util::comments;

use errors::{FatalError, DiagnosticBuilder};
use syntax_pos::symbol::{sym, Symbol};
use syntax_pos::{BytePos, Pos, Span};
use rustc_lexer::Base;
use rustc_lexer::unescape;

use std::char;
use std::convert::TryInto;
use rustc_data_structures::sync::Lrc;
use log::debug;

mod tokentrees;
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_parse/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use rustc_data_structures::fx::FxHashMap;
use syntax_pos::Span;

use super::{StringReader, UnmatchedBrace};

use rustc_data_structures::fx::FxHashMap;
use rustc_errors::PResult;
use syntax::print::pprust::token_to_string;
use syntax::token::{self, Token};
use syntax::tokenstream::{DelimSpan, IsJoint::{self, *}, TokenStream, TokenTree, TreeAndJoint};

use errors::PResult;
use syntax_pos::Span;

impl<'a> StringReader<'a> {
crate fn into_token_trees(self) -> (PResult<'a, TokenStream>, Vec<UnmatchedBrace>) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/lexer/unicode_chars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// http://www.unicode.org/Public/security/10.0.0/confusables.txt

use super::StringReader;
use errors::{Applicability, DiagnosticBuilder};
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
use crate::token;
use rustc_errors::{Applicability, DiagnosticBuilder};
use syntax_pos::{BytePos, Pos, Span, symbol::kw};

#[rustfmt::skip] // for line breaks
const UNICODE_ARRAY: &[(char, &str, char)] = &[
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use syntax::sess::ParseSess;
use syntax::token::{self, Nonterminal};
use syntax::tokenstream::{self, TokenStream, TokenTree};

use errors::{PResult, FatalError, Level, Diagnostic};
use rustc_errors::{PResult, FatalError, Level, Diagnostic};
use rustc_data_structures::sync::Lrc;
use syntax_pos::{Span, SourceFile, FileName};

Expand Down Expand Up @@ -53,7 +53,7 @@ pub enum DirectoryOwnership {
macro_rules! panictry_buffer {
($handler:expr, $e:expr) => ({
use std::result::Result::{Ok, Err};
use errors::FatalError;
use rustc_errors::FatalError;
match $e {
Ok(e) => e,
Err(errs) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/attr.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{SeqSep, Parser, TokenType, PathStyle};
use rustc_errors::PResult;
use syntax::attr;
use syntax::ast;
use syntax::util::comments;
use syntax::token::{self, Nonterminal};
use syntax_pos::{Span, Symbol};
use errors::PResult;

use log::debug;

Expand Down
25 changes: 11 additions & 14 deletions src/librustc_parse/parser/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
use super::{BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType, SeqSep, Parser};

use syntax::ast::{
self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, ItemKind,
Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
use rustc_error_codes::*;
use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind};
use syntax::token::{self, TokenKind, token_can_begin_expr};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::symbol::{kw, sym};
use syntax::ThinVec;
use syntax::util::parser::AssocOp;
use syntax::struct_span_err;

use errors::{PResult, Applicability, DiagnosticBuilder, pluralize};
use rustc_data_structures::fx::FxHashSet;
use syntax_pos::symbol::{kw, sym};
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};

use log::{debug, trace};
use std::mem;

use rustc_error_codes::*;

const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";

/// Creates a placeholder argument.
Expand Down Expand Up @@ -61,10 +58,10 @@ pub enum Error {
}

impl Error {
fn span_err<S: Into<MultiSpan>>(
fn span_err(
self,
sp: S,
handler: &errors::Handler,
sp: impl Into<MultiSpan>,
handler: &Handler,
) -> DiagnosticBuilder<'_> {
match self {
Error::FileNotFoundForModule {
Expand Down Expand Up @@ -212,7 +209,7 @@ impl<'a> Parser<'a> {
self.sess.span_diagnostic.span_bug(sp, m)
}

pub(super) fn diagnostic(&self) -> &'a errors::Handler {
pub(super) fn diagnostic(&self) -> &'a Handler {
&self.sess.span_diagnostic
}

Expand Down
17 changes: 7 additions & 10 deletions src/librustc_parse/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ use super::pat::{GateOr, PARAM_EXPECTED};
use super::diagnostics::Error;
use crate::maybe_recover_from_interpolated_ty_qpath;

use syntax::ast::{
self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode,
Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind,
FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit,
};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{PResult, Applicability};
use syntax::ast::{self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
use syntax::ast::{Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind};
use syntax::ast::{FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit};
use syntax::token::{self, Token, TokenKind};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::source_map::{self, Span};
use syntax::util::classify;
use syntax::util::literal::LitError;
use syntax::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
use syntax_pos::symbol::{kw, sym};
use syntax_pos::Symbol;
use errors::{PResult, Applicability};
use syntax_pos::source_map::{self, Span};
use syntax_pos::symbol::{kw, sym, Symbol};
use std::mem;
use rustc_data_structures::thin_vec::ThinVec;

/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
/// dropped into the token stream, which happens while parsing the result of
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/generics.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::Parser;

use rustc_errors::PResult;
use syntax::ast::{self, WhereClause, GenericParam, GenericParamKind, GenericBounds, Attribute};
use syntax::token;
use syntax::source_map::DUMMY_SP;
use syntax_pos::symbol::{kw, sym};

use errors::PResult;

impl<'a> Parser<'a> {
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use super::diagnostics::{Error, dummy_arg, ConsumeClosingDelim};

use crate::maybe_whole;

use rustc_errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
use rustc_error_codes::*;
use syntax::ast::{self, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item};
use syntax::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, UseTree, UseTreeKind};
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
Expand All @@ -14,16 +16,13 @@ use syntax::ptr::P;
use syntax::ThinVec;
use syntax::token;
use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
use syntax::source_map::{self, respan, Span};
use syntax::struct_span_err;
use syntax_pos::BytePos;
use syntax_pos::source_map::{self, respan, Span};
use syntax_pos::symbol::{kw, sym, Symbol};

use rustc_error_codes::*;

use log::debug;
use std::mem;
use errors::{PResult, Applicability, DiagnosticBuilder, StashKey};

pub(super) type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);

Expand Down
13 changes: 5 additions & 8 deletions src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@ use diagnostics::Error;
use crate::{Directory, DirectoryOwnership};
use crate::lexer::UnmatchedBrace;

use syntax::ast::{
self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit,
IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety,
};

use rustc_errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
use rustc_data_structures::thin_vec::ThinVec;
use syntax::ast::{self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit};
use syntax::ast::{IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety};
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::token::{self, Token, TokenKind, DelimToken};
use syntax::tokenstream::{self, DelimSpan, TokenTree, TokenStream, TreeAndJoint};
use syntax::sess::ParseSess;
use syntax::source_map::respan;
use syntax::struct_span_err;
use syntax::util::comments::{doc_comment_style, strip_doc_comment_decoration};
use syntax_pos::source_map::respan;
use syntax_pos::symbol::{kw, sym, Symbol};
use syntax_pos::{Span, BytePos, DUMMY_SP, FileName};
use rustc_data_structures::thin_vec::ThinVec;
use errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
use log::debug;

use std::borrow::Cow;
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_parse/parser/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ use super::diagnostics::Error;

use crate::{new_sub_parser_from_file, DirectoryOwnership};

use rustc_errors::PResult;
use syntax::attr;
use syntax::ast::{self, Ident, Attribute, ItemKind, Mod, Crate};
use syntax::token::{self, TokenKind};
use syntax::source_map::{SourceMap, Span, DUMMY_SP, FileName};

use syntax_pos::source_map::{SourceMap, Span, DUMMY_SP, FileName};
use syntax_pos::symbol::sym;
use errors::PResult;

use std::path::{self, Path, PathBuf};

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/pat.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use super::{Parser, PathStyle};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_errors::{PResult, Applicability, DiagnosticBuilder};
use syntax::ast::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
use syntax::ptr::P;
use syntax::print::pprust;
use syntax::ThinVec;
use syntax::token;
use syntax::source_map::{respan, Span, Spanned};
use syntax_pos::source_map::{respan, Span, Spanned};
use syntax_pos::symbol::{kw, sym};
use errors::{PResult, Applicability, DiagnosticBuilder};

type Expected = Option<&'static str>;

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/path.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use super::{Parser, TokenType};
use crate::maybe_whole;
use rustc_errors::{PResult, Applicability, pluralize};
use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
use syntax::ast::MacArgs;
use syntax::ThinVec;
use syntax::token::{self, Token};
use syntax::source_map::{Span, BytePos};
use syntax_pos::source_map::{Span, BytePos};
use syntax_pos::symbol::{kw, sym};

use std::mem;
use log::debug;
use errors::{PResult, Applicability, pluralize};

/// Specifies how to parse a path.
#[derive(Copy, Clone, PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_parse/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ use super::diagnostics::Error;
use crate::maybe_whole;
use crate::DirectoryOwnership;

use rustc_errors::{PResult, Applicability};
use syntax::ThinVec;
use syntax::ptr::P;
use syntax::ast;
use syntax::ast::{DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
use syntax::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
use syntax::util::classify;
use syntax::token;
use syntax::source_map::{respan, Span};
use syntax::symbol::{kw, sym};
use syntax_pos::source_map::{respan, Span};
use syntax_pos::symbol::{kw, sym};

use std::mem;
use errors::{PResult, Applicability};

impl<'a> Parser<'a> {
/// Parses a statement. This stops just before trailing semicolons on everything but items.
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_parse/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ use super::item::ParamCfg;

use crate::{maybe_whole, maybe_recover_from_interpolated_ty_qpath};

use rustc_errors::{PResult, Applicability, pluralize};
use rustc_error_codes::*;
use syntax::ptr::P;
use syntax::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam, Lifetime, Ident};
use syntax::ast::{TraitBoundModifier, TraitObjectSyntax, GenericBound, GenericBounds, PolyTraitRef};
use syntax::ast::{Mutability, AnonConst, Mac};
use syntax::token::{self, Token};
use syntax::source_map::Span;
use syntax::struct_span_fatal;
use syntax_pos::source_map::Span;
use syntax_pos::symbol::kw;

use errors::{PResult, Applicability, pluralize};

use rustc_error_codes::*;

/// Returns `true` if `IDENT t` can start a type -- `IDENT::a::b`, `IDENT<u8, u8>`,
/// `IDENT<<u8 as Trait>::AssocTy>`.
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/validate_attr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Meta-syntax validation logic of attributes for post-expansion.

use errors::{PResult, Applicability};
use rustc_errors::{PResult, Applicability};
use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP};
use syntax::ast::{self, Attribute, AttrKind, Ident, MacArgs, MetaItem, MetaItemKind};
use syntax::attr::mk_name_value_item_str;
Expand Down