Use field init shorthand where possible#134443
Conversation
Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used.
|
r? nnethercote |
tgross35
left a comment
There was a problem hiding this comment.
r=me unless you wanted a review from nnethercote specifically
|
This rustfmt setting seems uncontroversial. If you don't need a review from nick specifically, r=me when CI is green. |
|
👍 |
|
@bors r=lqd,tgross35,nnethercote |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@bors rollup=never can cause unrelated PRs in the rollup to break |
There was a problem hiding this comment.
This PR changes rustfmt.toml
|
Should |
I'm stuck, step-reviewer, help me: #129636 |
|
Can also apply this diff to make clippy check the same thing. Can be added to this pr or i can send it separately. diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs
index 0884d86cc6d..4644f31c003 100644
--- a/src/bootstrap/src/core/build_steps/clippy.rs
+++ b/src/bootstrap/src/core/build_steps/clippy.rs
@@ -378,20 +378,24 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
config: self.config.merge(&LintConfig {
allow: vec![],
warn: vec![],
- deny: vec!["warnings".into()],
+ deny: vec!["clippy::redundant_field_names".into(), "warnings".into()],
forbid: vec![],
}),
});
let library_clippy_cfg = LintConfig {
allow: vec!["clippy::all".into()],
warn: vec![],
- deny: vec!["clippy::correctness".into()],
+ deny: vec!["clippy::redundant_field_names".into(), "clippy::correctness".into()],
forbid: vec![],
};
let compiler_clippy_cfg = LintConfig {
allow: vec!["clippy::all".into()],
warn: vec![],
- deny: vec!["clippy::correctness".into(), "clippy::clone_on_ref_ptr".into()],
+ deny: vec![
+ "clippy::redundant_field_names".into(),
+ "clippy::correctness".into(),
+ "clippy::clone_on_ref_ptr".into(),
+ ],
forbid: vec![],
};
|
|
@klensy Please send the clippy change as a separate PR. Happy to review it. |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (4ba4ac6): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -7.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 2.9%, secondary -2.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 769.824s -> 771.62s (0.23%) |
Field init shorthand allows writing initializers like
tcx: tcxastcx. The compiler already uses it extensively. Fix the last few placeswhere it isn't yet used.
EDIT: this PR also updates
rustfmt.tomlto setuse_field_init_shorthand = true.