Closed
Description
in the latest stable compiler(1.27) (and probably earlier ones too) this snippet won't compile:
#![deny(elided_lifetimes_in_paths)]
#[derive(Debug)]
struct Foo {
a: i32,
b: i32,
}
#[derive(Debug)]
struct Bar<'a> {
a: &'a Foo,
}
fn fun<'a>() {
let foo = Foo {a: 1, b: 2};
let bar = Bar::<'a> {a: &foo};
println!("{}", bar);
}
fn main() {
fun();
}
The issue is that the code is perfectly fine. The compilation errors come from the macros used:
error: hidden lifetime parameters are deprecated, try `Foo<'_>`
--> src/main.rs:18:5
|
18 | println!("{}", bar);
| ^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> src/main.rs:1:9
|
1 | #![deny(elided_lifetimes_in_paths)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: hidden lifetime parameters are deprecated, try `Foo<'_>`
--> src/main.rs:18:5
|
18 | println!("{}", bar);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: hidden lifetime parameters are deprecated, try `Foo<'_>`
--> src/main.rs:4:10
|
4 | #[derive(Debug)]
| ^^^^^
error: hidden lifetime parameters are deprecated, try `Foo<'_>`
--> src/main.rs:10:10
|
10 | #[derive(Debug)]
| ^^^^^
error: hidden lifetime parameters are deprecated, try `Foo<'_>`
error: aborting due to 5 previous errors
The user of these macros + lint can't do anything to fix the errors. It seems as though at least some macro definitions in the standard library aren't ready for this lint yet.
See also #51902.
Note, the lint is still useful (actually helped me figure out some issues i had), but can't be left on because of these bugs.