-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
rustc_lint: address latent TODO #118017
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
compiler/rustc_lint/src/lib.rs
Outdated
@@ -39,6 +39,7 @@ | |||
#![feature(min_specialization)] | |||
#![feature(never_type)] | |||
#![feature(rustc_attrs)] | |||
#![feature(trait_upcasting)] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
compiler/rustc_lint/src/late.rs
Outdated
let store: &Lrc<_> = self.lint_store.as_ref().unwrap(); | ||
let store: &dyn Any = &**store; | ||
store.downcast_ref().unwrap() | ||
} | ||
} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the last commit.
☔ The latest upstream changes (presumably #118143) made this pull request unmergeable. Please resolve the merge conflicts. |
4cb4d3b
to
4ded7ee
Compare
`Option::unwrap` is called on the next line.
4ded7ee
to
e5139e6
Compare
r? @nnethercote |
e5139e6
to
55393b6
Compare
@bors r+ |
rustc_lint: address latent TODO See individual commits.
…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
Rollup merge of rust-lang#118017 - tamird:better-safety, r=cjgillot rustc_lint: address latent TODO See individual commits.
See individual commits.