Static ELIDED_NAMED_LIFETIMES
pub static ELIDED_NAMED_LIFETIMES: &'static Lint
Expand description
The elided_named_lifetimes
lint detects when an elided
lifetime ends up being a named lifetime, such as 'static
or some lifetime parameter 'a
.
§Example
ⓘ
#![deny(elided_named_lifetimes)]
struct Foo;
impl Foo {
pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 {
unsafe { &mut *(x as *mut _) }
}
}
{{produces}}
§Explanation
Lifetime elision is quite useful, because it frees you from having
to give each lifetime its own name, but sometimes it can produce
somewhat surprising resolutions. In safe code, it is mostly okay,
because the borrow checker prevents any unsoundness, so the worst
case scenario is you get a confusing error message in some other place.
But with unsafe
code, such unexpected resolutions may lead to unsound code.