Skip to content

Commit e1727e3

Browse files
committed
Auto merge of #49843 - leodasvacas:backport-fix-#49344, r=nikomatsakis
[beta] Backport fix for regression in defaults This proposes a backport of #49704, which fixes a regression that affects beta. r? @nikomatsakis
2 parents 8a75d2b + be673e8 commit e1727e3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/librustc_typeck/check/wfcheck.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,18 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
423423
_ => t.super_visit_with(self)
424424
}
425425
}
426+
427+
fn visit_region(&mut self, _: ty::Region<'tcx>) -> bool {
428+
true
429+
}
426430
}
427431
let mut param_count = CountParams { params: FxHashSet() };
428-
pred.visit_with(&mut param_count);
432+
let has_region = pred.visit_with(&mut param_count);
429433
let substituted_pred = pred.subst(fcx.tcx, substs);
430-
// Don't check non-defaulted params, dependent defaults or preds with multiple params.
431-
if substituted_pred.references_error() || param_count.params.len() > 1 {
434+
// Don't check non-defaulted params, dependent defaults (including lifetimes)
435+
// or preds with multiple params.
436+
if substituted_pred.references_error() || param_count.params.len() > 1
437+
|| has_region {
432438
continue;
433439
}
434440
// Avoid duplication of predicates that contain no parameters, for example.

src/test/run-pass/defaults-well-formedness.rs

+4
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ trait SelfBound<T: Copy=Self> {}
2727
// Not even for well-formedness.
2828
struct WellFormedProjection<A, T=<A as Iterator>::Item>(A, T);
2929

30+
// Issue #49344, predicates with lifetimes should not be checked.
31+
trait Scope<'a> {}
32+
struct Request<'a, S: Scope<'a> = i32>(S, &'a ());
33+
3034
fn main() {}

0 commit comments

Comments
 (0)