From 788261d2d30c92c7423a68088aaee32ce44f9520 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 29 Jul 2020 05:32:28 +0900 Subject: [PATCH 1/2] Add regression test for issue-59311 --- .../ui/higher-rank-trait-bounds/issue-59311.rs | 16 ++++++++++++++++ .../higher-rank-trait-bounds/issue-59311.stderr | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/higher-rank-trait-bounds/issue-59311.rs create mode 100644 src/test/ui/higher-rank-trait-bounds/issue-59311.stderr diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs new file mode 100644 index 0000000000000..c2168510cf5b8 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs @@ -0,0 +1,16 @@ +// Regression test for #59311. The test is taken from +// rust-lang/rust/issues/71546#issuecomment-620638437 +// as they seem to have the same cause. + +pub trait T { + fn t(&self, _: F) {} +} + +pub fn crash(v: &V) +where + for<'a> &'a V: T + 'static, +{ + v.t(|| {}); //~ ERROR: higher-ranked subtype error +} + +fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr b/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr new file mode 100644 index 0000000000000..e6488c337114b --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr @@ -0,0 +1,8 @@ +error: higher-ranked subtype error + --> $DIR/issue-59311.rs:13:9 + | +LL | v.t(|| {}); + | ^^^^^ + +error: aborting due to previous error + From cc36c3d140b82757c5ffe94c71232d2f32fcf2a4 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 6 Aug 2020 05:21:03 +0900 Subject: [PATCH 2/2] Add a FIXME comment --- src/test/ui/higher-rank-trait-bounds/issue-59311.rs | 4 ++++ src/test/ui/higher-rank-trait-bounds/issue-59311.stderr | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs index c2168510cf5b8..1e1241c7f83c5 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs @@ -2,6 +2,10 @@ // rust-lang/rust/issues/71546#issuecomment-620638437 // as they seem to have the same cause. +// FIXME: It's not clear that this code ought to report +// an error, but the regression test is here to ensure +// that it does not ICE. See discussion on #74889 for details. + pub trait T { fn t(&self, _: F) {} } diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr b/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr index e6488c337114b..ca6326292672b 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr @@ -1,5 +1,5 @@ error: higher-ranked subtype error - --> $DIR/issue-59311.rs:13:9 + --> $DIR/issue-59311.rs:17:9 | LL | v.t(|| {}); | ^^^^^