Skip to content

Commit 69e82c1

Browse files
committed
Check all substitution parameters for inference variables
1 parent 1939722 commit 69e82c1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustc/traits/auto_trait.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
359359
}
360360
&Ok(None) => {}
361361
&Err(SelectionError::Unimplemented) => {
362-
if self.is_of_param(pred.skip_binder().self_ty()) {
362+
if self.is_param_no_infer(pred.skip_binder().trait_ref.substs) {
363363
already_visited.remove(&pred);
364364
self.add_user_pred(
365365
&mut user_computed_preds,
@@ -597,6 +597,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
597597
finished_map
598598
}
599599

600+
fn is_param_no_infer(&self, substs: &Substs<'_>) -> bool {
601+
return self.is_of_param(substs.type_at(0)) &&
602+
!substs.types().any(|t| t.has_infer_types());
603+
}
604+
600605
pub fn is_of_param(&self, ty: Ty<'_>) -> bool {
601606
return match ty.sty {
602607
ty::Param(_) => true,
@@ -646,7 +651,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
646651
// from the various possible predicates
647652
match &predicate {
648653
&ty::Predicate::Trait(ref p) => {
649-
if self.is_of_param(p.skip_binder().self_ty())
654+
if self.is_param_no_infer(p.skip_binder().trait_ref.substs)
650655
&& !only_projections
651656
&& is_new_pred {
652657

@@ -663,7 +668,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
663668
// an inference variable.
664669
// Additionally, we check if we've seen this predicate before,
665670
// to avoid rendering duplicate bounds to the user.
666-
if self.is_of_param(p.skip_binder().projection_ty.self_ty())
671+
if self.is_param_no_infer(p.skip_binder().projection_ty.substs)
667672
&& !p.ty().skip_binder().is_ty_infer()
668673
&& is_new_pred {
669674
debug!("evaluate_nested_obligations: adding projection predicate\

0 commit comments

Comments
 (0)