Skip to content

Commit b6602d2

Browse files
authored
Rollup merge of rust-lang#66878 - Mark-Simulacrum:sess-decouple, r=Centril
Move Sessions into (new) librustc_session This PR moves `ParseSess` and `Session` from their current locations into a new crate, `librustc_session`. There are several intents behind this change. librustc is a very large crate, and we want to split it up over time -- this movement removes the sizeable session module from it. It also helps allow for future movement of things not coupled to TyCtxt but coupled to Session out of the crate. This movement allows allows for a future follow-up PR which unifies Session and ParseSess, allowing for a single source of truth for APIs interested in global options throughout the compiler; the ParseSess is already created directly as a member of Session in the current compiler (i.e., we do not first construct a ParseSess and then move it into Session later in the compilation). This PR intentionally avoids changing numerous imports throughout the tree to new locations of the moved types; this is needless noise and can be done as needed. In the process of moving the sessions back, the lint system received an update as well -- notably, early buffered lints are no longer ad-hoc declared as enum pairs and later associated with proper lint declarations. They are still separately handled (buffered), it is a little unclear whether this is truly necessary, but regardless is left for future PRs. Many of the types moved back are sort of ad-hoc placed into the same crate (librustc_session) instead of creating other crates; it's unclear whether this is actually a good thing, but it seemed better than creating numerous tiny crates which served no purpose on their own.
2 parents 1b83dcf + 68fb218 commit b6602d2

Some content is hidden

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

50 files changed

+545
-482
lines changed

Cargo.lock

