rust/compiler/rustc_resolve/src
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
..
late Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
rustdoc source_span_for_markdown_range: fix utf8 violation 2025-05-31 14:51:16 -05:00
build_reduced_graph.rs Reorder ast::ItemKind::{Struct,Enum,Union} fields. 2025-05-28 15:48:45 +10:00
check_unused.rs Rollup merge of #141741 - nnethercote:overhaul-UsePath, r=petrochenkov 2025-06-03 07:03:43 +02:00
def_collector.rs Reorder ast::ItemKind::{Struct,Enum,Union} fields. 2025-05-28 15:48:45 +10:00
diagnostics.rs consider glob imports in cfg suggestion 2025-05-28 00:59:47 +08:00
effective_visibilities.rs Reorder ast::ItemKind::{Struct,Enum,Union} fields. 2025-05-28 15:48:45 +10:00
errors.rs resolve: Support imports of associated types and glob imports from traits 2025-05-02 15:59:38 +03:00
ident.rs Avoid an empty trait name in impl blocks. 2025-04-09 15:01:14 +10:00
imports.rs resolve: Support imports of associated types and glob imports from traits 2025-05-02 15:59:38 +03:00
late.rs Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu 2025-06-05 19:49:30 +00:00
lib.rs update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
macros.rs Remove rustc_attr_data_structures re-export from rustc_attr_parsing 2025-05-18 18:14:43 +02:00
rustdoc.rs source_span_for_markdown_range: fix utf8 violation 2025-05-31 14:51:16 -05:00