@@ -19,10 +19,13 @@ use clippy_utils::get_parent_expr;
19
19
use rustc_data_structures:: fx:: FxHashSet ;
20
20
use rustc_errors:: Applicability ;
21
21
use rustc_hir:: intravisit:: { walk_expr, Visitor } ;
22
- use rustc_hir:: { self as hir} ;
22
+ use rustc_hir:: { self as hir, GenericArg } ;
23
23
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
24
24
use rustc_infer:: infer:: TyCtxtInferExt ;
25
+ use rustc_infer:: traits:: { Obligation , ObligationCause } ;
25
26
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
27
+ use rustc_middle:: query:: Key ;
28
+ use rustc_middle:: ty:: { AliasTy , Binder , ProjectionPredicate } ;
26
29
use rustc_span:: { sym, Span } ;
27
30
use rustc_trait_selection:: traits:: ObligationCtxt ;
28
31
use variable_check:: {
@@ -179,22 +182,43 @@ fn get_methods<'tcx>(
179
182
180
183
let tcx = cx. tcx ;
181
184
let infcx = tcx. infer_ctxt ( ) . build ( ) ;
182
- let origin = TypeVariableOrigin {
183
- kind : TypeVariableOriginKind :: TypeInference ,
184
- span,
185
- } ;
186
- let ty_var = infcx. next_ty_var ( origin) ;
187
- if let Some ( param_env) =
188
- // FIXME: what is assoc_ty
189
- if let Some ( projection) =
190
- make_normalized_projection ( tcx, param_env, trait_def_id, sym:: Item , vec ! [ ] )
185
+
186
+ if let Some ( ty_def_id) = original_ty. ty_def_id ( )
187
+ && let param_env = tcx. param_env ( ty_def_id)
188
+ && let Some ( projection) =
189
+ make_normalized_projection ( tcx, param_env, trait_def_id, sym:: Item , vec ! [ ] )
191
190
{
191
+ let cause = ObligationCause :: dummy ( ) ;
192
+ let origin = TypeVariableOrigin {
193
+ kind : TypeVariableOriginKind :: TypeInference ,
194
+ span,
195
+ } ;
196
+ let projection_ty = infcx. next_ty_var ( origin) ;
197
+
198
+ let projection = ProjectionPredicate {
199
+ projection_ty : AliasTy :: new ( tcx, trait_def_id, vec ! [ ] ) ,
200
+ term : tcx. mk_ty_var ( tcx. next_ty_var_id ( ) ) , // Or the specific type you expect the projection to equal.
201
+ } ;
202
+
203
+ let norm_ty = infcx. next_ty_var ( TypeVariableOrigin {
204
+ kind : TypeVariableOriginKind :: TypeInference ,
205
+ span : cause. span ,
206
+ } ) ;
207
+
208
+ // Create a projection obligation
209
+ let obligation = Obligation :: new (
210
+ cause. clone ( ) ,
211
+ param_env,
212
+ projection. to_predicate ( tcx, norm_ty) ,
213
+ ) ;
214
+
192
215
let ocx = ObligationCtxt :: new ( & infcx) ;
193
216
194
217
// FIXME: what is obligation
195
218
ocx. register_obligation ( obligation) ;
196
219
let some_errors = ocx. select_where_possible ( ) ;
197
220
}
221
+ // FIXME: what is assoc_ty
198
222
199
223
res
200
224
}
0 commit comments