Skip to content
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

Lint that warns when an elided lifetime ends up being a named lifetime (elided_named_lifetimes) #129207

Merged
merged 3 commits into from
Sep 1, 2024

Conversation

GrigorenkoPV
Copy link
Contributor

@GrigorenkoPV GrigorenkoPV commented Aug 17, 2024

As suggested in #48686 (comment)

Fixes #48686

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Aug 17, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Aug 18, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Aug 22, 2024
@rust-log-analyzer

This comment has been minimized.

@GrigorenkoPV GrigorenkoPV marked this pull request as ready for review August 23, 2024 19:57
@rustbot
Copy link
Collaborator

rustbot commented Aug 23, 2024

rustc_errors::translation was changed

cc @davidtwco, @compiler-errors, @TaKO8Ki

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

The Miri subtree was changed

cc @rust-lang/miri

@GrigorenkoPV
Copy link
Contributor Author

rustc_errors::translation was changed

  • replaced some elided lifetimes with explicit ones

Some changes occurred in src/tools/clippy

  • replaced some elided lifetimes with explicit ones
  • blessed some tests, because there is a new lint

The Miri subtree was changed

  • replaced some elided lifetimes with explicit ones

@GrigorenkoPV GrigorenkoPV requested a review from cjgillot August 23, 2024 21:40
@cjgillot
Copy link
Contributor

Could you submit d214d0b as a standalone PR? Is can be merged while we review this PR.

@cjgillot
Copy link
Contributor

Thanks!

As for the matter with crate_node_id, it will prevent users from controlling lint behaviour using allow/deny attributes. The missing node-ids are those which correspond to a ElidedAnchor resolution.

2 alternative ideas:

  • channel the correct NodeId for the lint to use;
  • emit the lints when seeing the ElidedAnchor in record_lifetime_res.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 24, 2024
…times, r=cjgillot

Fix `elided_named_lifetimes` in code

rust-lang#129207 (comment)

r? cjgillot
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 24, 2024
…times, r=cjgillot

Fix `elided_named_lifetimes` in code

rust-lang#129207 (comment)

r? cjgillot
@GrigorenkoPV
Copy link
Contributor Author

As for the matter with crate_node_id, it will prevent users from controlling lint behaviour using allow/deny attributes. The missing node-ids are those which correspond to a ElidedAnchor resolution.

Ah, I was worried that it might cause some sort of a problem, and indeed it does. Oh well. I seem to have fixed it and I also added a test for this.

@GrigorenkoPV
Copy link
Contributor Author

GrigorenkoPV commented Aug 24, 2024

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 24, 2024
@cuviper cuviper modified the milestones: 1.82.0, 1.83.0 Sep 5, 2024
irbull added a commit to irbull/deno_core that referenced this pull request Sep 5, 2024
Due to a change in Rust nightly, the Rust linter now warns when an
elided lifetime ends up being a named lifetime [1]. In this case, the
elided lifetime is `'static`, so we should explicitly set the named
lifetime to `'static`.

[1] rust-lang/rust#129207
@irbull
Copy link

irbull commented Sep 6, 2024

Part of the Deno project is built with Rust +nightly and is being hit by this change-set with the following error:

error: elided lifetime has a name
  --> core/runtime/snapshot.rs:32:19
   |
32 | ) -> (V8Snapshot, SerializableSnapshotSidecarData) {
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this elided lifetime gets resolved as `'static`

The fix is easy [1], but I thought I would leave this here in case others are being hit by it and hopefully google can index "elided lifetime has a name".

[1] denoland/deno_core#895

marvinhagemeister pushed a commit to denoland/deno_core that referenced this pull request Sep 6, 2024
Due to a change in Rust nightly, the Rust linter now warns when an
elided lifetime ends up being a named lifetime [1]. In this case, the
elided lifetime is `'static`, so we should explicitly set the lifetime
to `'static`.

[1] rust-lang/rust#129207
@GrigorenkoPV
Copy link
Contributor Author

The fix is easy

There is an upcoming PR implementing suggestions for this lint #129840. Currently it is in a conflict with some of clippy's suggestions, but maybe I can mark it non-machine-applicable for now, so that there are at least human-readable suggestions preventing confusion.

Thank you for your report!

compiler-errors added a commit to compiler-errors/rust that referenced this pull request Sep 7, 2024
…s-suggestion, r=cjgillot

Implement suggestions for `elided_named_lifetimes`

A follow-up to rust-lang#129207, as per rust-lang#129207 (comment).

r? cjgillot

I will probably squash this a bit, but later.

`@rustbot` label +A-lint
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 7, 2024
Rollup merge of rust-lang#129840 - GrigorenkoPV:elided-named-lifetimes-suggestion, r=cjgillot

Implement suggestions for `elided_named_lifetimes`

A follow-up to rust-lang#129207, as per rust-lang#129207 (comment).

r? cjgillot

I will probably squash this a bit, but later.

`@rustbot` label +A-lint
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 10, 2024
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Sep 12, 2024
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Sep 12, 2024
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Sep 16, 2024
…milio

This warning was introduced by rust-lang/rust#129207.

Differential Revision: https://phabricator.services.mozilla.com/D221462

UltraBlame original commit: 22a83ceba50b60d9407cbd3afc0a620b6c5d9eed
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Sep 16, 2024
…milio

This warning was introduced by rust-lang/rust#129207.

Differential Revision: https://phabricator.services.mozilla.com/D221462

UltraBlame original commit: 22a83ceba50b60d9407cbd3afc0a620b6c5d9eed
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Sep 16, 2024
…milio

This warning was introduced by rust-lang/rust#129207.

Differential Revision: https://phabricator.services.mozilla.com/D221462

UltraBlame original commit: 22a83ceba50b60d9407cbd3afc0a620b6c5d9eed
osiewicz added a commit to zed-industries/zed that referenced this pull request Sep 25, 2024
I compile Zed from nightly build pretty often and I've noticed that we're getting a few hits on new rustc lint:
rust-lang/rust#129207
osiewicz added a commit to zed-industries/zed that referenced this pull request Sep 25, 2024
I compile Zed from nightly build pretty often and I've noticed that
we're getting a few hits on new rustc lint:
rust-lang/rust#129207

Release Notes:

- N/A
kuruk-mm pushed a commit to dclexplorer/deno_core that referenced this pull request Oct 11, 2024
Due to a change in Rust nightly, the Rust linter now warns when an
elided lifetime ends up being a named lifetime [1]. In this case, the
elided lifetime is `'static`, so we should explicitly set the lifetime
to `'static`.

[1] rust-lang/rust#129207
noaccOS pushed a commit to noaccOS/zed that referenced this pull request Oct 19, 2024
I compile Zed from nightly build pretty often and I've noticed that
we're getting a few hits on new rustc lint:
rust-lang/rust#129207

Release Notes:

- N/A
ksolana added a commit to ksolana/agave that referenced this pull request Nov 3, 2024
ksolana added a commit to ksolana/agave that referenced this pull request Nov 4, 2024
ksolana added a commit to ksolana/agave that referenced this pull request Nov 5, 2024
ksolana added a commit to anza-xyz/agave that referenced this pull request Nov 6, 2024
github-actions bot pushed a commit to declantsien/webrender-native that referenced this pull request Jan 26, 2025
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. A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elision in method can take 'static from self, perhaps surprising