From ff15b5e2c76bb5c0fdd64e49ee76fbd2023415bd Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 25 Jun 2021 18:48:26 -0500 Subject: Query-ify global limit attribute handling --- compiler/rustc_session/src/lib.rs | 5 +++++ compiler/rustc_session/src/session.rs | 40 ++--------------------------------- 2 files changed, 7 insertions(+), 38 deletions(-) (limited to 'compiler/rustc_session/src') 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>, - /// The maximum recursion limit for potentially infinitely recursive - /// operations such as auto-dereference and monomorphization. - pub recursion_limit: OnceCell, - - /// The size at which the `large_assignments` lint starts - /// being emitted. - pub move_size_limit: OnceCell, - - /// The maximum length of types during monomorphization. - pub type_length_limit: OnceCell, - - /// The maximum blocks a const expression can evaluate. - pub const_eval_limit: OnceCell, - incr_comp_session: OneThread>, /// 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>(&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, -- cgit 1.4.1-3-g733a5