@@ -3,7 +3,6 @@ use crate::errors::CtorIsPrivate;
3
3
use crate :: method:: { self , MethodCallee , SelfSource } ;
4
4
use crate :: rvalue_scopes;
5
5
use crate :: { BreakableCtxt , Diverges , Expectation , FnCtxt , LoweredTy } ;
6
- use rustc_data_structures:: captures:: Captures ;
7
6
use rustc_data_structures:: fx:: FxHashSet ;
8
7
use rustc_errors:: { Applicability , Diag , ErrorGuaranteed , MultiSpan , StashKey } ;
9
8
use rustc_hir as hir;
@@ -47,7 +46,7 @@ use std::slice;
47
46
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
48
47
/// Produces warning on the given node, if the current point in the
49
48
/// function is unreachable, and there hasn't been another warning.
50
- pub ( in super :: super ) fn warn_if_unreachable ( & self , id : HirId , span : Span , kind : & str ) {
49
+ pub ( crate ) fn warn_if_unreachable ( & self , id : HirId , span : Span , kind : & str ) {
51
50
// FIXME: Combine these two 'if' expressions into one once
52
51
// let chains are implemented
53
52
if let Diverges :: Always { span : orig_span, custom_note } = self . diverges . get ( ) {
@@ -87,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
87
86
// FIXME(-Znext-solver): A lot of the calls to this method should
88
87
// probably be `try_structurally_resolve_type` or `structurally_resolve_type` instead.
89
88
#[ instrument( skip( self ) , level = "debug" , ret) ]
90
- pub ( in super :: super ) fn resolve_vars_with_obligations ( & self , mut ty : Ty < ' tcx > ) -> Ty < ' tcx > {
89
+ pub ( crate ) fn resolve_vars_with_obligations ( & self , mut ty : Ty < ' tcx > ) -> Ty < ' tcx > {
91
90
// No Infer()? Nothing needs doing.
92
91
if !ty. has_non_region_infer ( ) {
93
92
debug ! ( "no inference var, nothing needs doing" ) ;
@@ -109,7 +108,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
109
108
self . resolve_vars_if_possible ( ty)
110
109
}
111
110
112
- pub ( in super :: super ) fn record_deferred_call_resolution (
111
+ pub ( crate ) fn record_deferred_call_resolution (
113
112
& self ,
114
113
closure_def_id : LocalDefId ,
115
114
r : DeferredCallResolution < ' tcx > ,
@@ -118,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
118
117
deferred_call_resolutions. entry ( closure_def_id) . or_default ( ) . push ( r) ;
119
118
}
120
119
121
- pub ( in super :: super ) fn remove_deferred_call_resolutions (
120
+ pub ( crate ) fn remove_deferred_call_resolutions (
122
121
& self ,
123
122
closure_def_id : LocalDefId ,
124
123
) -> Vec < DeferredCallResolution < ' tcx > > {
@@ -172,7 +171,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
172
171
}
173
172
174
173
#[ instrument( level = "debug" , skip( self ) ) ]
175
- pub ( in super :: super ) fn write_resolution (
174
+ pub ( crate ) fn write_resolution (
176
175
& self ,
177
176
hir_id : HirId ,
178
177
r : Result < ( DefKind , DefId ) , ErrorGuaranteed > ,
@@ -336,7 +335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
336
335
}
337
336
338
337
/// Instantiates and normalizes the bounds for a given item
339
- pub ( in super :: super ) fn instantiate_bounds (
338
+ pub ( crate ) fn instantiate_bounds (
340
339
& self ,
341
340
span : Span ,
342
341
def_id : DefId ,
@@ -349,7 +348,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
349
348
result
350
349
}
351
350
352
- pub ( in super :: super ) fn normalize < T > ( & self , span : Span , value : T ) -> T
351
+ pub ( crate ) fn normalize < T > ( & self , span : Span , value : T ) -> T
353
352
where
354
353
T : TypeFoldable < TyCtxt < ' tcx > > ,
355
354
{
@@ -537,7 +536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
537
536
self . normalize ( span, field. ty ( self . tcx , args) )
538
537
}
539
538
540
- pub ( in super :: super ) fn resolve_rvalue_scopes ( & self , def_id : DefId ) {
539
+ pub ( crate ) fn resolve_rvalue_scopes ( & self , def_id : DefId ) {
541
540
let scope_tree = self . tcx . region_scope_tree ( def_id) ;
542
541
let rvalue_scopes = { rvalue_scopes:: resolve_rvalue_scopes ( self , scope_tree, def_id) } ;
543
542
let mut typeck_results = self . typeck_results . borrow_mut ( ) ;
@@ -553,7 +552,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
553
552
/// We must not attempt to select obligations after this method has run, or risk query cycle
554
553
/// ICE.
555
554
#[ instrument( level = "debug" , skip( self ) ) ]
556
- pub ( in super :: super ) fn resolve_coroutine_interiors ( & self ) {
555
+ pub ( crate ) fn resolve_coroutine_interiors ( & self ) {
557
556
// Try selecting all obligations that are not blocked on inference variables.
558
557
// Once we start unifying coroutine witnesses, trying to select obligations on them will
559
558
// trigger query cycle ICEs, as doing so requires MIR.
@@ -594,7 +593,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
594
593
}
595
594
596
595
#[ instrument( skip( self ) , level = "debug" ) ]
597
- pub ( in super :: super ) fn report_ambiguity_errors ( & self ) {
596
+ pub ( crate ) fn report_ambiguity_errors ( & self ) {
598
597
let mut errors = self . fulfillment_cx . borrow_mut ( ) . collect_remaining_errors ( self ) ;
599
598
600
599
if !errors. is_empty ( ) {
@@ -609,7 +608,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
609
608
}
610
609
611
610
/// Select as many obligations as we can at present.
612
- pub ( in super :: super ) fn select_obligations_where_possible (
611
+ pub ( crate ) fn select_obligations_where_possible (
613
612
& self ,
614
613
mutate_fulfillment_errors : impl Fn ( & mut Vec < traits:: FulfillmentError < ' tcx > > ) ,
615
614
) {
@@ -625,7 +624,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
625
624
/// returns a type of `&T`, but the actual type we assign to the
626
625
/// *expression* is `T`. So this function just peels off the return
627
626
/// type by one layer to yield `T`.
628
- pub ( in super :: super ) fn make_overloaded_place_return_type (
627
+ pub ( crate ) fn make_overloaded_place_return_type (
629
628
& self ,
630
629
method : MethodCallee < ' tcx > ,
631
630
) -> ty:: TypeAndMut < ' tcx > {
@@ -636,67 +635,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
636
635
ret_ty. builtin_deref ( true ) . unwrap ( )
637
636
}
638
637
639
- #[ instrument( skip( self ) , level = "debug" ) ]
640
- fn self_type_matches_expected_vid ( & self , self_ty : Ty < ' tcx > , expected_vid : ty:: TyVid ) -> bool {
641
- let self_ty = self . shallow_resolve ( self_ty) ;
642
- debug ! ( ?self_ty) ;
643
-
644
- match * self_ty. kind ( ) {
645
- ty:: Infer ( ty:: TyVar ( found_vid) ) => {
646
- let found_vid = self . root_var ( found_vid) ;
647
- debug ! ( "self_type_matches_expected_vid - found_vid={:?}" , found_vid) ;
648
- expected_vid == found_vid
649
- }
650
- _ => false ,
651
- }
652
- }
653
-
654
- #[ instrument( skip( self ) , level = "debug" ) ]
655
- pub ( in super :: super ) fn obligations_for_self_ty < ' b > (
656
- & ' b self ,
657
- self_ty : ty:: TyVid ,
658
- ) -> impl DoubleEndedIterator < Item = traits:: PredicateObligation < ' tcx > > + Captures < ' tcx > + ' b
659
- {
660
- let ty_var_root = self . root_var ( self_ty) ;
661
- trace ! ( "pending_obligations = {:#?}" , self . fulfillment_cx. borrow( ) . pending_obligations( ) ) ;
662
-
663
- self . fulfillment_cx . borrow ( ) . pending_obligations ( ) . into_iter ( ) . filter_map (
664
- move |obligation| match & obligation. predicate . kind ( ) . skip_binder ( ) {
665
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( data) )
666
- if self . self_type_matches_expected_vid (
667
- data. projection_ty . self_ty ( ) ,
668
- ty_var_root,
669
- ) =>
670
- {
671
- Some ( obligation)
672
- }
673
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( data) )
674
- if self . self_type_matches_expected_vid ( data. self_ty ( ) , ty_var_root) =>
675
- {
676
- Some ( obligation)
677
- }
678
-
679
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( ..) )
680
- | ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( ..) )
681
- | ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ..) )
682
- | ty:: PredicateKind :: Subtype ( ..)
683
- | ty:: PredicateKind :: Coerce ( ..)
684
- | ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives ( ..) )
685
- | ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives ( ..) )
686
- | ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( ..) )
687
- | ty:: PredicateKind :: ObjectSafe ( ..)
688
- | ty:: PredicateKind :: NormalizesTo ( ..)
689
- | ty:: PredicateKind :: AliasRelate ( ..)
690
- | ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstEvaluatable ( ..) )
691
- | ty:: PredicateKind :: ConstEquate ( ..)
692
- | ty:: PredicateKind :: Ambiguous => None ,
693
- } ,
694
- )
695
- }
696
-
697
- pub ( in super :: super ) fn type_var_is_sized ( & self , self_ty : ty:: TyVid ) -> bool {
638
+ pub ( crate ) fn type_var_is_sized ( & self , self_ty : ty:: TyVid ) -> bool {
698
639
let sized_did = self . tcx . lang_items ( ) . sized_trait ( ) ;
699
- self . obligations_for_self_ty ( self_ty) . any ( |obligation| {
640
+ self . obligations_for_self_ty ( self_ty) . into_iter ( ) . any ( |obligation| {
700
641
match obligation. predicate . kind ( ) . skip_binder ( ) {
701
642
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( data) ) => {
702
643
Some ( data. def_id ( ) ) == sized_did
@@ -706,15 +647,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
706
647
} )
707
648
}
708
649
709
- pub ( in super :: super ) fn err_args ( & self , len : usize ) -> Vec < Ty < ' tcx > > {
650
+ pub ( crate ) fn err_args ( & self , len : usize ) -> Vec < Ty < ' tcx > > {
710
651
let ty_error = Ty :: new_misc_error ( self . tcx ) ;
711
652
vec ! [ ty_error; len]
712
653
}
713
654
714
655
/// Unifies the output type with the expected type early, for more coercions
715
656
/// and forward type information on the input expressions.
716
657
#[ instrument( skip( self , call_span) , level = "debug" ) ]
717
- pub ( in super :: super ) fn expected_inputs_for_expected_output (
658
+ pub ( crate ) fn expected_inputs_for_expected_output (
718
659
& self ,
719
660
call_span : Span ,
720
661
expected_ret : Expectation < ' tcx > ,
@@ -747,7 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
747
688
expect_args
748
689
}
749
690
750
- pub ( in super :: super ) fn resolve_lang_item_path (
691
+ pub ( crate ) fn resolve_lang_item_path (
751
692
& self ,
752
693
lang_item : hir:: LangItem ,
753
694
span : Span ,
@@ -926,7 +867,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
926
867
/// but we often want access to the parent function's signature.
927
868
///
928
869
/// Otherwise, return false.
929
- pub ( in super :: super ) fn get_node_fn_decl (
870
+ pub ( crate ) fn get_node_fn_decl (
930
871
& self ,
931
872
node : Node < ' tcx > ,
932
873
) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , Ident , bool ) > {
@@ -1004,7 +945,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1004
945
} )
1005
946
}
1006
947
1007
- pub ( in super :: super ) fn note_internal_mutation_in_method (
948
+ pub ( crate ) fn note_internal_mutation_in_method (
1008
949
& self ,
1009
950
err : & mut Diag < ' _ > ,
1010
951
expr : & hir:: Expr < ' _ > ,
@@ -1549,7 +1490,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1549
1490
}
1550
1491
}
1551
1492
1552
- pub ( in super :: super ) fn with_breakable_ctxt < F : FnOnce ( ) -> R , R > (
1493
+ pub ( crate ) fn with_breakable_ctxt < F : FnOnce ( ) -> R , R > (
1553
1494
& self ,
1554
1495
id : HirId ,
1555
1496
ctxt : BreakableCtxt < ' tcx > ,
@@ -1575,7 +1516,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1575
1516
1576
1517
/// Instantiate a QueryResponse in a probe context, without a
1577
1518
/// good ObligationCause.
1578
- pub ( in super :: super ) fn probe_instantiate_query_response (
1519
+ pub ( crate ) fn probe_instantiate_query_response (
1579
1520
& self ,
1580
1521
span : Span ,
1581
1522
original_values : & OriginalQueryValues < ' tcx > ,
@@ -1590,7 +1531,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1590
1531
}
1591
1532
1592
1533
/// Returns `true` if an expression is contained inside the LHS of an assignment expression.
1593
- pub ( in super :: super ) fn expr_in_place ( & self , mut expr_id : HirId ) -> bool {
1534
+ pub ( crate ) fn expr_in_place ( & self , mut expr_id : HirId ) -> bool {
1594
1535
let mut contained_in_place = false ;
1595
1536
1596
1537
while let hir:: Node :: Expr ( parent_expr) = self . tcx . parent_hir_node ( expr_id) {
0 commit comments