diff options
| author | leonardo.yvens <leoyvens@gmail.com> | 2018-04-05 15:21:56 -0300 |
|---|---|---|
| committer | leonardo.yvens <leoyvens@gmail.com> | 2018-04-05 15:21:56 -0300 |
| commit | 933f9ebaae36c15ac917142033ec5f80e066d119 (patch) | |
| tree | 6ba92106dab56e1af8d5d1dacc6d42a52aaa6b38 | |
| parent | 56714acc5eb0687ed9a7566fdebe5528657fc5b3 (diff) | |
| download | rust-933f9ebaae36c15ac917142033ec5f80e066d119.tar.gz rust-933f9ebaae36c15ac917142033ec5f80e066d119.zip | |
Fix #49344
| -rw-r--r-- | src/librustc_typeck/check/wfcheck.rs | 12 | ||||
| -rw-r--r-- | src/test/run-pass/defaults-well-formedness.rs | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 406ff9463a0..7dc73a1d5f0 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -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. diff --git a/src/test/run-pass/defaults-well-formedness.rs b/src/test/run-pass/defaults-well-formedness.rs index f3594679095..9b06bf837ae 100644 --- a/src/test/run-pass/defaults-well-formedness.rs +++ b/src/test/run-pass/defaults-well-formedness.rs @@ -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() {} |
