Skip to content

Ideas for improving mismatched_lifetime_syntaxes wording? #141752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jieyouxu opened this issue May 30, 2025 · 1 comment
Open

Ideas for improving mismatched_lifetime_syntaxes wording? #141752

jieyouxu opened this issue May 30, 2025 · 1 comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-discussion Category: Discussion or questions that doesn't represent real issues. L-mismatched_lifetime_syntaxes Lint: mismatched_lifetime_syntaxes T-lang Relevant to the language team

Comments

@jieyouxu
Copy link
Member

Yes... on the other hand, it's possible we were just used to the old one. The new main warning here does match the lang model that we adopted (though I'm not sure if the "flowing from..." is the best possible wording). That model derives from what @nikomatsakis had proposed in #120808 (comment) to boil most of this down to things being mismatched, and we ended up adopting the form specifically described in #120808 (comment).

Originally posted by @traviscross in #138677 (comment)

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2025
@jieyouxu jieyouxu added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team C-discussion Category: Discussion or questions that doesn't represent real issues. L-mismatched_lifetime_syntaxes Lint: mismatched_lifetime_syntaxes and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 30, 2025
@yarrow
Copy link

yarrow commented Jun 10, 2025

I wonder if the message below should refer to hidden_lifetimes_in_output_paths instead of mismatched_lifetime_syntaxes.

warning: lifetime flowing from input to output with different syntax can be confusing
  --> src/help.rs:66:16
   |
66 | fn parse(text: &str) -> Vec<HelpItem> {
   |                ^^^^         -------- the lifetime gets resolved as `'_`
   |                |
   |                this lifetime flows to the output
   |
   = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: one option is to remove the lifetime for references and use the anonymous lifetime for paths
   |
66 | fn parse(text: &str) -> Vec<HelpItem<'_>> {
   |                                     ++++

The message is a bit confusing because the lifetime syntaxes in &str and HelpItem seem to be identical (both empty), and also because there is no lifetime to remove from the &str reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-discussion Category: Discussion or questions that doesn't represent real issues. L-mismatched_lifetime_syntaxes Lint: mismatched_lifetime_syntaxes T-lang Relevant to the language team
Projects
None yet
Development

No branches or pull requests

3 participants