about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-12-18 19:16:15 +0000
committerbors <bors@rust-lang.org>2024-12-18 19:16:15 +0000
commit4ba4ac612d36e3409e8e1e31e12acc028808f85f (patch)
tree4984f3ca5507abb2a5ccd2aad7346390edff999f /tests
parenta52085d9f6a6e596b0cbad4502cddf86bc878028 (diff)
parenta105cd606628b07e79ab343cc183a176e278c809 (diff)
downloadrust-4ba4ac612d36e3409e8e1e31e12acc028808f85f.tar.gz
rust-4ba4ac612d36e3409e8e1e31e12acc028808f85f.zip
Auto merge of #134443 - joshtriplett:use-field-init-shorthand, r=lqd,tgross35,nnethercote
Use field init shorthand where possible

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.

EDIT: this PR also updates `rustfmt.toml` to set
`use_field_init_shorthand = true`.
Diffstat (limited to 'tests')
-rw-r--r--tests/codegen-units/item-collection/generic-impl.rs2
-rw-r--r--tests/codegen/issues/issue-15953.rs2
-rw-r--r--tests/run-make/extern-fn-struct-passing-abi/test.rs2
-rw-r--r--tests/run-make/symbols-include-type-name/lib.rs2
4 files changed, 4 insertions, 4 deletions
diff --git a/tests/codegen-units/item-collection/generic-impl.rs b/tests/codegen-units/item-collection/generic-impl.rs
index 23d09e0d8af..f6e49f6e6df 100644
--- a/tests/codegen-units/item-collection/generic-impl.rs
+++ b/tests/codegen-units/item-collection/generic-impl.rs
@@ -14,7 +14,7 @@ fn id<T>(x: T) -> T {
 
 impl<T> Struct<T> {
     fn new(x: T) -> Struct<T> {
-        Struct { x: x, f: id }
+        Struct { x, f: id }
     }
 
     fn get<T2>(self, x: T2) -> (T, T2) {
diff --git a/tests/codegen/issues/issue-15953.rs b/tests/codegen/issues/issue-15953.rs
index 28d28428904..70e597ac1dd 100644
--- a/tests/codegen/issues/issue-15953.rs
+++ b/tests/codegen/issues/issue-15953.rs
@@ -9,7 +9,7 @@ struct Foo {
 #[no_mangle]
 // CHECK: memcpy
 fn interior(x: Vec<i32>) -> Vec<i32> {
-    let Foo { x } = Foo { x: x };
+    let Foo { x } = Foo { x };
     x
 }
 
diff --git a/tests/run-make/extern-fn-struct-passing-abi/test.rs b/tests/run-make/extern-fn-struct-passing-abi/test.rs
index f898592fce9..928b1d4a931 100644
--- a/tests/run-make/extern-fn-struct-passing-abi/test.rs
+++ b/tests/run-make/extern-fn-struct-passing-abi/test.rs
@@ -126,7 +126,7 @@ extern "C" {
 
 fn main() {
     let s = Rect { a: 553, b: 554, c: 555, d: 556 };
-    let t = BiggerRect { s: s, a: 27834, b: 7657 };
+    let t = BiggerRect { s, a: 27834, b: 7657 };
     let u = FloatRect { a: 3489, b: 3490, c: 8. };
     let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 };
     let w = Huge64 { a: 1234, b: 1335, c: 1436, d: 1537, e: 1638 };
diff --git a/tests/run-make/symbols-include-type-name/lib.rs b/tests/run-make/symbols-include-type-name/lib.rs
index 37d44591767..7fd42c8b4b4 100644
--- a/tests/run-make/symbols-include-type-name/lib.rs
+++ b/tests/run-make/symbols-include-type-name/lib.rs
@@ -4,7 +4,7 @@ pub struct Def {
 
 impl Def {
     pub fn new(id: i32) -> Def {
-        Def { id: id }
+        Def { id }
     }
 }