Skip to content

Commit aebe8a7

Browse files
committed
Add regression test
1 parent 8768db9 commit aebe8a7

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
struct Foo<'c, 'd>(&'c (), &'d ());
2+
3+
impl<'c, 'd> Foo<'c, 'd> {
4+
fn acc(&mut self, _bar: &Bar) -> &'d () {
5+
todo!()
6+
}
7+
}
8+
9+
struct Bar;
10+
11+
impl<'a> Bar {
12+
fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
13+
//~^ ERROR: struct takes 2 lifetime arguments but 3 lifetime arguments were supplied
14+
self.bar().map_err(|()| foo.acc(self))?;
15+
//~^ ERROR: explicit lifetime required in the type of `foo`
16+
Ok(())
17+
}
18+
fn bar(&self) -> Result<(), &'a ()> {
19+
todo!()
20+
}
21+
}
22+
23+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0107]: struct takes 2 lifetime arguments but 3 lifetime arguments were supplied
2+
--> $DIR/noisy-follow-up-erro.rs:12:30
3+
|
4+
LL | fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
5+
| ^^^ -- help: remove this lifetime argument
6+
| |
7+
| expected 2 lifetime arguments
8+
|
9+
note: struct defined here, with 2 lifetime parameters: `'c`, `'d`
10+
--> $DIR/noisy-follow-up-erro.rs:1:8
11+
|
12+
LL | struct Foo<'c, 'd>(&'c (), &'d ());
13+
| ^^^ -- --
14+
15+
error[E0621]: explicit lifetime required in the type of `foo`
16+
--> $DIR/noisy-follow-up-erro.rs:14:9
17+
|
18+
LL | fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
19+
| -------------------- help: add explicit lifetime `'a` to the type of `foo`: `&mut Foo<'_, 'a>`
20+
LL |
21+
LL | self.bar().map_err(|()| foo.acc(self))?;
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
23+
24+
error: aborting due to 2 previous errors
25+
26+
Some errors have detailed explanations: E0107, E0621.
27+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)