@@ -71,43 +71,6 @@ pub struct OpaqueHiddenType<'tcx> {
71
71
}
72
72
73
73
impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
74
- /// Links the opaque type with the given hidden type
75
- /// and creates appropriate obligations. For example, given the input:
76
- ///
77
- /// opaque = impl Iterator<Item = impl Debug>
78
- /// hidden = std::vec::IntoIter<i32>
79
- ///
80
- /// this method would register the opaque type `impl Iterator` to have
81
- /// the hidden type `std::vec::IntoIter<i32>` and create the type variable
82
- /// `?1` but also the obligations:
83
- ///
84
- /// std::vec::IntoIter<i32>: Iterator<Item = ?1>
85
- /// ?1: Debug
86
- ///
87
- /// Moreover, it returns an `OpaqueTypeMap` that would map `?0` to
88
- /// info about the `impl Iterator<..>` type and `?1` to info about
89
- /// the `impl Debug` type.
90
- ///
91
- /// # Parameters
92
- ///
93
- /// - `parent_def_id` -- the `DefId` of the function in which the opaque type
94
- /// is defined
95
- /// - `body_id` -- the body-id with which the resulting obligations should
96
- /// be associated
97
- /// - `param_env` -- the in-scope parameter environment to be used for
98
- /// obligations
99
- /// - `value` -- the value within which we are instantiating opaque types
100
- /// - `value_span` -- the span where the value came from, used in error reporting
101
- pub fn instantiate_opaque_types (
102
- & self ,
103
- ty : Ty < ' tcx > ,
104
- opaque : Ty < ' tcx > ,
105
- cause : ObligationCause < ' tcx > ,
106
- param_env : ty:: ParamEnv < ' tcx > ,
107
- ) -> Option < InferResult < ' tcx , ( ) > > {
108
- Instantiator { infcx : self , cause, param_env } . fold_opaque_ty_new ( opaque, |_, _| ty)
109
- }
110
-
111
74
pub fn handle_opaque_type (
112
75
& self ,
113
76
a : Ty < ' tcx > ,
@@ -123,7 +86,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
123
86
if !matches ! ( a. kind( ) , ty:: Opaque ( ..) ) {
124
87
return None ;
125
88
}
126
- self . instantiate_opaque_types ( b, a, cause. clone ( ) , param_env)
89
+ Instantiator { infcx : self , cause : cause. clone ( ) , param_env }
90
+ . fold_opaque_ty_new ( a, |_, _| b)
127
91
} ;
128
92
if let Some ( res) = process ( a, b) {
129
93
res
@@ -298,36 +262,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
298
262
/// but this is not necessary, because the opaque type we
299
263
/// create will be allowed to reference `T`. So we only generate a
300
264
/// constraint that `'0: 'a`.
301
- ///
302
- /// # The `free_region_relations` parameter
303
- ///
304
- /// The `free_region_relations` argument is used to find the
305
- /// "minimum" of the regions supplied to a given opaque type.
306
- /// It must be a relation that can answer whether `'a <= 'b`,
307
- /// where `'a` and `'b` are regions that appear in the "substs"
308
- /// for the opaque type references (the `<'a>` in `Foo1<'a>`).
309
- ///
310
- /// Note that we do not impose the constraints based on the
311
- /// generic regions from the `Foo1` definition (e.g., `'x`). This
312
- /// is because the constraints we are imposing here is basically
313
- /// the concern of the one generating the constraining type C1,
314
- /// which is the current function. It also means that we can
315
- /// take "implied bounds" into account in some cases:
316
- ///
317
- /// ```text
318
- /// trait SomeTrait<'a, 'b> { }
319
- /// fn foo<'a, 'b>(_: &'a &'b u32) -> impl SomeTrait<'a, 'b> { .. }
320
- /// ```
321
- ///
322
- /// Here, the fact that `'b: 'a` is known only because of the
323
- /// implied bounds from the `&'a &'b u32` parameter, and is not
324
- /// "inherent" to the opaque type definition.
325
- ///
326
- /// # Parameters
327
- ///
328
- /// - `opaque_types` -- the map produced by `instantiate_opaque_types`
329
- /// - `free_region_relations` -- something that can be used to relate
330
- /// the free regions (`'a`) that appear in the impl trait.
331
265
#[ instrument( level = "debug" , skip( self ) ) ]
332
266
pub fn register_member_constraints (
333
267
& self ,
0 commit comments