From 9155f672bf98c49ea7f31cc052488640eb3eb00e Mon Sep 17 00:00:00 2001 From: Ben Reeves Date: Sat, 27 Nov 2021 23:10:18 -0600 Subject: typeck: Ensure proper bound vars passed to `add_bounds`. Fixes the ICE in #88586. --- .../issue-88586-hr-self-outlives-in-trait-def.rs | 11 +++++++++++ .../issue-88586-hr-self-outlives-in-trait-def.stderr | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs create mode 100644 src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.stderr (limited to 'src') diff --git a/src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs b/src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs new file mode 100644 index 00000000000..3f5202827ad --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs @@ -0,0 +1,11 @@ +// Regression test for #88586: a higher-ranked outlives bound on Self in a trait +// definition caused an ICE when debug_assertions were enabled. +// +// The error output is incidentally unhelpful; this should be improved. + +trait A where for<'a> Self: 'a +//~^ ERROR the parameter type `Self` may not live long enough +{ +} + +fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.stderr b/src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.stderr new file mode 100644 index 00000000000..18618ffcc86 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.stderr @@ -0,0 +1,19 @@ +error[E0311]: the parameter type `Self` may not live long enough + --> $DIR/issue-88586-hr-self-outlives-in-trait-def.rs:6:1 + | +LL | / trait A where for<'a> Self: 'a +LL | | +LL | | { +LL | | } + | |_^ + | + = help: consider adding an explicit lifetime bound `Self: 'a`... + = note: ...so that the type `Self` will meet its required lifetime bounds... +note: ...that is required by this bound + --> $DIR/issue-88586-hr-self-outlives-in-trait-def.rs:6:29 + | +LL | trait A where for<'a> Self: 'a + | ^^ + +error: aborting due to previous error + -- cgit 1.4.1-3-g733a5