Skip to content

Commit 4272585

Browse files
authored
Rollup merge of rust-lang#68133 - Centril:slimmer-syntax, r=petrochenkov
Slimmer syntax High-level summary of changes: - The `syntax::node_count` pass is moved into `rustc_ast_passes`. This works towards improving rust-lang#65031 by making compiling `syntax` go faster. - The `syntax::{GLOBALS, with_globals, ..}` business is consolidated into `syntax::attr` for cleaner code and future possible improvements. - The pretty printer loses its dependency on `ParseSess`, opting to use `SourceMap` & friends directly instead. - Some drive by cleanup of `syntax::attr::HasAttr` happens. - Builtin attribute logic (`syntax::attr::builtin`) + `syntax::attr::allow_internal_unstable` is moved into a new `rustc_attr` crate. More logic from `syntax::attr` should be moved into that crate over time. This also means that `syntax` loses all mentions of `ParseSess`, which enables the next point. - The pretty printer `syntax::print` is moved into a new crate `rustc_ast_pretty`. - `rustc_session::node_id` is moved back as `syntax::node_id`. As a result, `syntax` gets to drop dependencies on `rustc_session` (and implicitly `rustc_target`), `rustc_error_codes`, and `rustc_errors`. Moreover `rustc_hir` gets to drop its dependency on `rustc_session` as well. At this point, these crates are mostly "pure data crates", which is approaching a desirable end state. - We should consider renaming `syntax` to `rustc_ast` now.
2 parents 2f688ac + 03b515a commit 4272585

File tree

139 files changed

+451
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+451
-358
lines changed

Diff for: Cargo.lock

