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

rustc_lint: address latent TODO #118017

Merged
merged 2 commits into from
Nov 25, 2023
Merged

rustc_lint: address latent TODO #118017

merged 2 commits into from
Nov 25, 2023

Conversation

tamird
Copy link
Contributor

@tamird tamird commented Nov 17, 2023

See individual commits.

@rustbot
Copy link
Collaborator

rustbot commented Nov 17, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@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. labels Nov 17, 2023
@@ -39,6 +39,7 @@
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(rustc_attrs)]
#![feature(trait_upcasting)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the feature stable enough to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it's headed for stabilization. See #65991 (comment) and #65991 (comment). FCP ended yesterday.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and also, trait_upcasting is used elsewhere in the compiler if I recall correctly

let store: &Lrc<_> = self.lint_store.as_ref().unwrap();
let store: &dyn Any = &**store;
store.downcast_ref().unwrap()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep unerased_lint_store, and prefer a comment on Session::lint_store?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how to answer this question. Can you suggest why that's preferable? I've explained this change in the commit message - did you read it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment is usually the simplest way to make something more discoverable. Accessing the unerased lint store is exceptional, so I'm not sure this warrants a new trait & impl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it exceptional? The lint store is never accessed without unerasing because nothing can be done with the erased type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a mild preference for the original function:

  • A trait seems like overkill, when there is a single method implemented for a single type. The trait suggests generality, i.e. there might be other types that implement the trait.
  • The "because Session::lint_store is type-erased" comment is useful, and should be preserved even if the trait is kept.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the last commit.

@bors
Copy link
Contributor

bors commented Nov 22, 2023

☔ The latest upstream changes (presumably #118143) made this pull request unmergeable. Please resolve the merge conflicts.

@tamird
Copy link
Contributor Author

tamird commented Nov 22, 2023

r? @nnethercote

@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 25, 2023

📌 Commit 55393b6 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 25, 2023
rustc_lint: address latent TODO

See individual commits.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 25, 2023
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#116446 (Yeet `mir::Const::from_anon_const`)
 - rust-lang#117871 (remove unused pub fns)
 - rust-lang#118017 (rustc_lint: address latent TODO)
 - rust-lang#118199 (Remove `HirId` from `QPath::LangItem`)
 - rust-lang#118272 (resolve: Avoid clones of `MacroData`)
 - rust-lang#118291 (rustdoc-search: clean up some DOM code)

Failed merges:

 - rust-lang#118201 (Miscellaneous `ObligationCauseCode` cleanups)
 - rust-lang#118256 (rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5d2b6b3 into rust-lang:master Nov 25, 2023
@rustbot rustbot added this to the 1.76.0 milestone Nov 25, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 25, 2023
Rollup merge of rust-lang#118017 - tamird:better-safety, r=cjgillot

rustc_lint: address latent TODO

See individual commits.
@tamird tamird deleted the better-safety branch November 25, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants