-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[Experimental] <T as Into<T>>::into
lint
#129249
base: master
Are you sure you want to change the base?
Conversation
r? @chenyukang rustbot has assigned @chenyukang. Use |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@bors try @craterbot check |
@bors try |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
fn check_item_post(&mut self, cx: &LateContext<'tcx>, item: &hir::Item<'_>) { | ||
let hir::ItemKind::Use(path, kind) = item.kind else { return }; | ||
tracing::info!("{:#?}", item); | ||
tracing::info!(?path, ?kind); | ||
for res in &path.res { | ||
let Res::Def(DefKind::TyAlias, def_id) = res else { continue }; | ||
let ty = cx.tcx.type_of(def_id).instantiate_identity(); | ||
let name = cx.tcx.item_name(*def_id); | ||
// println!("{ty:?} {name:?}"); | ||
self.ignored_types.push(ty); | ||
for stripped in cx.tcx.stripped_cfg_items(def_id.krate) { | ||
if stripped.name.name == name { | ||
tracing::info!("{name:#?}"); | ||
} | ||
} | ||
} | ||
} |
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.
This is not the right way to do this check, but it was the fastest way of getting a semi-accurate discard of types that have type
aliases in scope to somewhat handle platform cfg
cases.
@bors try |
[Experimental] `<T as Into<T>>::into` lint Running crater to see how common that pattern is. The Lint would have to be at most warn-by-default because there are a handful of cases detected that are actually perfectly reasonable (`type` aliases with per-platform `cfg`, or macros) which are now at best half-heartedly handled. I've detected a handful of cases where we're calling `.into()` unnecessarily in the `rustc` codebase as well, and changed those.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
🤔 looks like you are reimplementing a subset of https://rust-lang.github.io/rust-clippy/master/index.html#/useless_conversion ? edit: spoiler
|
looks a bit like a mix of |
This comment has been minimized.
This comment has been minimized.
@matthiaskrgr I'm trying to gauge how common the root cause of the recent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors try |
[Experimental] `<T as Into<T>>::into` lint Running crater to see how common that pattern is. The Lint would have to be at most warn-by-default because there are a handful of cases detected that are actually perfectly reasonable (`type` aliases with per-platform `cfg`, or macros) which are now at best half-heartedly handled. I've detected a handful of cases where we're calling `.into()` unnecessarily in the `rustc` codebase as well, and changed those.
(I think that I have enough building that I can run crater on the resulting binary) |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -733,6 +733,8 @@ lint_reserved_prefix = prefix `{$prefix}` is unknown | |||
.label = unknown prefix | |||
.suggestion = insert whitespace here to avoid this being parsed as a prefix in Rust 2021 | |||
|
|||
lint_self_type_conversion = this conversion is useless `{$source}` to `{$target}` |
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.
Incorrect sentence structure...
lint_self_type_conversion = this conversion is useless `{$source}` to `{$target}` | |
lint_self_type_conversion = useless conversion to the same type: `{$target}` |
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.
The lint itself will need to be iterated on. This is all a placeholder so that I can run crater :)
This comment has been minimized.
This comment has been minimized.
Running crater to see how common that pattern is. The Lint would have to be at most warn-by-default because there are a handful of cases detected that are actually perfectly reasonable (`type` aliases with per-platform `cfg`, or macros) which are now at best half-heartedly handled. I've detected a handful of cases where we're calling `.into()` unnecessarily in the `rustc` codebase as well, and changed those.
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #129665) made this pull request unmergeable. Please resolve the merge conflicts. |
Running crater to see how common that pattern is. The Lint would have to be at most warn-by-default because there are a handful of cases detected that are actually perfectly reasonable (
type
aliases with per-platformcfg
, or macros) which are now at best half-heartedly handled.I've detected a handful of cases where we're calling
.into()
unnecessarily in therustc
codebase as well, and changed those.CC #127343.