@@ -515,79 +515,107 @@ pub struct CReaderCacheKey {
515
515
pub pos : usize ,
516
516
}
517
517
518
- // Flags that we track on types. These flags are propagated upwards
519
- // through the type during type construction, so that we can quickly
520
- // check whether the type has various kinds of types in it without
521
- // recursing over the type itself.
522
518
bitflags ! {
519
+ /// Flags that we track on types. These flags are propagated upwards
520
+ /// through the type during type construction, so that we can quickly check
521
+ /// whether the type has various kinds of types in it without recursing
522
+ /// over the type itself.
523
523
pub struct TypeFlags : u32 {
524
- const HAS_PARAMS = 1 << 0 ;
525
- const HAS_TY_INFER = 1 << 1 ;
526
- const HAS_RE_INFER = 1 << 2 ;
527
- const HAS_RE_PLACEHOLDER = 1 << 3 ;
528
-
529
- /// Does this have any `ReEarlyBound` regions? Used to
530
- /// determine whether substitition is required, since those
531
- /// represent regions that are bound in a `ty::Generics` and
532
- /// hence may be substituted.
533
- const HAS_RE_EARLY_BOUND = 1 << 4 ;
534
-
535
- /// Does this have any region that "appears free" in the type?
536
- /// Basically anything but `ReLateBound` and `ReErased`.
537
- const HAS_FREE_REGIONS = 1 << 5 ;
538
-
539
- /// Is an error type reachable?
540
- const HAS_TY_ERR = 1 << 6 ;
541
- const HAS_PROJECTION = 1 << 7 ;
542
-
543
- // FIXME: Rename this to the actual property since it's used for generators too
544
- const HAS_TY_CLOSURE = 1 << 8 ;
524
+ // Does this have parameters? Used to determine whether substitution is
525
+ // required.
526
+ /// Does this have [Param]?
527
+ const HAS_TY_PARAM = 1 << 0 ;
528
+ /// Does this have [ReEarlyBound]?
529
+ const HAS_RE_PARAM = 1 << 1 ;
530
+ /// Does this have [ConstKind::Param]?
531
+ const HAS_CT_PARAM = 1 << 2 ;
532
+
533
+ const NEEDS_SUBST = TypeFlags :: HAS_TY_PARAM . bits
534
+ | TypeFlags :: HAS_RE_PARAM . bits
535
+ | TypeFlags :: HAS_CT_PARAM . bits;
536
+
537
+ /// Does this have [Infer]?
538
+ const HAS_TY_INFER = 1 << 3 ;
539
+ /// Does this have [ReVar]?
540
+ const HAS_RE_INFER = 1 << 4 ;
541
+ /// Does this have [ConstKind::Infer]?
542
+ const HAS_CT_INFER = 1 << 5 ;
543
+
544
+ /// Does this have inference variables? Used to determine whether
545
+ /// inference is required.
546
+ const NEEDS_INFER = TypeFlags :: HAS_TY_INFER . bits
547
+ | TypeFlags :: HAS_RE_INFER . bits
548
+ | TypeFlags :: HAS_CT_INFER . bits;
549
+
550
+ /// Does this have [Placeholder]?
551
+ const HAS_TY_PLACEHOLDER = 1 << 6 ;
552
+ /// Does this have [RePlaceholder]?
553
+ const HAS_RE_PLACEHOLDER = 1 << 7 ;
554
+ /// Does this have [ConstKind::Placeholder]?
555
+ const HAS_CT_PLACEHOLDER = 1 << 8 ;
545
556
546
557
/// `true` if there are "names" of types and regions and so forth
547
558
/// that are local to a particular fn
548
- const HAS_FREE_LOCAL_NAMES = 1 << 9 ;
559
+ const HAS_FREE_LOCAL_NAMES = TypeFlags :: HAS_TY_PARAM . bits
560
+ | TypeFlags :: HAS_RE_PARAM . bits
561
+ | TypeFlags :: HAS_CT_PARAM . bits
562
+ | TypeFlags :: HAS_TY_INFER . bits
563
+ | TypeFlags :: HAS_RE_INFER . bits
564
+ | TypeFlags :: HAS_CT_INFER . bits
565
+ | TypeFlags :: HAS_TY_PLACEHOLDER . bits
566
+ | TypeFlags :: HAS_RE_PLACEHOLDER . bits
567
+ | TypeFlags :: HAS_CT_PLACEHOLDER . bits;
568
+
569
+ /// Does this have [Projection] or [UnnormalizedProjection]?
570
+ const HAS_TY_PROJECTION = 1 << 9 ;
571
+ /// Does this have [Opaque]?
572
+ const HAS_TY_OPAQUE = 1 << 10 ;
573
+ /// Does this have [ConstKind::Unevaluated]?
574
+ const HAS_CT_PROJECTION = 1 << 11 ;
575
+
576
+ /// Could this type be normalized further?
577
+ const HAS_PROJECTION = TypeFlags :: HAS_TY_PROJECTION . bits
578
+ | TypeFlags :: HAS_TY_OPAQUE . bits
579
+ | TypeFlags :: HAS_CT_PROJECTION . bits;
549
580
550
581
/// Present if the type belongs in a local type context.
551
- /// Only set for Infer other than Fresh.
552
- const KEEP_IN_LOCAL_TCX = 1 << 10 ;
553
-
554
- /// Does this have any `ReLateBound` regions? Used to check
555
- /// if a global bound is safe to evaluate.
556
- const HAS_RE_LATE_BOUND = 1 << 11 ;
582
+ /// Set for placeholders and inference variables that are not "Fresh".
583
+ const KEEP_IN_LOCAL_TCX = 1 << 12 ;
557
584
558
- /// Does this have any `ReErased` regions ?
559
- const HAS_RE_ERASED = 1 << 12 ;
585
+ /// Is an error type reachable ?
586
+ const HAS_TY_ERR = 1 << 13 ;
560
587
561
- const HAS_TY_PLACEHOLDER = 1 << 13 ;
588
+ /// Does this have any region that "appears free" in the type?
589
+ /// Basically anything but [ReLateBound] and [ReErased].
590
+ const HAS_FREE_REGIONS = 1 << 14 ;
562
591
563
- const HAS_CT_INFER = 1 << 14 ;
564
- const HAS_CT_PLACEHOLDER = 1 << 15 ;
565
- /// Does this have any [Opaque] types.
566
- const HAS_TY_OPAQUE = 1 << 16 ;
592
+ /// Does this have any [ReLateBound] regions? Used to check
593
+ /// if a global bound is safe to evaluate.
594
+ const HAS_RE_LATE_BOUND = 1 << 15 ;
567
595
568
- const NEEDS_SUBST = TypeFlags :: HAS_PARAMS . bits |
569
- TypeFlags :: HAS_RE_EARLY_BOUND . bits ;
596
+ /// Does this have any [ReErased] regions?
597
+ const HAS_RE_ERASED = 1 << 16 ;
570
598
571
599
/// Flags representing the nominal content of a type,
572
600
/// computed by FlagsComputation. If you add a new nominal
573
601
/// flag, it should be added here too.
574
- const NOMINAL_FLAGS = TypeFlags :: HAS_PARAMS . bits |
575
- TypeFlags :: HAS_TY_INFER . bits |
576
- TypeFlags :: HAS_RE_INFER . bits |
577
- TypeFlags :: HAS_RE_PLACEHOLDER . bits |
578
- TypeFlags :: HAS_RE_EARLY_BOUND . bits |
579
- TypeFlags :: HAS_FREE_REGIONS . bits |
580
- TypeFlags :: HAS_TY_ERR . bits |
581
- TypeFlags :: HAS_PROJECTION . bits |
582
- TypeFlags :: HAS_TY_CLOSURE . bits |
583
- TypeFlags :: HAS_FREE_LOCAL_NAMES . bits |
584
- TypeFlags :: KEEP_IN_LOCAL_TCX . bits |
585
- TypeFlags :: HAS_RE_LATE_BOUND . bits |
586
- TypeFlags :: HAS_RE_ERASED . bits |
587
- TypeFlags :: HAS_TY_PLACEHOLDER . bits |
588
- TypeFlags :: HAS_CT_INFER . bits |
589
- TypeFlags :: HAS_CT_PLACEHOLDER . bits |
590
- TypeFlags :: HAS_TY_OPAQUE . bits;
602
+ const NOMINAL_FLAGS = TypeFlags :: HAS_TY_PARAM . bits
603
+ | TypeFlags :: HAS_RE_PARAM . bits
604
+ | TypeFlags :: HAS_CT_PARAM . bits
605
+ | TypeFlags :: HAS_TY_INFER . bits
606
+ | TypeFlags :: HAS_RE_INFER . bits
607
+ | TypeFlags :: HAS_CT_INFER . bits
608
+ | TypeFlags :: HAS_TY_PLACEHOLDER . bits
609
+ | TypeFlags :: HAS_RE_PLACEHOLDER . bits
610
+ | TypeFlags :: HAS_CT_PLACEHOLDER . bits
611
+ | TypeFlags :: HAS_TY_PROJECTION . bits
612
+ | TypeFlags :: HAS_TY_OPAQUE . bits
613
+ | TypeFlags :: HAS_CT_PROJECTION . bits
614
+ | TypeFlags :: KEEP_IN_LOCAL_TCX . bits
615
+ | TypeFlags :: HAS_TY_ERR . bits
616
+ | TypeFlags :: HAS_FREE_REGIONS . bits
617
+ | TypeFlags :: HAS_RE_LATE_BOUND . bits
618
+ | TypeFlags :: HAS_RE_ERASED . bits;
591
619
}
592
620
}
593
621
@@ -1816,10 +1844,10 @@ impl<'tcx> ParamEnv<'tcx> {
1816
1844
Reveal :: UserFacing => ParamEnvAnd { param_env : self , value } ,
1817
1845
1818
1846
Reveal :: All => {
1819
- if value. has_placeholders ( ) || value. needs_infer ( ) || value. has_param_types ( ) {
1820
- ParamEnvAnd { param_env : self , value }
1821
- } else {
1847
+ if value. is_global ( ) {
1822
1848
ParamEnvAnd { param_env : self . without_caller_bounds ( ) , value }
1849
+ } else {
1850
+ ParamEnvAnd { param_env : self , value }
1823
1851
}
1824
1852
}
1825
1853
}
0 commit comments