Skip to content

Commit

Permalink
Check all substitution parameters for inference variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Nov 14, 2018
1 parent 1939722 commit 69e82c1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/librustc/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
}
&Ok(None) => {}
&Err(SelectionError::Unimplemented) => {
if self.is_of_param(pred.skip_binder().self_ty()) {
if self.is_param_no_infer(pred.skip_binder().trait_ref.substs) {
already_visited.remove(&pred);
self.add_user_pred(
&mut user_computed_preds,
Expand Down Expand Up @@ -597,6 +597,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
finished_map
}

fn is_param_no_infer(&self, substs: &Substs<'_>) -> bool {
return self.is_of_param(substs.type_at(0)) &&
!substs.types().any(|t| t.has_infer_types());
}

pub fn is_of_param(&self, ty: Ty<'_>) -> bool {
return match ty.sty {
ty::Param(_) => true,
Expand Down Expand Up @@ -646,7 +651,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
// from the various possible predicates
match &predicate {
&ty::Predicate::Trait(ref p) => {
if self.is_of_param(p.skip_binder().self_ty())
if self.is_param_no_infer(p.skip_binder().trait_ref.substs)
&& !only_projections
&& is_new_pred {

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

0 comments on commit 69e82c1

Please sign in to comment.