about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-11-13 22:35:04 +0100
committerGitHub <noreply@github.com>2021-11-13 22:35:04 +0100
commite273fab434f6accf42b3bbcd37e900db26b36cba (patch)
tree5a85163953da3a5d45a4aef84151830b15a37993 /src/test
parentb35af0d04ddbfbbb5b616f1dac1bdad5a6e00cd6 (diff)
parent875024ca6b1ae63f2dbcf95f5a6208bcc36fe49d (diff)
downloadrust-e273fab434f6accf42b3bbcd37e900db26b36cba.tar.gz
rust-e273fab434f6accf42b3bbcd37e900db26b36cba.zip
Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
relate lifetime in `TypeOutlives` bounds on drop impls

Fixes #90838
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs13
-rw-r--r--src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr17
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs
new file mode 100644
index 00000000000..42530d31730
--- /dev/null
+++ b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs
@@ -0,0 +1,13 @@
+struct Wrapper<'a, T>(&'a T)
+where
+    T: 'a;
+
+impl<'a, T> Drop for Wrapper<'a, T>
+where
+    T: 'static,
+    //~^ error: `Drop` impl requires `T: 'static` but the struct it is implemented for does not
+{
+    fn drop(&mut self) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr
new file mode 100644
index 00000000000..5176684e153
--- /dev/null
+++ b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr
@@ -0,0 +1,17 @@
+error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not
+  --> $DIR/relate_lt_in_type_outlives_bound.rs:7:8
+   |
+LL |     T: 'static,
+   |        ^^^^^^^
+   |
+note: the implementor must specify the same requirement
+  --> $DIR/relate_lt_in_type_outlives_bound.rs:1:1
+   |
+LL | / struct Wrapper<'a, T>(&'a T)
+LL | | where
+LL | |     T: 'a;
+   | |__________^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0367`.