rust/tests/ui/rfcs
bors ccf3198de3 Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu
Add a new `mismatched-lifetime-syntaxes` lint

The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is:

- Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples:

    ```rust
    // Lint will warn about these
    fn(v: ContainsLifetime) -> ContainsLifetime<'_>;
    fn(&'static u8) -> &u8;
    ```

- Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule:

    ```rust
    // Lint will not warn about these
    fn(&u8) -> &'_ u8;
    fn(&'_ u8) -> &u8;
    fn(&u8) -> ContainsLifetime<'_>;
    ```

- Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler.

---

This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-05 19:49:30 +00:00
..
impl-trait
rfc-0000-never_patterns Error message for top-level or-patterns suggesting a solution 2025-05-09 22:16:34 +09:00
rfc-0107-bind-by-move-pattern-guards
rfc-1014-stdout-existential-crisis
rfc-1445-restrict-constants-in-patterns
rfc-1623-static
rfc-1717-dllimport
rfc-1789-as-cell
rfc-1857-stabilize-drop-order
rfc-1937-termination-trait Remove global next_disambiguator state and handle it with a DisambiguatorState type 2025-04-29 13:22:38 +02:00
rfc-2005-default-binding-mode
rfc-2008-non-exhaustive compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
rfc-2091-track-caller Add Location::file_with_nul 2025-06-04 09:23:05 -07:00
rfc-2093-infer-outlives
rfc-2126-crate-paths
rfc-2126-extern-absolute-paths
rfc-2151-raw-identifiers
rfc-2175-or-if-while-let
rfc-2294-if-let-guard Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
rfc-2302-self-struct-ctor
rfc-2306-convert-id
rfc-2361-dbg-macro
rfc-2396-target_feature-11
rfc-2421-unreserve-pure-offsetof-sizeof-alignof
rfc-2457-non-ascii-idents Move more tests/ui tests 2025-05-12 16:35:09 +02:00
rfc-2497-if-let-chains Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
rfc-2528-type-changing-struct-update
rfc-2565-param-attrs
rfc-3348-c-string-literals
rfc-3467-unsafe-pinned Initial UnsafePinned/UnsafeUnpin impl [Part 1: Libs] 2025-04-13 01:11:04 -04:00
type-alias-impl-trait
rfc-3391-result-ffi-guarantees.rs