Combine individual limit queries into single limits query
This commit is contained in:
@@ -53,6 +53,7 @@ use rustc_middle::ty::OpaqueTypeKey;
|
||||
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
|
||||
use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
|
||||
use rustc_session::lint::{Level, Lint};
|
||||
use rustc_session::Limit;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::def_id::StableCrateId;
|
||||
use rustc_span::source_map::MultiSpan;
|
||||
@@ -1569,6 +1570,22 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
def_kind => (def_kind.article(), def_kind.descr(def_id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_length_limit(self) -> Limit {
|
||||
self.limits(()).type_length_limit
|
||||
}
|
||||
|
||||
pub fn recursion_limit(self) -> Limit {
|
||||
self.limits(()).recursion_limit
|
||||
}
|
||||
|
||||
pub fn move_size_limit(self) -> Limit {
|
||||
self.limits(()).move_size_limit
|
||||
}
|
||||
|
||||
pub fn const_eval_limit(self) -> Limit {
|
||||
self.limits(()).const_eval_limit
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait implemented for all `X<'a>` types that can be safely and
|
||||
|
||||
@@ -221,7 +221,7 @@ fn layout_raw<'tcx>(
|
||||
ty::tls::with_related_context(tcx, move |icx| {
|
||||
let (param_env, ty) = query.into_parts();
|
||||
|
||||
if !tcx.recursion_limit(()).value_within_limit(icx.layout_depth) {
|
||||
if !tcx.recursion_limit().value_within_limit(icx.layout_depth) {
|
||||
tcx.sess.fatal(&format!("overflow representing the type `{}`", ty));
|
||||
}
|
||||
|
||||
|
||||
@@ -1437,7 +1437,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
||||
}
|
||||
|
||||
fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
|
||||
let type_length_limit = self.tcx.type_length_limit(());
|
||||
let type_length_limit = self.tcx.type_length_limit();
|
||||
if type_length_limit.value_within_limit(self.printed_type_count) {
|
||||
self.printed_type_count += 1;
|
||||
self.pretty_print_type(ty)
|
||||
|
||||
@@ -49,7 +49,7 @@ use rustc_serialize::opaque;
|
||||
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
|
||||
use rustc_session::utils::NativeLibKind;
|
||||
use rustc_session::CrateDisambiguator;
|
||||
use rustc_session::Limit;
|
||||
use rustc_session::Limits;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
use rustc_ast as ast;
|
||||
|
||||
@@ -206,7 +206,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
mut ty: Ty<'tcx>,
|
||||
normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let recursion_limit = self.recursion_limit(());
|
||||
let recursion_limit = self.recursion_limit();
|
||||
for iteration in 0.. {
|
||||
if !recursion_limit.value_within_limit(iteration) {
|
||||
return self.ty_error_with_message(
|
||||
|
||||
Reference in New Issue
Block a user