about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-05-27 08:22:32 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-03 13:03:52 +0000
commitaebe8a7ed3f6b915170df8e9056f2bdbaac4de00 (patch)
treef8c1011815cd9875757ac1a3c73d291a3d9d59df
parent8768db9912af2dc70651156bb638b09dc2cec630 (diff)
downloadrust-aebe8a7ed3f6b915170df8e9056f2bdbaac4de00.tar.gz
rust-aebe8a7ed3f6b915170df8e9056f2bdbaac4de00.zip
Add regression test
-rw-r--r--tests/ui/lifetimes/noisy-follow-up-erro.rs23
-rw-r--r--tests/ui/lifetimes/noisy-follow-up-erro.stderr27
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/ui/lifetimes/noisy-follow-up-erro.rs b/tests/ui/lifetimes/noisy-follow-up-erro.rs
new file mode 100644
index 00000000000..47a87068d8f
--- /dev/null
+++ b/tests/ui/lifetimes/noisy-follow-up-erro.rs
@@ -0,0 +1,23 @@
+struct Foo<'c, 'd>(&'c (), &'d ());
+
+impl<'c, 'd> Foo<'c, 'd> {
+    fn acc(&mut self, _bar: &Bar) -> &'d () {
+        todo!()
+    }
+}
+
+struct Bar;
+
+impl<'a> Bar {
+    fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
+        //~^ ERROR: struct takes 2 lifetime arguments but 3 lifetime arguments were supplied
+        self.bar().map_err(|()| foo.acc(self))?;
+        //~^ ERROR: explicit lifetime required in the type of `foo`
+        Ok(())
+    }
+    fn bar(&self) -> Result<(), &'a ()> {
+        todo!()
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/lifetimes/noisy-follow-up-erro.stderr b/tests/ui/lifetimes/noisy-follow-up-erro.stderr
new file mode 100644
index 00000000000..f549009a87c
--- /dev/null
+++ b/tests/ui/lifetimes/noisy-follow-up-erro.stderr
@@ -0,0 +1,27 @@
+error[E0107]: struct takes 2 lifetime arguments but 3 lifetime arguments were supplied
+  --> $DIR/noisy-follow-up-erro.rs:12:30
+   |
+LL |     fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
+   |                              ^^^         -- help: remove this lifetime argument
+   |                              |
+   |                              expected 2 lifetime arguments
+   |
+note: struct defined here, with 2 lifetime parameters: `'c`, `'d`
+  --> $DIR/noisy-follow-up-erro.rs:1:8
+   |
+LL | struct Foo<'c, 'd>(&'c (), &'d ());
+   |        ^^^ --  --
+
+error[E0621]: explicit lifetime required in the type of `foo`
+  --> $DIR/noisy-follow-up-erro.rs:14:9
+   |
+LL |     fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
+   |                         -------------------- help: add explicit lifetime `'a` to the type of `foo`: `&mut Foo<'_, 'a>`
+LL |
+LL |         self.bar().map_err(|()| foo.acc(self))?;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0107, E0621.
+For more information about an error, try `rustc --explain E0107`.