about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorBen Reeves <benwolverine2019@gmail.com>2021-11-27 23:10:18 -0600
committerBen Reeves <benwolverine2019@gmail.com>2021-11-27 23:59:08 -0600
commit9155f672bf98c49ea7f31cc052488640eb3eb00e (patch)
tree8c35b1dd59a8778631f4b3bd3cce4b98db622327 /src/test
parent4919988fe1765e51232558647f2260fff3544658 (diff)
downloadrust-9155f672bf98c49ea7f31cc052488640eb3eb00e.tar.gz
rust-9155f672bf98c49ea7f31cc052488640eb3eb00e.zip
typeck: Ensure proper bound vars passed to `add_bounds`.
Fixes the ICE in #88586.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs11
-rw-r--r--src/test/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.stderr19
2 files changed, 30 insertions, 0 deletions
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
+