@@ -172,14 +172,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
172172 let bound_predicate = predicate.kind();
173173 let mut err = match bound_predicate.skip_binder() {
174174 ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
175- let trait_ref = bound_predicate.rebind(data.trait_ref );
176- debug!(?trait_ref );
175+ let trait_pred = bound_predicate.rebind(data);
176+ debug!(?trait_pred );
177177
178178 if let Err(e) = predicate.error_reported() {
179179 return e;
180180 }
181181
182- if let Err(guar) = self.tcx.ensure().coherent_trait(trait_ref .def_id()) {
182+ if let Err(guar) = self.tcx.ensure().coherent_trait(trait_pred .def_id()) {
183183 // Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
184184 // other `Foo` impls are incoherent.
185185 return guar;
@@ -200,13 +200,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
200200 // avoid inundating the user with unnecessary errors, but we now
201201 // check upstream for type errors and don't add the obligations to
202202 // begin with in those cases.
203- if self.tcx.is_lang_item(trait_ref .def_id(), LangItem::Sized) {
203+ if self.tcx.is_lang_item(trait_pred .def_id(), LangItem::Sized) {
204204 match self.tainted_by_errors() {
205205 None => {
206206 let err = self.emit_inference_failure_err(
207207 obligation.cause.body_id,
208208 span,
209- trait_ref .self_ty().skip_binder().into(),
209+ trait_pred .self_ty().skip_binder().into(),
210210 TypeAnnotationNeeded::E0282,
211211 false,
212212 );
@@ -251,10 +251,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
251251
252252 let mut ambiguities = compute_applicable_impls_for_diagnostics(
253253 self.infcx,
254- &obligation.with(self.tcx, trait_ref ),
254+ &obligation.with(self.tcx, trait_pred ),
255255 );
256- let has_non_region_infer =
257- trait_ref.skip_binder().args.types().any(|t| !t.is_ty_or_numeric_infer());
256+ let has_non_region_infer = trait_pred
257+ .skip_binder()
258+ .trait_ref
259+ .args
260+ .types()
261+ .any(|t| !t.is_ty_or_numeric_infer());
258262 // It doesn't make sense to talk about applicable impls if there are more than a
259263 // handful of them. If there are a lot of them, but only a few of them have no type
260264 // params, we only show those, as they are more likely to be useful/intended.
@@ -294,7 +298,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
294298 if impl_candidates.len() < 40 {
295299 self.report_similar_impl_candidates(
296300 impl_candidates.as_slice(),
297- trait_ref ,
301+ trait_pred ,
298302 obligation.cause.body_id,
299303 &mut err,
300304 false,
@@ -306,7 +310,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
306310 if let ObligationCauseCode::WhereClause(def_id, _)
307311 | ObligationCauseCode::WhereClauseInExpr(def_id, ..) = *obligation.cause.code()
308312 {
309- self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref .def_id());
313+ self.suggest_fully_qualified_path(&mut err, def_id, span, trait_pred .def_id());
310314 }
311315
312316 if let Some(ty::GenericArgKind::Type(_)) = arg.map(|arg| arg.unpack())
0 commit comments