diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-06-25 18:48:26 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2021-07-04 12:33:14 -0500 |
| commit | ff15b5e2c76bb5c0fdd64e49ee76fbd2023415bd (patch) | |
| tree | 8ffd85d54373d3a3f22cd528d948ec7fde919b2f /compiler/rustc_session | |
| parent | 90442458ac46b1d5eed752c316da25450f67285b (diff) | |
| download | rust-ff15b5e2c76bb5c0fdd64e49ee76fbd2023415bd.tar.gz rust-ff15b5e2c76bb5c0fdd64e49ee76fbd2023415bd.zip | |
Query-ify global limit attribute handling
Diffstat (limited to 'compiler/rustc_session')
| -rw-r--r-- | compiler/rustc_session/src/lib.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 40 |
2 files changed, 7 insertions, 38 deletions
diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 8d00a9a959e..9a82ae3fc10 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -24,3 +24,8 @@ pub use session::*; pub mod output; pub use getopts; + +/// Requirements for a `StableHashingContext` to be used in this crate. +/// This is a hack to allow using the `HashStable_Generic` derive macro +/// instead of implementing everything in `rustc_middle`. +pub trait HashStableContext {} diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index f792e319867..609144f7411 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -22,6 +22,7 @@ use rustc_errors::json::JsonEmitter; use rustc_errors::registry::Registry; use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported}; use rustc_lint_defs::FutureBreakage; +use rustc_macros::HashStable_Generic; pub use rustc_span::crate_disambiguator::CrateDisambiguator; use rustc_span::source_map::{FileLoader, MultiSpan, RealFileLoader, SourceMap, Span}; use rustc_span::{edition::Edition, RealFileName}; @@ -66,7 +67,7 @@ pub enum CtfeBacktrace { /// New-type wrapper around `usize` for representing limits. Ensures that comparisons against /// limits are consistent throughout the compiler. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, HashStable_Generic)] pub struct Limit(pub usize); impl Limit { @@ -144,20 +145,6 @@ pub struct Session { lint_store: OnceCell<Lrc<dyn SessionLintStore>>, - /// The maximum recursion limit for potentially infinitely recursive - /// operations such as auto-dereference and monomorphization. - pub recursion_limit: OnceCell<Limit>, - - /// The size at which the `large_assignments` lint starts - /// being emitted. - pub move_size_limit: OnceCell<usize>, - - /// The maximum length of types during monomorphization. - pub type_length_limit: OnceCell<Limit>, - - /// The maximum blocks a const expression can evaluate. - pub const_eval_limit: OnceCell<Limit>, - incr_comp_session: OneThread<RefCell<IncrCompSession>>, /// Used for incremental compilation tests. Will only be populated if /// `-Zquery-dep-graph` is specified. @@ -347,25 +334,6 @@ impl Session { self.crate_types.set(crate_types).expect("`crate_types` was initialized twice") } - #[inline] - pub fn recursion_limit(&self) -> Limit { - self.recursion_limit.get().copied().unwrap() - } - - #[inline] - pub fn move_size_limit(&self) -> usize { - self.move_size_limit.get().copied().unwrap() - } - - #[inline] - pub fn type_length_limit(&self) -> Limit { - self.type_length_limit.get().copied().unwrap() - } - - pub fn const_eval_limit(&self) -> Limit { - self.const_eval_limit.get().copied().unwrap() - } - pub fn struct_span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> DiagnosticBuilder<'_> { self.diagnostic().struct_span_warn(sp, msg) } @@ -1391,10 +1359,6 @@ pub fn build_session( crate_disambiguator: OnceCell::new(), features: OnceCell::new(), lint_store: OnceCell::new(), - recursion_limit: OnceCell::new(), - move_size_limit: OnceCell::new(), - type_length_limit: OnceCell::new(), - const_eval_limit: OnceCell::new(), incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)), cgu_reuse_tracker, prof, |
