@@ -410,6 +410,7 @@ impl<'tcx> Instance<'tcx> {
410
410
let args = tcx. erase_regions ( args) ;
411
411
tcx. resolve_instance ( tcx. erase_regions ( param_env. and ( ( def_id, args) ) ) )
412
412
}
413
+
413
414
/// Behaves exactly like [`resolve`], but panics on error.
414
415
pub fn expect_resolve (
415
416
tcx : TyCtxt < ' tcx > ,
@@ -526,6 +527,7 @@ impl<'tcx> Instance<'tcx> {
526
527
} )
527
528
}
528
529
}
530
+
529
531
/// Returns an instance representing closure of type `requested_kind` with `def_id` and subst set to `args`.
530
532
pub fn resolve_closure (
531
533
tcx : TyCtxt < ' tcx > ,
@@ -540,6 +542,7 @@ impl<'tcx> Instance<'tcx> {
540
542
_ => Instance :: new ( def_id, args) ,
541
543
}
542
544
}
545
+
543
546
/// Returns an instance representing the function [`drop_in_place`] with its generic argument set to `ty`.
544
547
pub fn resolve_drop_in_place ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> ty:: Instance < ' tcx > {
545
548
let def_id = tcx. require_lang_item ( LangItem :: DropInPlace , None ) ;
@@ -573,6 +576,7 @@ impl<'tcx> Instance<'tcx> {
573
576
debug ! ( ?self_ty, args=?tupled_inputs_ty. tuple_fields( ) ) ;
574
577
Instance { def, args }
575
578
}
579
+
576
580
pub fn try_resolve_item_for_coroutine (
577
581
tcx : TyCtxt < ' tcx > ,
578
582
trait_item_id : DefId ,
@@ -620,6 +624,7 @@ impl<'tcx> Instance<'tcx> {
620
624
Some ( Instance :: new ( trait_item_id, rcvr_args) )
621
625
}
622
626
}
627
+
623
628
/// Depending on the kind of `InstanceDef`, the MIR body associated with an
624
629
/// instance is expressed in terms of the generic parameters of `self.def_id()`, and in other
625
630
/// cases the MIR body is expressed in terms of the types found in the substitution array.
@@ -633,6 +638,7 @@ impl<'tcx> Instance<'tcx> {
633
638
fn args_for_mir_body ( & self ) -> Option < GenericArgsRef < ' tcx > > {
634
639
self . def . has_polymorphic_mir_body ( ) . then_some ( self . args )
635
640
}
641
+
636
642
/// Instantiates a generic value `v`(like `Vec<T>`), substituting its generic arguments and turning it into a concrete one(like `i32`, or `Vec<f32>`).
637
643
/// If a value is not generic, this will do nothing.
638
644
/// This function does not erase lifetimes, so a value like `&'a i32` will remain unchanged.
@@ -648,6 +654,7 @@ impl<'tcx> Instance<'tcx> {
648
654
v. instantiate_identity ( )
649
655
}
650
656
}
657
+
651
658
/// Instantiates a generic value `v`(like `Vec<T>`), substituting its generic arguments and turning it into a concrete one(like `i32`, or `Vec<f32>`).
652
659
/// This function erases lifetimes, so a value like `&'a i32` will become `&ReErased i32`.
653
660
/// If a value is not generic and has no lifetime info, this will do nothing.
@@ -669,6 +676,7 @@ impl<'tcx> Instance<'tcx> {
669
676
tcx. normalize_erasing_regions ( param_env, v. skip_binder ( ) )
670
677
}
671
678
}
679
+
672
680
/// A version of [`instantiate_mir_and_normalize_erasing_regions`] which will returns a [`NormalizationError`] on normalization failure instead of panicking.
673
681
#[ inline( always) ]
674
682
pub fn try_instantiate_mir_and_normalize_erasing_regions < T > (
@@ -847,30 +855,37 @@ impl UnusedGenericParams {
847
855
bitset. set_range ( 0 ..amount) ;
848
856
Self ( bitset)
849
857
}
858
+
850
859
/// Creates a new [`UnusedGenericParams`] where all generic pameters are set as used.
851
860
pub fn new_all_used ( ) -> Self {
852
861
Self ( FiniteBitSet :: new_empty ( ) )
853
862
}
863
+
854
864
/// Marks a generic paramenter at index `idx` as used.
855
865
pub fn mark_used ( & mut self , idx : u32 ) {
856
866
self . 0 . clear ( idx) ;
857
867
}
868
+
858
869
/// Returns true if generic paramenter at index `idx` unused, and false otherwise.
859
870
pub fn is_unused ( & self , idx : u32 ) -> bool {
860
871
self . 0 . contains ( idx) . unwrap_or ( false )
861
872
}
873
+
862
874
/// Returns true if generic paramenter at index `idx` used, and false otherwise.
863
875
pub fn is_used ( & self , idx : u32 ) -> bool {
864
876
!self . is_unused ( idx)
865
877
}
878
+
866
879
/// Returns true if all generic parameters are used, and false otherwise.
867
880
pub fn all_used ( & self ) -> bool {
868
881
self . 0 . is_empty ( )
869
882
}
883
+
870
884
/// Turns a [`UnusedGenericParams`] into its underlying bit representation.
871
885
pub fn bits ( & self ) -> u32 {
872
886
self . 0 . 0
873
887
}
888
+
874
889
/// Creates a [`UnusedGenericParams`] from its bit representation.
875
890
pub fn from_bits ( bits : u32 ) -> UnusedGenericParams {
876
891
UnusedGenericParams ( FiniteBitSet ( bits) )
0 commit comments