From c13d5f1aebe05839907e401f2fc975f1df03a79e Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 18 Feb 2023 04:09:51 +0000 Subject: [PATCH] Make sure test_type_match doesn't ICE with late-bound types --- .../src/infer/outlives/test_type_match.rs | 3 ++- .../type-match-with-late-bound.rs | 14 ++++++++++++++ .../type-match-with-late-bound.stderr | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs create mode 100644 tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 10b474efd5aeb..2f7c496161bca 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -186,7 +186,8 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> { #[instrument(skip(self), level = "debug")] fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - if let ty::Error(_) = pattern.kind() { + // FIXME(non_lifetime_binders): What to do here? + if matches!(pattern.kind(), ty::Error(_) | ty::Bound(..)) { // Unlike normal `TypeRelation` rules, `ty::Error` does not equal any type. self.no_match() } else if pattern == value { diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs new file mode 100644 index 0000000000000..5ff7089b993a8 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs @@ -0,0 +1,14 @@ +// edition:2021 +// check-pass + +// Checks that test_type_match code doesn't ICE when predicates have late-bound types + +#![feature(non_lifetime_binders)] +//~^ WARN is incomplete and may not be safe to use + +async fn walk2<'a, T: 'a>(_: T) +where + for F: 'a, +{} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr new file mode 100644 index 0000000000000..3609bed28dffb --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/type-match-with-late-bound.rs:6:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted +