Skip to content

Commit 0e18ca1

Browse files
authored
Rollup merge of #67045 - Centril:parser-import-clean, r=Mark-Simulacrum
rustc_parser: cleanup imports Reorganize & canonicalize some imports + Drop `rustc_target` as a dependency. r? @Mark-Simulacrum
2 parents 23b8c06 + 74804fa commit 0e18ca1

File tree

19 files changed

+58
-76
lines changed

19 files changed

+58
-76
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3806,7 +3806,6 @@ dependencies = [
38063806
"rustc_errors",
38073807
"rustc_feature",
38083808
"rustc_lexer",
3809-
"rustc_target",
38103809
"smallvec 1.0.0",
38113810
"syntax",
38123811
"syntax_pos",

src/librustc_parse/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ doctest = false
1212
[dependencies]
1313
bitflags = "1.0"
1414
log = "0.4"
15-
syntax_pos = { path = "../libsyntax_pos" }
16-
syntax = { path = "../libsyntax" }
17-
errors = { path = "../librustc_errors", package = "rustc_errors" }
1815
rustc_data_structures = { path = "../librustc_data_structures" }
1916
rustc_feature = { path = "../librustc_feature" }
2017
rustc_lexer = { path = "../librustc_lexer" }
21-
rustc_target = { path = "../librustc_target" }
22-
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
18+
rustc_errors = { path = "../librustc_errors" }
2319
rustc_error_codes = { path = "../librustc_error_codes" }
20+
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
21+
syntax_pos = { path = "../libsyntax_pos" }
22+
syntax = { path = "../libsyntax" }

src/librustc_parse/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
use crate::validate_attr;
1212
use rustc_feature::Features;
13+
use rustc_errors::Applicability;
1314
use syntax::attr::HasAttrs;
1415
use syntax::feature_gate::{feature_err, get_features};
1516
use syntax::attr;
@@ -21,7 +22,6 @@ use syntax::sess::ParseSess;
2122
use syntax::util::map_in_place::MapInPlace;
2223
use syntax_pos::symbol::sym;
2324

24-
use errors::Applicability;
2525
use smallvec::SmallVec;
2626

2727
/// A folder that strips out items that do not belong in the current configuration.

src/librustc_parse/lexer/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
use rustc_data_structures::sync::Lrc;
2+
use rustc_errors::{FatalError, DiagnosticBuilder};
3+
use rustc_lexer::Base;
4+
use rustc_lexer::unescape;
15
use syntax::token::{self, Token, TokenKind};
26
use syntax::sess::ParseSess;
3-
use syntax::symbol::{sym, Symbol};
47
use syntax::util::comments;
5-
6-
use errors::{FatalError, DiagnosticBuilder};
8+
use syntax_pos::symbol::{sym, Symbol};
79
use syntax_pos::{BytePos, Pos, Span};
8-
use rustc_lexer::Base;
9-
use rustc_lexer::unescape;
1010

1111
use std::char;
1212
use std::convert::TryInto;
13-
use rustc_data_structures::sync::Lrc;
1413
use log::debug;
1514

1615
mod tokentrees;

src/librustc_parse/lexer/tokentrees.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
use rustc_data_structures::fx::FxHashMap;
2-
use syntax_pos::Span;
3-
41
use super::{StringReader, UnmatchedBrace};
52

3+
use rustc_data_structures::fx::FxHashMap;
4+
use rustc_errors::PResult;
65
use syntax::print::pprust::token_to_string;
76
use syntax::token::{self, Token};
87
use syntax::tokenstream::{DelimSpan, IsJoint::{self, *}, TokenStream, TokenTree, TreeAndJoint};
9-
10-
use errors::PResult;
8+
use syntax_pos::Span;
119

1210
impl<'a> StringReader<'a> {
1311
crate fn into_token_trees(self) -> (PResult<'a, TokenStream>, Vec<UnmatchedBrace>) {

src/librustc_parse/lexer/unicode_chars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// http://www.unicode.org/Public/security/10.0.0/confusables.txt
33

44
use super::StringReader;
5-
use errors::{Applicability, DiagnosticBuilder};
6-
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
75
use crate::token;
6+
use rustc_errors::{Applicability, DiagnosticBuilder};
7+
use syntax_pos::{BytePos, Pos, Span, symbol::kw};
88

99
#[rustfmt::skip] // for line breaks
1010
const UNICODE_ARRAY: &[(char, &str, char)] = &[

src/librustc_parse/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use syntax::sess::ParseSess;
88
use syntax::token::{self, Nonterminal};
99
use syntax::tokenstream::{self, TokenStream, TokenTree};
1010

11-
use errors::{PResult, FatalError, Level, Diagnostic};
11+
use rustc_errors::{PResult, FatalError, Level, Diagnostic};
1212
use rustc_data_structures::sync::Lrc;
1313
use syntax_pos::{Span, SourceFile, FileName};
1414

@@ -53,7 +53,7 @@ pub enum DirectoryOwnership {
5353
macro_rules! panictry_buffer {
5454
($handler:expr, $e:expr) => ({
5555
use std::result::Result::{Ok, Err};
56-
use errors::FatalError;
56+
use rustc_errors::FatalError;
5757
match $e {
5858
Ok(e) => e,
5959
Err(errs) => {

src/librustc_parse/parser/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::{SeqSep, Parser, TokenType, PathStyle};
2+
use rustc_errors::PResult;
23
use syntax::attr;
34
use syntax::ast;
45
use syntax::util::comments;
56
use syntax::token::{self, Nonterminal};
67
use syntax_pos::{Span, Symbol};
7-
use errors::PResult;
88

99
use log::debug;
1010

src/librustc_parse/parser/diagnostics.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
use super::{BlockMode, PathStyle, SemiColonMode, TokenType, TokenExpectType, SeqSep, Parser};
22

3-
use syntax::ast::{
4-
self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item, ItemKind,
5-
Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind,
6-
};
3+
use rustc_data_structures::fx::FxHashSet;
4+
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
5+
use rustc_error_codes::*;
6+
use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
7+
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind};
78
use syntax::token::{self, TokenKind, token_can_begin_expr};
89
use syntax::print::pprust;
910
use syntax::ptr::P;
10-
use syntax::symbol::{kw, sym};
1111
use syntax::ThinVec;
1212
use syntax::util::parser::AssocOp;
1313
use syntax::struct_span_err;
14-
15-
use errors::{PResult, Applicability, DiagnosticBuilder, pluralize};
16-
use rustc_data_structures::fx::FxHashSet;
14+
use syntax_pos::symbol::{kw, sym};
1715
use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
16+
1817
use log::{debug, trace};
1918
use std::mem;
2019

21-
use rustc_error_codes::*;
22-
2320
const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";
2421

2522
/// Creates a placeholder argument.
@@ -61,10 +58,10 @@ pub enum Error {
6158
}
6259

6360
impl Error {
64-
fn span_err<S: Into<MultiSpan>>(
61+
fn span_err(
6562
self,
66-
sp: S,
67-
handler: &errors::Handler,
63+
sp: impl Into<MultiSpan>,
64+
handler: &Handler,
6865
) -> DiagnosticBuilder<'_> {
6966
match self {
7067
Error::FileNotFoundForModule {
@@ -212,7 +209,7 @@ impl<'a> Parser<'a> {
212209
self.sess.span_diagnostic.span_bug(sp, m)
213210
}
214211

215-
pub(super) fn diagnostic(&self) -> &'a errors::Handler {
212+
pub(super) fn diagnostic(&self) -> &'a Handler {
216213
&self.sess.span_diagnostic
217214
}
218215

src/librustc_parse/parser/expr.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ use super::pat::{GateOr, PARAM_EXPECTED};
44
use super::diagnostics::Error;
55
use crate::maybe_recover_from_interpolated_ty_qpath;
66

7-
use syntax::ast::{
8-
self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode,
9-
Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind,
10-
FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit,
11-
};
7+
use rustc_data_structures::thin_vec::ThinVec;
8+
use rustc_errors::{PResult, Applicability};
9+
use syntax::ast::{self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
10+
use syntax::ast::{Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind};
11+
use syntax::ast::{FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit};
1212
use syntax::token::{self, Token, TokenKind};
1313
use syntax::print::pprust;
1414
use syntax::ptr::P;
15-
use syntax::source_map::{self, Span};
1615
use syntax::util::classify;
1716
use syntax::util::literal::LitError;
1817
use syntax::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
19-
use syntax_pos::symbol::{kw, sym};
20-
use syntax_pos::Symbol;
21-
use errors::{PResult, Applicability};
18+
use syntax_pos::source_map::{self, Span};
19+
use syntax_pos::symbol::{kw, sym, Symbol};
2220
use std::mem;
23-
use rustc_data_structures::thin_vec::ThinVec;
2421

2522
/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
2623
/// dropped into the token stream, which happens while parsing the result of

0 commit comments

Comments
 (0)