rust/tests/ui/higher-ranked
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
..
leak-check Report higher-ranked trait error when higher-ranked projection goal fails in new solver 2025-04-09 17:53:32 +00:00
subtype [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
trait-bounds Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
anonymous-higher-ranked-lifetime.rs Adjust anonymous-higher-ranked-lifetime.rs 2024-12-10 11:31:13 +08:00
anonymous-higher-ranked-lifetime.stderr Adjust anonymous-higher-ranked-lifetime.rs 2024-12-10 11:31:13 +08:00
builtin-closure-like-bounds.rs Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
closure-bound-codegen-ice.rs Fix obligation param and bless tests 2024-04-01 22:48:23 -04:00
erroneous-lifetime-bound.rs Move binder and polarity parsing into parse_generic_ty_bound 2024-06-28 19:40:31 -04:00
erroneous-lifetime-bound.stderr Move binder and polarity parsing into parse_generic_ty_bound 2024-06-28 19:40:31 -04:00
higher-lifetime-bounds.rs Simple modification of diagnostic information 2023-12-21 10:17:11 +08:00
higher-lifetime-bounds.stderr Simple modification of diagnostic information 2023-12-21 10:17:11 +08:00
higher-ranked-invalid-bounds.rs cleaned up some tests 2025-06-03 07:38:06 +05:00
higher-ranked-invalid-bounds.stderr cleaned up some tests 2025-06-03 07:38:06 +05:00
higher-ranked-lifetime-equality.rs Make nll higher ranked equate use bidirectional subtyping in invariant context 2024-02-29 15:27:59 -03:00
higher-ranked-lifetime-equality.stderr Make nll higher ranked equate use bidirectional subtyping in invariant context 2024-02-29 15:27:59 -03:00
higher-ranked-lifetime-error.rs eagerly instantiate binders to avoid relying on sub 2024-03-14 17:19:40 +01:00
higher-ranked-lifetime-error.stderr eagerly instantiate binders to avoid relying on sub 2024-03-14 17:19:40 +01:00
structually-relate-aliases.rs Assert that obligations are empty before deeply normalizing 2024-12-02 22:51:18 +00:00
structually-relate-aliases.stderr Use trait name instead of full constraint in suggestion message 2024-12-07 21:29:58 +00:00
subtyping-fn-ptr-coercion.rs Use the right type when coercing fn items to pointers 2024-08-13 16:23:20 -04:00
well-formed-aliases.rs Okay actually check only alias TYPES 2024-05-21 15:56:10 -04:00
well-formed-aliases.stderr Okay actually check only alias TYPES 2024-05-21 15:56:10 -04:00