+55-4
Original file line numberDiff line numberDiff line change
@@ -3097,6 +3097,7 @@ dependencies = [
30973097
"rustc-rayon",
30983098
"rustc-rayon-core",
30993099
"rustc_apfloat",
3100+
"rustc_attr",
31003101
"rustc_data_structures",
31013102
"rustc_errors",
31023103
"rustc_feature",
@@ -3362,6 +3363,7 @@ version = "0.0.0"
33623363
dependencies = [
33633364
"log",
33643365
"rustc",
3366+
"rustc_ast_pretty",
33653367
"rustc_data_structures",
33663368
"rustc_errors",
33673369
"rustc_hir",
@@ -3378,6 +3380,8 @@ name = "rustc_ast_passes"
33783380
version = "0.0.0"
33793381
dependencies = [
33803382
"log",
3383+
"rustc_ast_pretty",
3384+
"rustc_attr",
33813385
"rustc_data_structures",
33823386
"rustc_errors",
33833387
"rustc_feature",
@@ -3387,12 +3391,40 @@ dependencies = [
33873391
"syntax",
33883392
]
33893393

3394+
[[package]]
3395+
name = "rustc_ast_pretty"
3396+
version = "0.0.0"
3397+
dependencies = [
3398+
"log",
3399+
"rustc_data_structures",
3400+
"rustc_span",
3401+
"syntax",
3402+
]
3403+
3404+
[[package]]
3405+
name = "rustc_attr"
3406+
version = "0.0.0"
3407+
dependencies = [
3408+
"rustc_ast_pretty",
3409+
"rustc_data_structures",
3410+
"rustc_errors",
3411+
"rustc_feature",
3412+
"rustc_macros",
3413+
"rustc_session",
3414+
"rustc_span",
3415+
"serialize",
3416+
"smallvec 1.0.0",
3417+
"syntax",
3418+
]
3419+
33903420
[[package]]
33913421
name = "rustc_builtin_macros"
33923422
version = "0.0.0"
33933423
dependencies = [
33943424
"fmt_macros",
33953425
"log",
3426+
"rustc_ast_pretty",
3427+
"rustc_attr",
33963428
"rustc_data_structures",
33973429
"rustc_errors",
33983430
"rustc_expand",
@@ -3415,6 +3447,7 @@ dependencies = [
34153447
"log",
34163448
"rustc",
34173449
"rustc-demangle",
3450+
"rustc_attr",
34183451
"rustc_codegen_ssa",
34193452
"rustc_codegen_utils",
34203453
"rustc_data_structures",
@@ -3445,6 +3478,7 @@ dependencies = [
34453478
"num_cpus",
34463479
"rustc",
34473480
"rustc_apfloat",
3481+
"rustc_attr",
34483482
"rustc_codegen_utils",
34493483
"rustc_data_structures",
34503484
"rustc_errors",
@@ -3509,6 +3543,7 @@ dependencies = [
35093543
"lazy_static 1.3.0",
35103544
"log",
35113545
"rustc",
3546+
"rustc_ast_pretty",
35123547
"rustc_codegen_utils",
35133548
"rustc_data_structures",
35143549
"rustc_error_codes",
@@ -3555,6 +3590,8 @@ version = "0.0.0"
35553590
dependencies = [
35563591
"log",
35573592
"rustc_ast_passes",
3593+
"rustc_ast_pretty",
3594+
"rustc_attr",
35583595
"rustc_data_structures",
35593596
"rustc_errors",
35603597
"rustc_feature",
@@ -3584,11 +3621,11 @@ version = "0.0.0"
35843621
name = "rustc_hir"
35853622
version = "0.0.0"
35863623
dependencies = [
3624+
"rustc_ast_pretty",
35873625
"rustc_data_structures",
35883626
"rustc_errors",
35893627
"rustc_index",
35903628
"rustc_macros",
3591-
"rustc_session",
35923629
"rustc_span",
35933630
"rustc_target",
35943631
"serialize",
@@ -3631,6 +3668,7 @@ dependencies = [
36313668
"rustc-rayon",
36323669
"rustc_ast_lowering",
36333670
"rustc_ast_passes",
3671+
"rustc_attr",
36343672
"rustc_builtin_macros",
36353673
"rustc_codegen_llvm",
36363674
"rustc_codegen_ssa",
@@ -3675,6 +3713,8 @@ version = "0.0.0"
36753713
dependencies = [
36763714
"log",
36773715
"rustc",
3716+
"rustc_ast_pretty",
3717+
"rustc_attr",
36783718
"rustc_data_structures",
36793719
"rustc_errors",
36803720
"rustc_feature",
@@ -3715,6 +3755,8 @@ dependencies = [
37153755
"log",
37163756
"memmap",
37173757
"rustc",
3758+
"rustc_ast_pretty",
3759+
"rustc_attr",
37183760
"rustc_data_structures",
37193761
"rustc_errors",
37203762
"rustc_expand",
@@ -3742,6 +3784,8 @@ dependencies = [
37423784
"polonius-engine",
37433785
"rustc",
37443786
"rustc_apfloat",
3787+
"rustc_ast_pretty",
3788+
"rustc_attr",
37453789
"rustc_data_structures",
37463790
"rustc_errors",
37473791
"rustc_hir",
@@ -3764,6 +3808,7 @@ dependencies = [
37643808
"log",
37653809
"rustc",
37663810
"rustc_apfloat",
3811+
"rustc_attr",
37673812
"rustc_data_structures",
37683813
"rustc_errors",
37693814
"rustc_hir",
@@ -3783,6 +3828,8 @@ version = "0.0.0"
37833828
dependencies = [
37843829
"bitflags",
37853830
"log",
3831+
"rustc_ast_pretty",
3832+
"rustc_attr",
37863833
"rustc_data_structures",
37873834
"rustc_errors",
37883835
"rustc_feature",
@@ -3800,6 +3847,7 @@ version = "0.0.0"
38003847
dependencies = [
38013848
"log",
38023849
"rustc",
3850+
"rustc_attr",
38033851
"rustc_data_structures",
38043852
"rustc_errors",
38053853
"rustc_feature",
@@ -3830,6 +3878,7 @@ version = "0.0.0"
38303878
dependencies = [
38313879
"log",
38323880
"rustc",
3881+
"rustc_attr",
38333882
"rustc_data_structures",
38343883
"rustc_errors",
38353884
"rustc_hir",
@@ -3847,6 +3896,8 @@ dependencies = [
38473896
"log",
38483897
"rustc",
38493898
"rustc_ast_lowering",
3899+
"rustc_ast_pretty",
3900+
"rustc_attr",
38503901
"rustc_data_structures",
38513902
"rustc_errors",
38523903
"rustc_expand",
@@ -3867,6 +3918,7 @@ dependencies = [
38673918
"rls-data",
38683919
"rls-span",
38693920
"rustc",
3921+
"rustc_ast_pretty",
38703922
"rustc_codegen_utils",
38713923
"rustc_data_structures",
38723924
"rustc_hir",
@@ -3890,6 +3942,7 @@ dependencies = [
38903942
"rustc_span",
38913943
"rustc_target",
38923944
"serialize",
3945+
"syntax",
38933946
]
38943947

38953948
[[package]]
@@ -3964,6 +4017,7 @@ dependencies = [
39644017
"arena",
39654018
"log",
39664019
"rustc",
4020+
"rustc_attr",
39674021
"rustc_data_structures",
39684022
"rustc_errors",
39694023
"rustc_hir",
@@ -4484,12 +4538,9 @@ version = "0.0.0"
44844538
dependencies = [
44854539
"log",
44864540
"rustc_data_structures",
4487-
"rustc_errors",
4488-
"rustc_feature",
44894541
"rustc_index",
44904542
"rustc_lexer",
44914543
"rustc_macros",
4492-
"rustc_session",
44934544
"rustc_span",
44944545
"scoped-tls",
44954546
"serialize",

Diff for: src/librustc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rustc-rayon = "0.3.0"
2121
rustc-rayon-core = "0.3.0"
2222
polonius-engine = "0.11.0"
2323
rustc_apfloat = { path = "../librustc_apfloat" }
24+
rustc_attr = { path = "../librustc_attr" }
2425
rustc_feature = { path = "../librustc_feature" }
2526
rustc_hir = { path = "../librustc_hir" }
2627
rustc_target = { path = "../librustc_target" }

Diff for: src/librustc/hir/map/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use rustc_data_structures::stable_hasher::StableHasher;
1010
use rustc_hir as hir;
1111
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
1212
use rustc_index::vec::IndexVec;
13-
use rustc_session::node_id::NodeMap;
1413
use rustc_session::CrateDisambiguator;
1514
use rustc_span::hygiene::ExpnId;
1615
use rustc_span::symbol::{sym, Symbol};
1716
use rustc_span::Span;
1817
use syntax::ast;
18+
use syntax::node_id::NodeMap;
1919

2020
use std::borrow::Borrow;
2121
use std::fmt::Write;

Diff for: src/librustc/ich/impls_hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
44
use crate::hir::map::DefPathHash;
55
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
6+
use rustc_attr as attr;
67
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
78
use rustc_hir as hir;
89
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
910
use smallvec::SmallVec;
1011
use std::mem;
11-
use syntax::attr;
1212

1313
impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
1414
#[inline]

Diff for: src/librustc/middle/codegen_fn_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::mir::mono::Linkage;
2+
use rustc_attr::{InlineAttr, OptimizeAttr};
23
use rustc_span::symbol::Symbol;
3-
use syntax::attr::{InlineAttr, OptimizeAttr};
44

55
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
66
pub struct CodegenFnAttrs {

Diff for: src/librustc/middle/stability.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ pub use self::StabilityLevel::*;
55

66
use crate::session::{DiagnosticMessageId, Session};
77
use crate::ty::{self, TyCtxt};
8+
use rustc_attr::{self as attr, ConstStability, Deprecation, RustcDeprecation, Stability};
89
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
910
use rustc_errors::{Applicability, DiagnosticBuilder};
1011
use rustc_feature::GateIssue;
1112
use rustc_hir as hir;
1213
use rustc_hir::def::DefKind;
1314
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
1415
use rustc_hir::{self, HirId};
15-
use rustc_session::lint::{self, BuiltinLintDiagnostics, Lint, LintBuffer};
16+
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
17+
use rustc_session::lint::{BuiltinLintDiagnostics, Lint, LintBuffer};
18+
use rustc_session::parse::feature_err_issue;
1619
use rustc_span::symbol::{sym, Symbol};
1720
use rustc_span::{MultiSpan, Span};
1821
use syntax::ast::CRATE_NODE_ID;
19-
use syntax::attr::{self, ConstStability, Deprecation, RustcDeprecation, Stability};
20-
use syntax::sess::feature_err_issue;
2122

2223
use std::num::NonZeroU32;
2324

@@ -97,7 +98,7 @@ pub fn report_unstable(
9798
issue: Option<NonZeroU32>,
9899
is_soft: bool,
99100
span: Span,
100-
soft_handler: impl FnOnce(&'static lint::Lint, Span, &str),
101+
soft_handler: impl FnOnce(&'static Lint, Span, &str),
101102
) {
102103
let msg = match reason {
103104
Some(r) => format!("use of unstable library feature '{}': {}", feature, r),
@@ -119,7 +120,7 @@ pub fn report_unstable(
119120
let fresh = sess.one_time_diagnostics.borrow_mut().insert(error_id);
120121
if fresh {
121122
if is_soft {
122-
soft_handler(lint::builtin::SOFT_UNSTABLE, span, &msg)
123+
soft_handler(SOFT_UNSTABLE, span, &msg)
123124
} else {
124125
feature_err_issue(&sess.parse_sess, feature, span, GateIssue::Library(issue), &msg)
125126
.emit();
@@ -175,19 +176,19 @@ fn deprecation_message_common(message: String, reason: Option<Symbol>) -> String
175176

176177
pub fn deprecation_message(depr: &Deprecation, path: &str) -> (String, &'static Lint) {
177178
let message = format!("use of deprecated item '{}'", path);
178-
(deprecation_message_common(message, depr.note), lint::builtin::DEPRECATED)
179+
(deprecation_message_common(message, depr.note), DEPRECATED)
179180
}
180181

181182
pub fn rustc_deprecation_message(depr: &RustcDeprecation, path: &str) -> (String, &'static Lint) {
182183
let (message, lint) = if deprecation_in_effect(&depr.since.as_str()) {
183-
(format!("use of deprecated item '{}'", path), lint::builtin::DEPRECATED)
184+
(format!("use of deprecated item '{}'", path), DEPRECATED)
184185
} else {
185186
(
186187
format!(
187188
"use of item '{}' that will be deprecated in future version {}",
188189
path, depr.since
189190
),
190-
lint::builtin::DEPRECATED_IN_FUTURE,
191+
DEPRECATED_IN_FUTURE,
191192
)
192193
};
193194
(deprecation_message_common(message, Some(depr.reason)), lint)

Diff for: src/librustc/mir/mono.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
33
use crate::session::config::OptLevel;
44
use crate::ty::print::obsolete::DefPathBasedNames;
55
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
6+
use rustc_attr::InlineAttr;
67
use rustc_data_structures::base_n;
78
use rustc_data_structures::fx::FxHashMap;
89
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -12,7 +13,6 @@ use rustc_span::source_map::Span;
1213
use rustc_span::symbol::Symbol;
1314
use std::fmt;
1415
use std::hash::Hash;
15-
use syntax::attr::InlineAttr;
1616

1717
/// Describes how a monomorphization will be instantiated in object files.
1818
#[derive(PartialEq)]

Diff for: src/librustc/traits/on_unimplemented.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use fmt_macros::{Parser, Piece, Position};
33
use crate::ty::{self, GenericParamDefKind, TyCtxt};
44
use crate::util::common::ErrorReported;
55

6+
use rustc_attr as attr;
67
use rustc_data_structures::fx::FxHashMap;
78
use rustc_errors::struct_span_err;
89
use rustc_hir::def_id::DefId;
910
use rustc_span::symbol::{kw, sym, Symbol};
1011
use rustc_span::Span;
1112
use syntax::ast::{MetaItem, NestedMetaItem};
12-
use syntax::attr;
1313

1414
#[derive(Clone, Debug)]
1515
pub struct OnUnimplementedFormatString(Symbol);

0 commit comments

Comments
 (0)