Add regression test

This commit is contained in:
Oli Scherer 2024-05-27 08:22:32 +00:00
parent 8768db9912
commit aebe8a7ed3
2 changed files with 50 additions and 0 deletions

View File

@ -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() {}

View File

@ -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`.