@@ -355,28 +355,10 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
355355 self . infcx . tcx . mk_imm_ref ( r, self . tcx ( ) . types . isize )
356356 }
357357
358- pub fn t_rptr_static ( & self ) -> Ty < ' tcx > {
359- self . infcx . tcx . mk_imm_ref ( self . infcx . tcx . types . re_static ,
360- self . tcx ( ) . types . isize )
361- }
362-
363- pub fn t_rptr_empty ( & self ) -> Ty < ' tcx > {
364- self . infcx . tcx . mk_imm_ref ( self . infcx . tcx . types . re_empty ,
365- self . tcx ( ) . types . isize )
366- }
367-
368358 pub fn sub ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) -> InferResult < ' tcx , ( ) > {
369359 self . infcx . at ( & ObligationCause :: dummy ( ) , self . param_env ) . sub ( t1, t2)
370360 }
371361
372- pub fn lub ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) -> InferResult < ' tcx , Ty < ' tcx > > {
373- self . infcx . at ( & ObligationCause :: dummy ( ) , self . param_env ) . lub ( t1, t2)
374- }
375-
376- pub fn glb ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) -> InferResult < ' tcx , Ty < ' tcx > > {
377- self . infcx . at ( & ObligationCause :: dummy ( ) , self . param_env ) . glb ( t1, t2)
378- }
379-
380362 /// Checks that `t1 <: t2` is true (this may register additional
381363 /// region checks).
382364 pub fn check_sub ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) {
@@ -401,37 +383,6 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
401383 }
402384 }
403385 }
404-
405- /// Checks that `LUB(t1,t2) == t_lub`
406- pub fn check_lub ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > , t_lub : Ty < ' tcx > ) {
407- match self . lub ( t1, t2) {
408- Ok ( InferOk { obligations, value : t } ) => {
409- // None of these tests should require nested obligations:
410- assert ! ( obligations. is_empty( ) ) ;
411-
412- self . assert_eq ( t, t_lub) ;
413- }
414- Err ( ref e) => panic ! ( "unexpected error in LUB: {}" , e) ,
415- }
416- }
417-
418- /// Checks that `GLB(t1,t2) == t_glb`
419- pub fn check_glb ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > , t_glb : Ty < ' tcx > ) {
420- debug ! ( "check_glb(t1={}, t2={}, t_glb={})" , t1, t2, t_glb) ;
421- match self . glb ( t1, t2) {
422- Err ( e) => panic ! ( "unexpected error computing LUB: {:?}" , e) ,
423- Ok ( InferOk { obligations, value : t } ) => {
424- // None of these tests should require nested obligations:
425- assert ! ( obligations. is_empty( ) ) ;
426-
427- self . assert_eq ( t, t_glb) ;
428-
429- // sanity check for good measure:
430- self . assert_subtype ( t, t1) ;
431- self . assert_subtype ( t, t2) ;
432- }
433- }
434- }
435386}
436387
437388#[ test]
@@ -510,169 +461,6 @@ fn sub_free_bound_false_infer() {
510461 } )
511462}
512463
513- #[ test]
514- fn lub_free_bound_infer ( ) {
515- //! Test result of:
516- //!
517- //! LUB(fn(_#1), for<'b> fn(&'b isize))
518- //!
519- //! This should yield `fn(&'_ isize)`. We check
520- //! that it yields `fn(&'x isize)` for some free `'x`,
521- //! anyhow.
522-
523- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |mut env| {
524- env. create_simple_region_hierarchy ( ) ;
525- let t_infer1 = env. infcx . next_ty_var ( TypeVariableOrigin :: MiscVariable ( DUMMY_SP ) ) ;
526- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
527- let t_rptr_free1 = env. t_rptr_free ( 1 ) ;
528- env. check_lub ( env. t_fn ( & [ t_infer1] , env. tcx ( ) . types . isize ) ,
529- env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
530- env. t_fn ( & [ t_rptr_free1] , env. tcx ( ) . types . isize ) ) ;
531- } ) ;
532- }
533-
534- #[ test]
535- fn lub_bound_bound ( ) {
536- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |env| {
537- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
538- let t_rptr_bound2 = env. t_rptr_late_bound ( 2 ) ;
539- env. check_lub ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
540- env. t_fn ( & [ t_rptr_bound2] , env. tcx ( ) . types . isize ) ,
541- env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ) ;
542- } )
543- }
544-
545- #[ test]
546- fn lub_bound_free ( ) {
547- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |mut env| {
548- env. create_simple_region_hierarchy ( ) ;
549- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
550- let t_rptr_free1 = env. t_rptr_free ( 1 ) ;
551- env. check_lub ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
552- env. t_fn ( & [ t_rptr_free1] , env. tcx ( ) . types . isize ) ,
553- env. t_fn ( & [ t_rptr_free1] , env. tcx ( ) . types . isize ) ) ;
554- } )
555- }
556-
557- #[ test]
558- fn lub_bound_static ( ) {
559- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |env| {
560- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
561- let t_rptr_static = env. t_rptr_static ( ) ;
562- env. check_lub ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
563- env. t_fn ( & [ t_rptr_static] , env. tcx ( ) . types . isize ) ,
564- env. t_fn ( & [ t_rptr_static] , env. tcx ( ) . types . isize ) ) ;
565- } )
566- }
567-
568- #[ test]
569- fn lub_bound_bound_inverse_order ( ) {
570- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |env| {
571- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
572- let t_rptr_bound2 = env. t_rptr_late_bound ( 2 ) ;
573- env. check_lub ( env. t_fn ( & [ t_rptr_bound1, t_rptr_bound2] , t_rptr_bound1) ,
574- env. t_fn ( & [ t_rptr_bound2, t_rptr_bound1] , t_rptr_bound1) ,
575- env. t_fn ( & [ t_rptr_bound1, t_rptr_bound1] , t_rptr_bound1) ) ;
576- } )
577- }
578-
579- #[ test]
580- fn lub_free_free ( ) {
581- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |mut env| {
582- env. create_simple_region_hierarchy ( ) ;
583- let t_rptr_free1 = env. t_rptr_free ( 1 ) ;
584- let t_rptr_free2 = env. t_rptr_free ( 2 ) ;
585- let t_rptr_static = env. t_rptr_static ( ) ;
586- env. check_lub ( env. t_fn ( & [ t_rptr_free1] , env. tcx ( ) . types . isize ) ,
587- env. t_fn ( & [ t_rptr_free2] , env. tcx ( ) . types . isize ) ,
588- env. t_fn ( & [ t_rptr_static] , env. tcx ( ) . types . isize ) ) ;
589- } )
590- }
591-
592- #[ test]
593- fn lub_returning_scope ( ) {
594- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |mut env| {
595- env. create_simple_region_hierarchy ( ) ;
596- let t_rptr_scope10 = env. t_rptr_scope ( 10 ) ;
597- let t_rptr_scope11 = env. t_rptr_scope ( 11 ) ;
598- let t_rptr_empty = env. t_rptr_empty ( ) ;
599- env. check_lub ( env. t_fn ( & [ t_rptr_scope10] , env. tcx ( ) . types . isize ) ,
600- env. t_fn ( & [ t_rptr_scope11] , env. tcx ( ) . types . isize ) ,
601- env. t_fn ( & [ t_rptr_empty] , env. tcx ( ) . types . isize ) ) ;
602- } ) ;
603- }
604-
605- #[ test]
606- fn glb_free_free_with_common_scope ( ) {
607- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |mut env| {
608- env. create_simple_region_hierarchy ( ) ;
609- let t_rptr_free1 = env. t_rptr_free ( 1 ) ;
610- let t_rptr_free2 = env. t_rptr_free ( 2 ) ;
611- let t_rptr_scope = env. t_rptr_scope ( 1 ) ;
612- env. check_glb ( env. t_fn ( & [ t_rptr_free1] , env. tcx ( ) . types . isize ) ,
613- env. t_fn ( & [ t_rptr_free2] , env. tcx ( ) . types . isize ) ,
614- env. t_fn ( & [ t_rptr_scope] , env. tcx ( ) . types . isize ) ) ;
615- } )
616- }
617-
618- #[ test]
619- fn glb_bound_bound ( ) {
620- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |env| {
621- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
622- let t_rptr_bound2 = env. t_rptr_late_bound ( 2 ) ;
623- env. check_glb ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
624- env. t_fn ( & [ t_rptr_bound2] , env. tcx ( ) . types . isize ) ,
625- env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ) ;
626- } )
627- }
628-
629- #[ test]
630- fn glb_bound_free ( ) {
631- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |mut env| {
632- env. create_simple_region_hierarchy ( ) ;
633- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
634- let t_rptr_free1 = env. t_rptr_free ( 1 ) ;
635- env. check_glb ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
636- env. t_fn ( & [ t_rptr_free1] , env. tcx ( ) . types . isize ) ,
637- env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ) ;
638- } )
639- }
640-
641- #[ test]
642- fn glb_bound_free_infer ( ) {
643- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |env| {
644- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
645- let t_infer1 = env. infcx . next_ty_var ( TypeVariableOrigin :: MiscVariable ( DUMMY_SP ) ) ;
646-
647- // compute GLB(fn(_) -> isize, for<'b> fn(&'b isize) -> isize),
648- // which should yield for<'b> fn(&'b isize) -> isize
649- env. check_glb ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
650- env. t_fn ( & [ t_infer1] , env. tcx ( ) . types . isize ) ,
651- env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ) ;
652-
653- // as a side-effect, computing GLB should unify `_` with
654- // `&'_ isize`
655- let t_resolve1 = env. infcx . shallow_resolve ( t_infer1) ;
656- match t_resolve1. sty {
657- ty:: TyRef ( ..) => { }
658- _ => {
659- panic ! ( "t_resolve1={:?}" , t_resolve1) ;
660- }
661- }
662- } )
663- }
664-
665- #[ test]
666- fn glb_bound_static ( ) {
667- test_env ( EMPTY_SOURCE_STR , errors ( & [ ] ) , |env| {
668- let t_rptr_bound1 = env. t_rptr_late_bound ( 1 ) ;
669- let t_rptr_static = env. t_rptr_static ( ) ;
670- env. check_glb ( env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ,
671- env. t_fn ( & [ t_rptr_static] , env. tcx ( ) . types . isize ) ,
672- env. t_fn ( & [ t_rptr_bound1] , env. tcx ( ) . types . isize ) ) ;
673- } )
674- }
675-
676464/// Test substituting a bound region into a function, which introduces another level of binding.
677465/// This requires adjusting the Debruijn index.
678466#[ test]
0 commit comments