Skip to content

Commit 0f3ffe7

Browse files
authored
sdk,cosmwasm: fix new clippy 1.78.0 lints (wormhole-foundation#3925)
The 1.78 version of the rust toolchain has been released on the stable channel: https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-178 It introduces a number of new clippy lints. The relevant ones: - https://rust-lang.github.io/rust-clippy/master/index.html#/assigning_clones - https://rust-lang.github.io/rust-clippy/master/index.html#/multiple_bound_locations - https://rust-lang.github.io/rust-clippy/master/index.html#/new_without_default This commit fixes these lints.
1 parent 557fc92 commit 0f3ffe7

File tree

4 files changed

+60
-78
lines changed

4 files changed

+60
-78
lines changed

cosmwasm/contracts/ibc-translator/src/reply.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn convert_cw20_to_bank_and_send(
136136

137137
let mut symbol = token_info.symbol;
138138
if symbol.is_empty() {
139-
symbol = tf_scaled_denom.clone();
139+
symbol.clone_from(&tf_scaled_denom);
140140
}
141141
let tf_description =
142142
token_info.name.clone() + ", " + symbol.as_str() + ", " + tokenfactory_denom.as_str();

cosmwasm/contracts/ibc-translator/tests/test_setup/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,17 @@ impl<C: DeserializeOwned> MockQuerier<C> {
238238
self.ibc = IbcQuerier::new(port_id, channels);
239239
}
240240

241-
pub fn update_wasm<WH: 'static>(&mut self, handler: WH)
241+
pub fn update_wasm<WH>(&mut self, handler: WH)
242242
where
243-
WH: Fn(&WasmQuery) -> QuerierResult,
243+
WH: 'static + Fn(&WasmQuery) -> QuerierResult,
244244
{
245245
self.wasm.update_handler(handler)
246246
}
247247

248248
#[allow(dead_code)]
249-
pub fn with_custom_handler<CH: 'static>(mut self, handler: CH) -> Self
249+
pub fn with_custom_handler<CH>(mut self, handler: CH) -> Self
250250
where
251-
CH: Fn(&C) -> MockQuerierCustomHandlerResult,
251+
CH: 'static + Fn(&C) -> MockQuerierCustomHandlerResult,
252252
{
253253
self.custom_handler = Box::from(handler);
254254
self
@@ -311,9 +311,9 @@ impl WasmQuerier {
311311
Self { handler }
312312
}
313313

314-
fn update_handler<WH: 'static>(&mut self, handler: WH)
314+
fn update_handler<WH>(&mut self, handler: WH)
315315
where
316-
WH: Fn(&WasmQuery) -> QuerierResult,
316+
WH: 'static + Fn(&WasmQuery) -> QuerierResult,
317317
{
318318
self.handler = Box::from(handler)
319319
}

cosmwasm/packages/cw_transcode/src/ser.rs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ impl Serializer {
2020
}
2121
}
2222

23+
impl Default for Serializer {
24+
fn default() -> Self {
25+
Self::new()
26+
}
27+
}
28+
2329
impl<'a> serde::Serializer for &'a mut Serializer {
2430
type Ok = ();
2531
type Error = Error;
@@ -117,9 +123,9 @@ impl<'a> serde::Serializer for &'a mut Serializer {
117123
}
118124

119125
#[inline]
120-
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
126+
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
121127
where
122-
T: Serialize,
128+
T: ?Sized + Serialize,
123129
{
124130
value.serialize(self)
125131
}
@@ -153,27 +159,23 @@ impl<'a> serde::Serializer for &'a mut Serializer {
153159
}
154160

155161
#[inline]
156-
fn serialize_newtype_struct<T: ?Sized>(
157-
self,
158-
_: &'static str,
159-
_: &T,
160-
) -> Result<Self::Ok, Self::Error>
162+
fn serialize_newtype_struct<T>(self, _: &'static str, _: &T) -> Result<Self::Ok, Self::Error>
161163
where
162-
T: Serialize,
164+
T: ?Sized + Serialize,
163165
{
164166
Err(Error::NotAStruct)
165167
}
166168

167169
#[inline]
168-
fn serialize_newtype_variant<T: ?Sized>(
170+
fn serialize_newtype_variant<T>(
169171
self,
170172
_: &'static str,
171173
_variant_index: u32,
172174
_: &'static str,
173175
_: &T,
174176
) -> Result<Self::Ok, Self::Error>
175177
where
176-
T: Serialize,
178+
T: ?Sized + Serialize,
177179
{
178180
Err(Error::NotAStruct)
179181
}
@@ -246,9 +248,9 @@ impl<'a> serde::Serializer for &'a mut Serializer {
246248
}
247249

248250
#[inline]
249-
fn collect_str<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
251+
fn collect_str<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
250252
where
251-
T: Display,
253+
T: ?Sized + Display,
252254
{
253255
Err(Error::NotAStruct)
254256
}
@@ -265,9 +267,9 @@ pub struct Transcoder<'a> {
265267
}
266268

267269
impl<'a> Transcoder<'a> {
268-
fn serialize_field<T: ?Sized>(&mut self, k: &'static str, v: &T) -> Result<(), Error>
270+
fn serialize_field<T>(&mut self, k: &'static str, v: &T) -> Result<(), Error>
269271
where
270-
T: Serialize,
272+
T: ?Sized + Serialize,
271273
{
272274
let key = k.into();
273275
let value = serde_json_wasm::to_string(v)?;
@@ -288,13 +290,9 @@ impl<'a> SerializeStruct for Transcoder<'a> {
288290
type Error = Error;
289291

290292
#[inline]
291-
fn serialize_field<T: ?Sized>(
292-
&mut self,
293-
k: &'static str,
294-
v: &T,
295-
) -> Result<Self::Ok, Self::Error>
293+
fn serialize_field<T>(&mut self, k: &'static str, v: &T) -> Result<Self::Ok, Self::Error>
296294
where
297-
T: Serialize,
295+
T: ?Sized + Serialize,
298296
{
299297
self.serialize_field(k, v)
300298
}
@@ -310,13 +308,9 @@ impl<'a> SerializeStructVariant for Transcoder<'a> {
310308
type Error = Error;
311309

312310
#[inline]
313-
fn serialize_field<T: ?Sized>(
314-
&mut self,
315-
k: &'static str,
316-
v: &T,
317-
) -> Result<Self::Ok, Self::Error>
311+
fn serialize_field<T>(&mut self, k: &'static str, v: &T) -> Result<Self::Ok, Self::Error>
318312
where
319-
T: Serialize,
313+
T: ?Sized + Serialize,
320314
{
321315
self.serialize_field(k, v)
322316
}

sdk/rust/serde_wormhole/src/ser.rs

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ impl<'a, W: Write> ser::Serializer for &'a mut Serializer<W> {
122122
}
123123

124124
#[inline]
125-
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
125+
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
126126
where
127-
T: Serialize,
127+
T: ?Sized + Serialize,
128128
{
129129
value.serialize(self)
130130
}
@@ -152,13 +152,13 @@ impl<'a, W: Write> ser::Serializer for &'a mut Serializer<W> {
152152
self.writer.write_all(&[v]).map_err(Error::from)
153153
}
154154

155-
fn serialize_newtype_struct<T: ?Sized>(
155+
fn serialize_newtype_struct<T>(
156156
self,
157157
name: &'static str,
158158
value: &T,
159159
) -> Result<Self::Ok, Self::Error>
160160
where
161-
T: Serialize,
161+
T: ?Sized + Serialize,
162162
{
163163
if name == crate::raw::TOKEN {
164164
value.serialize(RawMessageSerializer(&mut self.writer))
@@ -167,15 +167,15 @@ impl<'a, W: Write> ser::Serializer for &'a mut Serializer<W> {
167167
}
168168
}
169169

170-
fn serialize_newtype_variant<T: ?Sized>(
170+
fn serialize_newtype_variant<T>(
171171
self,
172172
name: &'static str,
173173
_variant_index: u32,
174174
variant: &'static str,
175175
value: &T,
176176
) -> Result<Self::Ok, Self::Error>
177177
where
178-
T: Serialize,
178+
T: ?Sized + Serialize,
179179
{
180180
let v: u8 = variant
181181
.parse()
@@ -257,9 +257,9 @@ impl<'a, W: Write> ser::Serializer for &'a mut Serializer<W> {
257257
}
258258

259259
#[inline]
260-
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
260+
fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
261261
where
262-
T: Display,
262+
T: ?Sized + Display,
263263
{
264264
self.serialize_str(&value.to_string())
265265
}
@@ -275,9 +275,9 @@ impl<'a, W: Write> ser::SerializeSeq for &'a mut Serializer<W> {
275275
type Error = Error;
276276

277277
#[inline]
278-
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
278+
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
279279
where
280-
T: Serialize,
280+
T: ?Sized + Serialize,
281281
{
282282
value.serialize(&mut **self)
283283
}
@@ -293,9 +293,9 @@ impl<'a, W: Write> ser::SerializeTuple for &'a mut Serializer<W> {
293293
type Error = Error;
294294

295295
#[inline]
296-
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
296+
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
297297
where
298-
T: Serialize,
298+
T: ?Sized + Serialize,
299299
{
300300
value.serialize(&mut **self)
301301
}
@@ -311,9 +311,9 @@ impl<'a, W: Write> ser::SerializeTupleStruct for &'a mut Serializer<W> {
311311
type Error = Error;
312312

313313
#[inline]
314-
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
314+
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
315315
where
316-
T: Serialize,
316+
T: ?Sized + Serialize,
317317
{
318318
value.serialize(&mut **self)
319319
}
@@ -329,9 +329,9 @@ impl<'a, W: Write> ser::SerializeTupleVariant for &'a mut Serializer<W> {
329329
type Error = Error;
330330

331331
#[inline]
332-
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
332+
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
333333
where
334-
T: Serialize,
334+
T: ?Sized + Serialize,
335335
{
336336
value.serialize(&mut **self)
337337
}
@@ -347,13 +347,9 @@ impl<'a, W: Write> ser::SerializeStruct for &'a mut Serializer<W> {
347347
type Error = Error;
348348

349349
#[inline]
350-
fn serialize_field<T: ?Sized>(
351-
&mut self,
352-
_key: &'static str,
353-
value: &T,
354-
) -> Result<(), Self::Error>
350+
fn serialize_field<T>(&mut self, _key: &'static str, value: &T) -> Result<(), Self::Error>
355351
where
356-
T: Serialize,
352+
T: ?Sized + Serialize,
357353
{
358354
value.serialize(&mut **self)
359355
}
@@ -369,13 +365,9 @@ impl<'a, W: Write> ser::SerializeStructVariant for &'a mut Serializer<W> {
369365
type Error = Error;
370366

371367
#[inline]
372-
fn serialize_field<T: ?Sized>(
373-
&mut self,
374-
_key: &'static str,
375-
value: &T,
376-
) -> Result<(), Self::Error>
368+
fn serialize_field<T>(&mut self, _key: &'static str, value: &T) -> Result<(), Self::Error>
377369
where
378-
T: Serialize,
370+
T: ?Sized + Serialize,
379371
{
380372
value.serialize(&mut **self)
381373
}
@@ -391,29 +383,25 @@ impl<'a, W: Write> ser::SerializeMap for &'a mut Serializer<W> {
391383
type Error = Error;
392384

393385
#[inline]
394-
fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
386+
fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
395387
where
396-
T: Serialize,
388+
T: ?Sized + Serialize,
397389
{
398390
key.serialize(&mut **self)
399391
}
400392

401393
#[inline]
402-
fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
394+
fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
403395
where
404-
T: Serialize,
396+
T: ?Sized + Serialize,
405397
{
406398
value.serialize(&mut **self)
407399
}
408400

409-
fn serialize_entry<K: ?Sized, V: ?Sized>(
410-
&mut self,
411-
key: &K,
412-
value: &V,
413-
) -> Result<(), Self::Error>
401+
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Self::Error>
414402
where
415-
K: Serialize,
416-
V: Serialize,
403+
K: ?Sized + Serialize,
404+
V: ?Sized + Serialize,
417405
{
418406
self.serialize_key(key)?;
419407
self.serialize_value(value)
@@ -508,9 +496,9 @@ impl<W: Write> ser::Serializer for RawMessageSerializer<W> {
508496
Err(ser::Error::custom("expected RawMessage"))
509497
}
510498

511-
fn serialize_some<T: ?Sized>(self, _value: &T) -> Result<Self::Ok, Self::Error>
499+
fn serialize_some<T>(self, _value: &T) -> Result<Self::Ok, Self::Error>
512500
where
513-
T: Serialize,
501+
T: ?Sized + Serialize,
514502
{
515503
Err(ser::Error::custom("expected RawMessage"))
516504
}
@@ -532,26 +520,26 @@ impl<W: Write> ser::Serializer for RawMessageSerializer<W> {
532520
Err(ser::Error::custom("expected RawMessage"))
533521
}
534522

535-
fn serialize_newtype_struct<T: ?Sized>(
523+
fn serialize_newtype_struct<T>(
536524
self,
537525
_name: &'static str,
538526
_value: &T,
539527
) -> Result<Self::Ok, Self::Error>
540528
where
541-
T: Serialize,
529+
T: ?Sized + Serialize,
542530
{
543531
Err(ser::Error::custom("expected RawMessage"))
544532
}
545533

546-
fn serialize_newtype_variant<T: ?Sized>(
534+
fn serialize_newtype_variant<T>(
547535
self,
548536
_name: &'static str,
549537
_variant_index: u32,
550538
_variant: &'static str,
551539
_value: &T,
552540
) -> Result<Self::Ok, Self::Error>
553541
where
554-
T: Serialize,
542+
T: ?Sized + Serialize,
555543
{
556544
Err(ser::Error::custom("expected RawMessage"))
557545
}

0 commit comments

Comments
 (0)