Eluding "hidden lifetime parameters" warning

In a library, we have code like this one:

fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {

I think we compile the same way, with rustc 1.38, at the library level, with cargo test (we thus have the same Cargo.toml).
Some developers, when running cargo test see the "hidden lifetime parameters in types are deprecated" warning.

Some others don't see it.

The warning is clear and I'm now used to fix it. What I don't understand is why some developers don't see it. What can explain this difference ?

::std::fmt::Formatter has a lifetime parameter, so what it's saying is that you should change it to this:

fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error>

Note that we have explicit elision of a lifetime ('_), which is different to no lifetime at all, implicit elision of a lifetime.

The warning is clear, and I already fixed many LOCs for this problem.

What I don't understand is why some developers don't see the warning.

Might it be some .cargo/config files ?

Note OP's question:

What would cause some developers to see the warning, others not, for the same piece of code?

2 Likes

Are they all running the latest rustc, and using the same channel? For example, rustc 1.38 msvc-windows-pc

OK, found it, thanks to @shepmaster:

I had set an env flag:

RUSTFLAGS= -W rust_2018_idioms
4 Likes