-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New lint: concealed_obvious_default
#15037
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @samueltardieu. Use |
concealed_obvious_default
lintconcealed_obvious_default
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.
Thanks, this is interesting. I've added some comments.
Also, could you split this into two commits: one with the lint applied (auto-fixed) to Clippy sources, then one with the lint itself. The order between both commits is not mandatory, but auto-fixing Clippy sources first allows the repository to pass the dogfood at every step, in case we need to bisect it.
Also, should the lint move to a allow-by-default category once we have discussed about it, removing the application commit would be easy.
14d8112
to
4f7953e
Compare
f2f906f
to
bb6c0d4
Compare
Thanks for the review. I've addressed your comments and added tests to check for macro expansion both on the receiver and the method |
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.
Thanks. I've started a FCP thread on Zulip to discuss about the lint inclusion in Clippy.
commit 1c0b99d Author: Nik Revenco <[email protected]> Date: Sun Jul 27 10:51:12 2025 +0100 refactor: Do not use `unwrap_or_default` on simple integer See rust-lang/rust-clippy#15037 commit 7a83e9e Author: Nik Revenco <[email protected]> Date: Sun Jul 27 10:43:39 2025 +0100 feat: horizontal scroll of the current document into account when drawing the blame Co-authored-by: Taylor Plewe <[email protected]> commit 5e21b7f Author: Nik Revenco <[email protected]> Date: Tue Jun 17 11:40:21 2025 +0100 fix: Cargo.lock commit 14d4163 Merge: a476d6d fed3edc Author: Nik Revenco <[email protected]> Date: Tue Jun 17 11:37:05 2025 +0100 Merge branch 'master' into gix-blame commit a476d6d Author: Nik Revenco <[email protected]> Date: Sat Jun 7 14:06:25 2025 +0100 Revert "feat: if you are the author, use "You" instead of name" This reverts commit 41cb919. I don't think it's worth to have this feature for the additional complexity of allowing users to opt-out, plus considering the fact that it might be inaccurate and cause confusion Similar discussion: zed-industries/zed#10557 commit 41cb919 Author: Nik Revenco <[email protected]> Date: Sat Jun 7 11:57:55 2025 +0100 feat: if you are the author, use "You" instead of name commit 100ad75 Author: Nik Revenco <[email protected]> Date: Sat Jun 7 11:35:46 2025 +0100 chore: clarify comment commit d00ff25 Merge: 08c6650 f4b488e Author: Nik Revenco <[email protected]> Date: Sat Jun 7 11:34:29 2025 +0100 Merge branch 'master' into gix-blame commit 08c6650 Author: Nik Revenco <[email protected]> Date: Mon May 19 13:54:00 2025 +0100 docs: Add line breaks to paragraph + improve wording commit e64b4fa Author: Nik Revenco <[email protected]> Date: Mon May 19 13:47:34 2025 +0100 docs: improve wording Co-authored-by: uncenter <[email protected]> commit 92dc3ca Author: Nik Revenco <[email protected]> Date: Mon May 19 13:44:00 2025 +0100 docs: improve wording Co-authored-by: uncenter <[email protected]> commit eb559cf Author: Nik Revenco <[email protected]> Date: Mon May 19 13:43:28 2025 +0100 docs: remove hard to understand sentence Co-authored-by: uncenter <[email protected]> commit dd1f31d Author: Nik Revenco <[email protected]> Date: Mon May 19 12:21:05 2025 +0100 docs: improve wording Co-authored-by: uncenter <[email protected]> commit 9d27551 Author: Nik Revenco <[email protected]> Date: Mon May 19 12:20:48 2025 +0100 docs: improve wording Co-authored-by: uncenter <[email protected]> commit 01e9dc1 Author: Nik Revenco <[email protected]> Date: Mon May 19 10:27:10 2025 +0100 test: use correct variable name commit 00117f8 Author: Nik Revenco <[email protected]> Date: Mon May 19 09:49:15 2025 +0100 fix: use correct variable name `title` instead of `message` commit 4eebdec Author: Nik Revenco <[email protected]> Date: Mon May 19 09:47:47 2025 +0100 test: use renamed `commit_message` commit a859cb2 Author: Nik Revenco <[email protected]> Date: Mon May 19 09:44:17 2025 +0100 docs: change sentence commit f1a29ee Author: Nik Revenco <[email protected]> Date: Mon May 19 09:41:01 2025 +0100 feat: rename the `message` variable to `title` commit 0123bac Author: Nik Revenco <[email protected]> Date: Mon May 19 09:31:18 2025 +0100 docs: remove confusing instructions These instructions are confusing and hard to interpret. The details won't matter for almost all people, so there's no need to provide this information commit 1ca7ee8 Author: Nik Revenco <[email protected]> Date: Mon May 19 09:27:54 2025 +0100 feat: rename config options Based off uncenter's review commit b8bd060 Author: Nik Revenco <[email protected]> Date: Mon May 19 09:11:34 2025 +0100 chore: fix merge conflicts commit deb5897 Merge: 7effac9 3ceae88 Author: Nik Revenco <[email protected]> Date: Mon May 19 09:11:20 2025 +0100 Merge branch 'master' into gix-blame commit 7effac9 Author: Nik Revenco <[email protected]> Date: Tue May 6 18:22:25 2025 +0100 fix: only render inline blame once per line at most Renders inline blame for the last visual line commit be5fbff Author: Nik Revenco <[email protected]> Date: Tue May 6 17:38:04 2025 +0100 chore: resolve merge conflicts commit b31f1c7 Merge: 03f0883 e53462c Author: Nik Revenco <[email protected]> Date: Tue May 6 17:10:02 2025 +0100 Merge branch 'master' into gix-blame commit 03f0883 Author: Nik Revenco <[email protected]> Date: Wed Apr 16 23:34:56 2025 +0100 chore: fix merge conflicts commit 5d83e93 Merge: 616758e 37b5d8b Author: Nik Revenco <[email protected]> Date: Wed Apr 16 23:09:49 2025 +0100 Merge branch 'master' into gix-blame commit 616758e Author: Nik Revenco <[email protected]> Date: Fri Apr 4 08:19:40 2025 +0100 refactor: rename macro _ commit c74fec4 Author: Nik Revenco <[email protected]> Date: Wed Apr 2 00:12:38 2025 +0100 fix?: do not block on the main thread when acquiring diff handle not sure if this will work as I can't reproduce this but let's see! commit e8d7e76 Author: Nik Revenco <[email protected]> Date: Tue Apr 1 12:17:48 2025 +0100 fix: spelling error Co-authored-by: Sebastian Klähn <[email protected]> commit 1a0dad3 Author: Nik Revenco <[email protected]> Date: Sun Mar 30 11:42:43 2025 +0100 perf: only render inline blame for visible lines when `all-lines` is set Previously, we rendereded the inline blame for lines in 3X the range of the viewport This is not necessary because when we scroll down, the rendering will occur before we see the new content commit 95344a9 Author: Nik Revenco <[email protected]> Date: Sat Mar 29 23:59:06 2025 +0000 perf: use string preallocations for string concatenation commit af3b670 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 21:35:45 2025 +0000 refactor: move expression _ commit b3b1c88 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 21:34:06 2025 +0000 refactor: pass the `Style` instead of `Theme` commit c101f37 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 21:31:08 2025 +0000 style: fmt commit 082ba4d Author: Nik Revenco <[email protected]> Date: Tue Mar 25 21:27:14 2025 +0000 refactor: `match` over `if` commit ab56638 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 21:24:33 2025 +0000 refactor: render inline blame in a separate Editor function commit 00d168a Author: Nik Revenco <[email protected]> Date: Tue Mar 25 21:14:02 2025 +0000 fix: funny boolean inversion commit a8097f1 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 20:02:05 2025 +0000 perf: use `Vec<T>` instead of `HashMap<usize, T>` commit 22f9571 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 19:01:12 2025 +0000 feat: split `inline-blame.behaviour` into two options _ _ commit b9f8226 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 13:03:20 2025 +0000 refactor: remove `new_config` from EditorConfigDidChange event There is no need for it because we have access to `Editor::config()` commit d34074a Author: Nik Revenco <[email protected]> Date: Tue Mar 25 12:51:47 2025 +0000 perf: do not render inline blame on invisible lines commit ac0e677 Author: Nik Revenco <[email protected]> Date: Tue Mar 25 12:34:01 2025 +0000 chore: appease clippy commit 76a92af Author: Nik Revenco <[email protected]> Date: Tue Mar 25 12:25:12 2025 +0000 feat: `all-lines` option for inline blame commit 7478d9e Author: Nik Revenco <[email protected]> Date: Tue Mar 25 11:55:05 2025 +0000 refactor: extract as variable commit f54fdef Author: Nik Revenco <[email protected]> Date: Tue Mar 25 11:46:36 2025 +0000 refactor: remove extra layer of sync commit 8f0721f Author: Nik Revenco <[email protected]> Date: Mon Mar 24 16:07:19 2025 +0000 use format! instead of preallocating this is more efficient apparently commit 07c69c1 Author: Nik Revenco <[email protected]> Date: Mon Mar 24 04:00:02 2025 +0000 fix: update blame when editing config commit 647615d Author: Nik Revenco <[email protected]> Date: Mon Mar 24 01:31:01 2025 +0000 perf: optimize obtaining blame for the same line _ fix: blame_line_impl _ _ _ _ _ commit 29f4428 Author: Nik Revenco <[email protected]> Date: Tue Mar 18 01:11:57 2025 +0000 feat: Inline Git Blame fix: use relative path when finding file style: cargo fmt _ chore: better error message refactor: rename to `blame_line` fix: use line of primary cursor for git blame feat: basic implementation of blocking Blame handler feat: implement basic virtual text (end of line blame) feat: figure out how to draw stuff at the end of lines feat: implement end of line virtual text for the current line feat: implement inline git blame chore: clean up chore: remove unused import _ chore: set `blame` to `false` by default docs: document `[editor.vcs.blame]` chore: add progress perf: use background task for worker _ chore: remove unnecessary panic!s chore: remove commented code refactor: remove some layers of abstraction refactor: remove nesting feat: [editor.vcs] -> [editor.version-control] fix: account for inserted and deleted lines _ refactor: extract into a `blame` module feat: allow using custom commit format feat: allow more customizability for inline blame test: add tests for custom inline commit parsser refactor: rename `blame` -> `blame_line` _ _ test: create helper macros for tests test: make test syntax more expressive. Allow specifying line numbers that just got added test: with interspersed lines feat: add `line_blame` static command _ test: add an extra test case test: add ability to have `delete`d lines test: fix on windows (?) test: `delete` test case test: add extra step to test case test: add documentation for macro refactor: use `hashmap!` macro refactor: collapse match arm fix: remove panic perf: update inline git blame every 150 milliseconds instead of on each command test: add attributes on blocks style: move function earlier in the file perf: cache blame results in a hashma chore: remove log statements chore: clean up. ALSO: removes checking for inline blame every N seconds. _ perf: use mspc instead of busy-wait docs: add information why we don't optimize the repo _ test: add back the commented out tests chore: comment out cfg(not(windows)) test: add extra history to blame test docs: remove incorrect static command _ test: disable test on windows feat: send inline blame event update when reloading or saving the document feat: rename `version-control` -> `inline-blame` feat: update theme key used for inline-blame chore: remove unused #![allow] chore: style: remove accidental formatting docs: remove incorrect key perf: Use a single `ThreadSafeRepository` instead of re-constructing it each time feat: add `inline_blame` static command bound to `space + B` style: revert formatting in keymap.md chore: do not compute blame for document when changing config option This isn't needed anymore because the inline-blame will be computed regardless if `inline_blame.enable` is set or not style: remove newline refactor: use `fold` instead of loop chore: clean up feat: log error forl line blame when it happens feat: improve message when we don't have the blame We know that we don't have it because we're still calculating it. feat: do not render inline blame for empty lines _ feat: do not show blame output when we are on a hunk that was added refactor: remove additional wrapper methods fix _ feat: more readable time for git blame chr feat: feat: improved error handling fix: path separator on Windows test: disable on windows refactor: move pretty date function formatter into `helix-stdx` perf: do not use a syscall on each render chore: add TODO comment to update gix version chore: use `gix::path` conversion from Path -> BString _ _ chore: do not update file blame on document save This is not needed because when we write the file, we don't make a new commit so the blame will not change. refactor: use statics to get time elapsed instead of editor state refactor: do not use custom event, use handler instead fix: do not spawn a new handler docs: correct examples for `editor.inline-blame.format` docs: correct static command name refactor: add comments, and improve variable names I didn't really understand this function when I made it. Was just copy-pasted from end of line diagnostics I wanted to know what this is actually doing, so I investigated and while doing this also added comments and improved names of variables so others can understand too fix: time in future is accounted for perf: inline some functions that are called in only 1 place, during a render loop perf: add option to disable requesting inline blame in the background fix: request blame again when document is reloaded chore: inline blame is disabled with request on demand feat: when requesting line blame with "blame on demand", show blame in status perf: use less allocations perf: less allocations in `format_relative_time` _ _ _ _ docs: correct name of command _ feat: improve error message _ feat: rename enum variants for inline blame behaviour docs: improve description of behaviour field Signed-off-by: Dan Bluhm Hansen <[email protected]>
☔ The latest upstream changes (possibly #14896) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR introduces a
complexity
lintconcealed_obvious_default
which checks usages ofOption::<T>::unwrap_or_default()
on a type with an obvious default and suggests usingOption::<T>::unwrap_or(<default>)
instead. It checks similar methods onResult
andEntry
for example, it suggests to replace
x.unwrap_or_default()
withx.unwrap_or(0)
wherex: Option<u8>
.Closes #14779
changelog: add [
concealed_obvious_default
] lint