@@ -24,8 +24,8 @@ use rustc_middle::query::TyCtxtAt;
24
24
use rustc_middle:: ty:: adjustment:: { CustomCoerceUnsized , PointerCoercion } ;
25
25
use rustc_middle:: ty:: print:: { shrunk_instance_name, with_no_trimmed_paths} ;
26
26
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 ,
29
29
} ;
30
30
use rustc_middle:: { middle:: codegen_fn_attrs:: CodegenFnAttrFlags , mir:: visit:: TyContext } ;
31
31
use rustc_session:: Limit ;
@@ -267,7 +267,6 @@ fn collect_items_rec<'tcx>(
267
267
recursion_depths,
268
268
recursion_limit,
269
269
) ) ;
270
- check_type_length_limit ( tcx, instance) ;
271
270
272
271
rustc_data_structures:: stack:: ensure_sufficient_stack ( || {
273
272
collect_used_items ( tcx, instance, & mut used_items) ;
@@ -403,47 +402,6 @@ fn check_recursion_limit<'tcx>(
403
402
( def_id, recursion_depth)
404
403
}
405
404
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
-
447
405
struct MirUsedCollector < ' a , ' tcx > {
448
406
tcx : TyCtxt < ' tcx > ,
449
407
body : & ' a mir:: Body < ' tcx > ,
0 commit comments