Skip to content

Commit 3deccbd

Browse files
committed
Remove type length check in collector
1 parent 4f7a511 commit 3deccbd

File tree

1 file changed

+2
-44
lines changed

1 file changed

+2
-44
lines changed

src/monomorphize_collector.rs

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use rustc_middle::query::TyCtxtAt;
2424
use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion};
2525
use rustc_middle::ty::print::{shrunk_instance_name, with_no_trimmed_paths};
2626
use rustc_middle::ty::{
27-
self, GenericArgKind, GenericArgs, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable,
28-
TypeVisitableExt, VtblEntry,
27+
self, GenericArgs, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt,
28+
VtblEntry,
2929
};
3030
use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, mir::visit::TyContext};
3131
use rustc_session::Limit;
@@ -267,7 +267,6 @@ fn collect_items_rec<'tcx>(
267267
recursion_depths,
268268
recursion_limit,
269269
));
270-
check_type_length_limit(tcx, instance);
271270

272271
rustc_data_structures::stack::ensure_sufficient_stack(|| {
273272
collect_used_items(tcx, instance, &mut used_items);
@@ -403,47 +402,6 @@ fn check_recursion_limit<'tcx>(
403402
(def_id, recursion_depth)
404403
}
405404

406-
fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
407-
let type_length = instance
408-
.args
409-
.iter()
410-
.flat_map(|arg| arg.walk())
411-
.filter(|arg| match arg.unpack() {
412-
GenericArgKind::Type(_) | GenericArgKind::Const(_) => true,
413-
GenericArgKind::Lifetime(_) => false,
414-
})
415-
.count();
416-
debug!(" => type length={}", type_length);
417-
418-
// Rust code can easily create exponentially-long types using only a
419-
// polynomial recursion depth. Even with the default recursion
420-
// depth, you can easily get cases that take >2^60 steps to run,
421-
// which means that rustc basically hangs.
422-
//
423-
// Bail out in these cases to avoid that bad user experience.
424-
if !tcx.type_length_limit().value_within_limit(type_length) {
425-
let (shrunk, written_to_path) = shrunk_instance_name(tcx, instance);
426-
let msg = format!(
427-
"reached the type-length limit while instantiating `{}`",
428-
shrunk
429-
);
430-
let mut diag = tcx
431-
.dcx()
432-
.struct_span_fatal(tcx.def_span(instance.def_id()), msg);
433-
if let Some(path) = written_to_path {
434-
diag.note(format!(
435-
"the full type name has been written to '{}'",
436-
path.display()
437-
));
438-
}
439-
diag.help(format!(
440-
"consider adding a `#![type_length_limit=\"{}\"]` attribute to your crate",
441-
type_length
442-
));
443-
diag.emit();
444-
}
445-
}
446-
447405
struct MirUsedCollector<'a, 'tcx> {
448406
tcx: TyCtxt<'tcx>,
449407
body: &'a mir::Body<'tcx>,

0 commit comments

Comments
 (0)