@@ -9,6 +9,7 @@ mod engine;
9
9
pub mod error_reporting;
10
10
mod fulfill;
11
11
pub mod misc;
12
+ pub mod normalize;
12
13
mod object_safety;
13
14
pub mod outlives_bounds;
14
15
pub mod project;
@@ -40,17 +41,15 @@ use rustc_span::Span;
40
41
use std:: fmt:: Debug ;
41
42
use std:: ops:: ControlFlow ;
42
43
43
- pub ( crate ) use self :: project:: { needs_normalization, BoundVarReplacer , PlaceholderReplacer } ;
44
-
45
44
pub use self :: coherence:: { add_placeholder_note, orphan_check, overlapping_impls} ;
46
45
pub use self :: coherence:: { OrphanCheckErr , OverlapResult } ;
47
46
pub use self :: engine:: { ObligationCtxt , TraitEngineExt } ;
48
47
pub use self :: fulfill:: { FulfillmentContext , PendingPredicateObligation } ;
48
+ pub use self :: normalize:: NormalizeExt ;
49
49
pub use self :: object_safety:: astconv_object_safety_violations;
50
50
pub use self :: object_safety:: is_vtable_safe_method;
51
51
pub use self :: object_safety:: object_safety_violations_for_assoc_item;
52
52
pub use self :: object_safety:: ObjectSafetyViolation ;
53
- pub use self :: project:: NormalizeExt ;
54
53
pub use self :: project:: { normalize_inherent_projection, normalize_projection_type} ;
55
54
pub use self :: select:: { EvaluationCache , SelectionCache , SelectionContext } ;
56
55
pub use self :: select:: { EvaluationResult , IntercrateAmbiguityCause , OverflowError } ;
@@ -68,6 +67,7 @@ pub use self::util::{
68
67
} ;
69
68
pub use self :: util:: { expand_trait_aliases, TraitAliasExpander } ;
70
69
pub use self :: util:: { get_vtable_index_of_object_method, impl_item_is_final, upcast_choices} ;
70
+ pub use self :: util:: { with_replaced_escaping_bound_vars, BoundVarReplacer , PlaceholderReplacer } ;
71
71
72
72
pub use rustc_infer:: traits:: * ;
73
73
@@ -119,60 +119,16 @@ pub fn predicates_for_generics<'tcx>(
119
119
120
120
/// Determines whether the type `ty` is known to meet `bound` and
121
121
/// returns true if so. Returns false if `ty` either does not meet
122
- /// `bound` or is not known to meet bound (note that this is
123
- /// conservative towards *no impl*, which is the opposite of the
124
- /// `evaluate` methods).
122
+ /// `bound` or is not known to meet bound.
125
123
pub fn type_known_to_meet_bound_modulo_regions < ' tcx > (
126
124
infcx : & InferCtxt < ' tcx > ,
127
125
param_env : ty:: ParamEnv < ' tcx > ,
128
126
ty : Ty < ' tcx > ,
129
127
def_id : DefId ,
130
128
) -> bool {
131
129
let trait_ref = ty:: TraitRef :: new ( infcx. tcx , def_id, [ ty] ) ;
132
- pred_known_to_hold_modulo_regions ( infcx, param_env, trait_ref)
133
- }
134
-
135
- /// FIXME(@lcnr): this function doesn't seem right and shouldn't exist?
136
- ///
137
- /// Ping me on zulip if you want to use this method and need help with finding
138
- /// an appropriate replacement.
139
- #[ instrument( level = "debug" , skip( infcx, param_env, pred) , ret) ]
140
- fn pred_known_to_hold_modulo_regions < ' tcx > (
141
- infcx : & InferCtxt < ' tcx > ,
142
- param_env : ty:: ParamEnv < ' tcx > ,
143
- pred : impl ToPredicate < ' tcx > ,
144
- ) -> bool {
145
- let obligation = Obligation :: new ( infcx. tcx , ObligationCause :: dummy ( ) , param_env, pred) ;
146
-
147
- let result = infcx. evaluate_obligation_no_overflow ( & obligation) ;
148
- debug ! ( ?result) ;
149
-
150
- if result. must_apply_modulo_regions ( ) {
151
- true
152
- } else if result. may_apply ( ) {
153
- // Sometimes obligations are ambiguous because the recursive evaluator
154
- // is not smart enough, so we fall back to fulfillment when we're not certain
155
- // that an obligation holds or not. Even still, we must make sure that
156
- // the we do no inference in the process of checking this obligation.
157
- let goal = infcx. resolve_vars_if_possible ( ( obligation. predicate , obligation. param_env ) ) ;
158
- infcx. probe ( |_| {
159
- let ocx = ObligationCtxt :: new ( infcx) ;
160
- ocx. register_obligation ( obligation) ;
161
-
162
- let errors = ocx. select_all_or_error ( ) ;
163
- match errors. as_slice ( ) {
164
- // Only known to hold if we did no inference.
165
- [ ] => infcx. shallow_resolve ( goal) == goal,
166
-
167
- errors => {
168
- debug ! ( ?errors) ;
169
- false
170
- }
171
- }
172
- } )
173
- } else {
174
- false
175
- }
130
+ let obligation = Obligation :: new ( infcx. tcx , ObligationCause :: dummy ( ) , param_env, trait_ref) ;
131
+ infcx. predicate_must_hold_modulo_regions ( & obligation)
176
132
}
177
133
178
134
#[ instrument( level = "debug" , skip( tcx, elaborated_env) ) ]
0 commit comments