mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
rustc_parser: cleanup imports
This commit is contained in:
parent
aeaaf8f640
commit
74804fa3e7
@ -3806,7 +3806,6 @@ dependencies = [
|
||||
"rustc_errors",
|
||||
"rustc_feature",
|
||||
"rustc_lexer",
|
||||
"rustc_target",
|
||||
"smallvec 1.0.0",
|
||||
"syntax",
|
||||
"syntax_pos",
|
||||
|
@ -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" }
|
||||
rustc_error_codes = { path = "../librustc_error_codes" }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
|
@ -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;
|
||||
@ -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.
|
||||
|
@ -1,16 +1,15 @@
|
||||
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::{BytePos, Pos, Span};
|
||||
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::util::comments;
|
||||
use syntax_pos::symbol::{sym, Symbol};
|
||||
use syntax_pos::{BytePos, Pos, Span};
|
||||
|
||||
use std::char;
|
||||
use std::convert::TryInto;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use log::debug;
|
||||
|
||||
mod tokentrees;
|
||||
|
@ -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>) {
|
||||
|
@ -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)] = &[
|
||||
|
@ -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};
|
||||
|
||||
@ -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) => {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
@ -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 {
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 `+`.
|
||||
|
@ -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};
|
||||
@ -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>>);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
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};
|
||||
@ -7,9 +8,8 @@ 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>;
|
||||
|
||||
|
@ -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)]
|
||||
|
@ -6,6 +6,7 @@ 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;
|
||||
@ -13,11 +14,10 @@ use syntax::ast::{DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, E
|
||||
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.
|
||||
|
@ -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>`.
|
||||
///
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user