This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
compiler/rustc_lint_defs/src Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1864,10 +1864,35 @@ declare_lint! {
18641864}
18651865
18661866declare_lint ! {
1867- /// TODO
1867+ /// The `elided_named_lifetimes` lint detects when an elided
1868+ /// lifetime ends up being a named lifetime, such as `'static`
1869+ /// or some lifetime parameter `'a`.
1870+ ///
1871+ /// ### Example
1872+ ///
1873+ /// ```rust,compile_fail
1874+ /// #![deny(elided_named_lifetimes)]
1875+ /// struct Foo;
1876+ /// impl Foo {
1877+ /// pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 {
1878+ /// unsafe { &mut *(x as *mut _) }
1879+ /// }
1880+ /// }
1881+ /// ```
1882+ ///
1883+ /// {{produces}}
1884+ ///
1885+ /// ### Explanation
1886+ ///
1887+ /// Lifetime elision is quite useful, because it frees you from having
1888+ /// to give each lifetime its own name, but sometimes it can produce
1889+ /// somewhat surprising resolutions. In safe code, it is mostly okay,
1890+ /// because the borrow checker prevents any unsoundness, so the worst
1891+ /// case scenario is you get a confusing error message in some other place.
1892+ /// But with `unsafe` code, such unexpected resolutions may lead to unsound code.
18681893 pub ELIDED_NAMED_LIFETIMES ,
18691894 Warn ,
1870- "TODO "
1895+ "detects when an elided lifetime gets resolved to be `'static` or some named parameter "
18711896}
18721897
18731898declare_lint ! {
You can’t perform that action at this time.
0 commit comments