+21
Original file line numberDiff line numberDiff line change
@@ -3205,6 +3205,7 @@ dependencies = [
32053205
"rustc_fs_util",
32063206
"rustc_index",
32073207
"rustc_macros",
3208+
"rustc_session",
32083209
"rustc_target",
32093210
"scoped-tls",
32103211
"serialize",
@@ -3518,6 +3519,7 @@ dependencies = [
35183519
"rustc_fs_util",
35193520
"rustc_incremental",
35203521
"rustc_index",
3522+
"rustc_session",
35213523
"rustc_target",
35223524
"serialize",
35233525
"syntax",
@@ -3634,6 +3636,7 @@ dependencies = [
36343636
"rustc",
36353637
"rustc_data_structures",
36363638
"rustc_fs_util",
3639+
"rustc_session",
36373640
"serialize",
36383641
"syntax",
36393642
"syntax_pos",
@@ -3697,6 +3700,7 @@ dependencies = [
36973700
"rustc_error_codes",
36983701
"rustc_feature",
36993702
"rustc_index",
3703+
"rustc_session",
37003704
"rustc_target",
37013705
"syntax",
37023706
"syntax_pos",
@@ -3884,6 +3888,22 @@ dependencies = [
38843888
"syntax_pos",
38853889
]
38863890

3891+
[[package]]
3892+
name = "rustc_session"
3893+
version = "0.0.0"
3894+
dependencies = [
3895+
"log",
3896+
"num_cpus",
3897+
"rustc_data_structures",
3898+
"rustc_errors",
3899+
"rustc_feature",
3900+
"rustc_fs_util",
3901+
"rustc_index",
3902+
"rustc_target",
3903+
"serialize",
3904+
"syntax_pos",
3905+
]
3906+
38873907
[[package]]
38883908
name = "rustc_target"
38893909
version = "0.0.0"
@@ -4463,6 +4483,7 @@ dependencies = [
44634483
"rustc_index",
44644484
"rustc_lexer",
44654485
"rustc_macros",
4486+
"rustc_session",
44664487
"scoped-tls",
44674488
"serialize",
44684489
"smallvec 1.0.0",

src/librustc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ rustc_fs_util = { path = "../librustc_fs_util" }
3939
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
4040
measureme = "0.4"
4141
rustc_error_codes = { path = "../librustc_error_codes" }
42+
rustc_session = { path = "../librustc_session" }

src/librustc/dep_graph/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod prev;
55
mod query;
66
mod safe;
77
mod serialized;
8-
pub mod cgu_reuse_tracker;
98

109
pub use self::dep_node::{DepNode, DepKind, DepConstructor, WorkProductId, RecoverKey, label_strs};
1110
pub use self::graph::{DepGraph, WorkProduct, DepNodeIndex, DepNodeColor, TaskDeps, hash_result};

src/librustc/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#![recursion_limit="512"]
6565

6666
#[macro_use] extern crate bitflags;
67-
extern crate getopts;
6867
#[macro_use] extern crate scoped_tls;
6968
#[cfg(windows)]
7069
extern crate libc;
@@ -74,10 +73,6 @@ extern crate libc;
7473
#[macro_use] extern crate syntax;
7574
#[macro_use] extern crate smallvec;
7675

77-
// Use the test crate here so we depend on getopts through it. This allow tools to link to both
78-
// librustc_driver and libtest.
79-
extern crate test as _;
80-
8176
#[cfg(test)]
8277
mod tests;
8378

@@ -113,7 +108,7 @@ pub mod middle {
113108
}
114109

115110
pub mod mir;
116-
pub mod session;
111+
pub use rustc_session as session;
117112
pub mod traits;
118113
pub mod ty;
119114

src/librustc/lint/builtin.rs

+4-27
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use syntax::ast;
1212
use syntax::edition::Edition;
1313
use syntax::source_map::Span;
1414
use syntax::symbol::Symbol;
15+
use syntax::early_buffered_lints::{ILL_FORMED_ATTRIBUTE_INPUT, META_VARIABLE_MISUSE};
16+
use rustc_session::declare_lint;
1517

1618
declare_lint! {
1719
pub EXCEEDING_BITSHIFTS,
@@ -404,31 +406,6 @@ declare_lint! {
404406
};
405407
}
406408

407-
/// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
408-
pub mod parser {
409-
declare_lint! {
410-
pub ILL_FORMED_ATTRIBUTE_INPUT,
411-
Deny,
412-
"ill-formed attribute inputs that were previously accepted and used in practice",
413-
@future_incompatible = super::FutureIncompatibleInfo {
414-
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
415-
edition: None,
416-
};
417-
}
418-
419-
declare_lint! {
420-
pub META_VARIABLE_MISUSE,
421-
Allow,
422-
"possible meta-variable misuse at macro definition"
423-
}
424-
425-
declare_lint! {
426-
pub INCOMPLETE_INCLUDE,
427-
Deny,
428-
"trailing content in included file"
429-
}
430-
}
431-
432409
declare_lint! {
433410
pub DEPRECATED_IN_FUTURE,
434411
Allow,
@@ -520,8 +497,8 @@ declare_lint_pass! {
520497
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
521498
MACRO_USE_EXTERN_CRATE,
522499
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
523-
parser::ILL_FORMED_ATTRIBUTE_INPUT,
524-
parser::META_VARIABLE_MISUSE,
500+
ILL_FORMED_ATTRIBUTE_INPUT,
501+
META_VARIABLE_MISUSE,
525502
DEPRECATED_IN_FUTURE,
526503
AMBIGUOUS_ASSOCIATED_ITEMS,
527504
MUTABLE_BORROW_RESERVATION_CONFLICT,

src/librustc/lint/internal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use errors::Applicability;
99
use rustc_data_structures::fx::FxHashMap;
1010
use syntax::ast::{Ident, Item, ItemKind};
1111
use syntax::symbol::{sym, Symbol};
12+
use rustc_session::declare_tool_lint;
1213

1314
declare_tool_lint! {
1415
pub rustc::DEFAULT_HASH_TYPES,

src/librustc/lint/levels.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::lint::{self, Lint, LintId, Level, LintSource};
88
use crate::session::Session;
99
use crate::util::nodemap::FxHashMap;
1010
use errors::{Applicability, DiagnosticBuilder};
11-
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
11+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1212
use syntax::ast;
1313
use syntax::attr;
1414
use syntax::feature_gate;
@@ -93,7 +93,7 @@ impl LintLevelSets {
9393

9494
// If `level` is none then we actually assume the default level for this
9595
// lint.
96-
let mut level = level.unwrap_or_else(|| lint.default_level(sess));
96+
let mut level = level.unwrap_or_else(|| lint.default_level(sess.edition()));
9797

9898
// If we're about to issue a warning, check at the last minute for any
9999
// directives against the warnings "lint". If, for example, there's an
@@ -566,19 +566,3 @@ impl<'a> HashStable<StableHashingContext<'a>> for LintLevelMap {
566566
})
567567
}
568568
}
569-
570-
impl<HCX> HashStable<HCX> for LintId {
571-
#[inline]
572-
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
573-
self.lint_name_raw().hash_stable(hcx, hasher);
574-
}
575-
}
576-
577-
impl<HCX> ToStableHashKey<HCX> for LintId {
578-
type KeyType = &'static str;
579-
580-
#[inline]
581-
fn to_stable_hash_key(&self, _: &HCX) -> &'static str {
582-
self.lint_name_raw()
583-
}
584-
}

0 commit comments

Comments
 (0)