Skip to content

Fix regression in defaults #49344 #49704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,18 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
_ => t.super_visit_with(self)
}
}

fn visit_region(&mut self, _: ty::Region<'tcx>) -> bool {
true
}
}
let mut param_count = CountParams { params: FxHashSet() };
pred.visit_with(&mut param_count);
let has_region = pred.visit_with(&mut param_count);
let substituted_pred = pred.subst(fcx.tcx, substs);
// Don't check non-defaulted params, dependent defaults or preds with multiple params.
if substituted_pred.references_error() || param_count.params.len() > 1 {
// Don't check non-defaulted params, dependent defaults (including lifetimes)
// or preds with multiple params.
if substituted_pred.references_error() || param_count.params.len() > 1
|| has_region {
continue;
}
// Avoid duplication of predicates that contain no parameters, for example.
Expand Down
4 changes: 4 additions & 0 deletions src/test/run-pass/defaults-well-formedness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ trait SelfBound<T: Copy=Self> {}
// Not even for well-formedness.
struct WellFormedProjection<A, T=<A as Iterator>::Item>(A, T);

// Issue #49344, predicates with lifetimes should not be checked.
trait Scope<'a> {}
struct Request<'a, S: Scope<'a> = i32>(S, &'a ());

fn main() {}