rust/tests
bors 2f80ead27c 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
..
test_utils Move/rename lazy::Sync{OnceCell,Lazy} to sync::{Once,Lazy}Lock 2022-06-16 19:54:42 +04:00
ui Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu 2025-06-05 19:49:30 +00:00
ui-cargo Merge commit '9f9a822509' into clippy-subtree-update 2025-02-28 23:27:09 +01:00
ui-internal Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
ui-toml Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
workspace_test Merge commit 'cb806113e0' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
check-fmt.rs Merge commit 'cb806113e0' into clippy-subtree-update 2024-08-08 19:13:50 +02:00
clippy.toml Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
compile-test.rs Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
config-metadata.rs Merge commit 'a109190d70' into clippy-subtree-update 2024-10-18 13:44:06 +02:00
dogfood.rs Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
integration.rs Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
lint_message_convention.rs Merge commit '1e5237f4a5' into clippy-subtree-update 2025-03-20 22:34:29 +01:00
missing-test-files.rs Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
versioncheck.rs Clippy: skip check_host_compiler check in rustc testsuite 2025-02-28 23:27:22 +01:00
workspace.rs Stabilize LazyCell and LazyLock (lazy_cell) 2024-02-20 20:55:13 -07:00