Skip to content

Commit 569b098

Browse files
committed
Fix lints
1 parent 9a66fcf commit 569b098

File tree

10 files changed

+49
-59
lines changed

10 files changed

+49
-59
lines changed

crates/rr/src/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ impl fmt::Debug for RRFuncArgVals {
4040
let hex_string = bytes
4141
.iter()
4242
.rev()
43-
.map(|b| format!("{:02x}", b))
43+
.map(|b| format!("{b:02x}"))
4444
.collect::<String>();
45-
format!("0x{}", hex_string)
45+
format!("0x{hex_string}")
4646
};
4747
for flat_size in self.sizes.iter() {
4848
list.entry(&(
@@ -72,7 +72,7 @@ pub trait Validate<T: ?Sized> {
7272
where
7373
Self: fmt::Debug,
7474
{
75-
log::debug!("Validating => {:?}", self);
75+
log::debug!("Validating => {self:?}");
7676
}
7777
}
7878

@@ -86,7 +86,7 @@ where
8686
if self == expect {
8787
Ok(())
8888
} else {
89-
log::error!("Validation against {:?} failed!", expect);
89+
log::error!("Validation against {expect:?} failed!");
9090
Err(ReplayError::FailedValidation)
9191
}
9292
}

crates/rr/src/events/component_events.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ macro_rules! builtin_events {
177177
type Error = ReplayError;
178178

179179
fn try_from(value: $enum) -> Result<Self, Self::Error> {
180-
#[allow(irrefutable_let_patterns)]
181180
if let $enum::$rr_var(x) = value {
182181
Ok(x)
183182
} else {

crates/rr/src/events/core_events.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ pub struct RRModuleInstanceId(pub u32);
1515
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Ord, PartialOrd)]
1616
pub struct RRModuleFuncIndex(pub u32);
1717

18-
impl Into<FuncIndex> for RRModuleFuncIndex {
19-
fn into(self) -> FuncIndex {
20-
FuncIndex::from_u32(self.0)
18+
impl From<RRModuleFuncIndex> for FuncIndex {
19+
fn from(r: RRModuleFuncIndex) -> Self {
20+
FuncIndex::from_u32(r.0)
2121
}
2222
}
2323

24-
impl Into<EntityIndex> for RRModuleFuncIndex {
25-
fn into(self) -> EntityIndex {
26-
EntityIndex::from(Into::<FuncIndex>::into(self))
24+
impl From<RRModuleFuncIndex> for EntityIndex {
25+
fn from(r: RRModuleFuncIndex) -> Self {
26+
EntityIndex::from(FuncIndex::from(r))
2727
}
2828
}
2929

crates/rr/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ impl fmt::Display for ReplayError {
214214
write!(f, "event type mismatch during replay")
215215
}
216216
Self::EventError(e) => {
217-
write!(f, "{:?}", e)
217+
write!(f, "{e:?}")
218218
}
219219
Self::FailedRead(e) => {
220-
write!(f, "{}", e)?;
220+
write!(f, "{e}")?;
221221
f.write_str("Note: Ensure sufficient `deserialization-buffer-size` in replay settings if you included `validation-metadata` during recording")
222222
}
223223
Self::InvalidEventPosition => {
@@ -229,7 +229,7 @@ impl fmt::Display for ReplayError {
229229
"missing component binary with checksum 0x{} during replay",
230230
checksum
231231
.iter()
232-
.map(|b| format!("{:02x}", b))
232+
.map(|b| format!("{b:02x}"))
233233
.collect::<String>()
234234
)
235235
}
@@ -239,18 +239,18 @@ impl fmt::Display for ReplayError {
239239
"missing module binary with checksum {:02x?} during replay",
240240
checksum
241241
.iter()
242-
.map(|b| format!("{:02x}", b))
242+
.map(|b| format!("{b:02x}"))
243243
.collect::<String>()
244244
)
245245
}
246246
Self::MissingComponentInstance(id) => {
247-
write!(f, "missing component instance ID {:?} during replay", id)
247+
write!(f, "missing component instance ID {id:?} during replay")
248248
}
249249
Self::MissingModuleInstance(id) => {
250-
write!(f, "missing module instance ID {:?} during replay", id)
250+
write!(f, "missing module instance ID {id:?} during replay")
251251
}
252252
Self::InvalidCoreFuncIndex(index) => {
253-
write!(f, "replay core func ({:?}) during replay is invalid", index)
253+
write!(f, "replay core func ({index:?}) during replay is invalid")
254254
}
255255
}
256256
}

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ impl<'a, T: 'static> LowerContext<'a, T> {
290290
FixedMemorySlice {
291291
bytes: slice_mut[offset..].first_chunk_mut().unwrap(),
292292
#[cfg(feature = "rr")]
293-
offset: offset,
293+
offset,
294294
#[cfg(feature = "rr")]
295-
recorder: recorder,
295+
recorder,
296296
}
297297
}
298298

@@ -314,9 +314,9 @@ impl<'a, T: 'static> LowerContext<'a, T> {
314314
DynamicMemorySlice {
315315
bytes: &mut slice_mut[offset..][..size],
316316
#[cfg(feature = "rr")]
317-
offset: offset,
317+
offset,
318318
#[cfg(feature = "rr")]
319-
recorder: recorder,
319+
recorder,
320320
}
321321
}
322322

@@ -526,7 +526,7 @@ impl<'a, T: 'static> LowerContext<'a, T> {
526526
}
527527
}
528528
_ => {
529-
bail!("Invalid event \'{:?}\' encountered during lowering", event);
529+
bail!("Invalid event \'{event:?}\' encountered during lowering");
530530
}
531531
};
532532
}

crates/wasmtime/src/runtime/rr/backend.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ impl RRFuncArgValsConvertable for RRFuncArgVals {
8989
}
9090

9191
// Conversions from Wasmtime types to RR types
92-
impl Into<RRComponentInstanceId> for ComponentInstanceId {
93-
fn into(self) -> RRComponentInstanceId {
94-
RRComponentInstanceId(self.as_u32())
92+
impl From<ComponentInstanceId> for RRComponentInstanceId {
93+
fn from(id: ComponentInstanceId) -> Self {
94+
RRComponentInstanceId(id.as_u32())
9595
}
9696
}
9797

98-
impl Into<RRModuleInstanceId> for InstanceId {
99-
fn into(self) -> RRModuleInstanceId {
100-
RRModuleInstanceId(self.as_u32())
98+
impl From<InstanceId> for RRModuleInstanceId {
99+
fn from(id: InstanceId) -> Self {
100+
RRModuleInstanceId(id.as_u32())
101101
}
102102
}
103103

@@ -145,7 +145,7 @@ impl Recorder for RecordBuffer {
145145
Ok(RecordBuffer {
146146
buf: Vec::new(),
147147
writer: Box::new(writer),
148-
settings: settings,
148+
settings,
149149
})
150150
}
151151

@@ -214,7 +214,7 @@ impl Iterator for ReplayBuffer {
214214
} else if event.is_marker() {
215215
continue 'event_loop;
216216
} else {
217-
log::debug!("Read replay event => {}", event);
217+
log::debug!("Read replay event => {event}");
218218
break 'event_loop Some(Ok(event));
219219
}
220220
}
@@ -376,9 +376,7 @@ mod tests {
376376
let b_slice: &[u8] = &b.get_bytes()[..*sz as usize];
377377
assert!(
378378
a_slice == b_slice,
379-
"Recorded values {:?} and replayed values {:?} do not match",
380-
a_slice,
381-
b_slice
379+
"Recorded values {a_slice:?} and replayed values {b_slice:?} do not match"
382380
);
383381
}
384382
Ok(())

crates/wasmtime/src/runtime/rr/hooks/component_hooks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn record_wasm_func_begin(
4343
#[cfg(feature = "rr")]
4444
store.record_event(|| WasmFuncBeginEvent {
4545
instance: instance.into(),
46-
func_index: func_index.into(),
46+
func_index,
4747
})?;
4848
let _ = (instance, func_index, store);
4949
Ok(())
@@ -59,7 +59,7 @@ pub fn record_wasm_func_post_return<T>(
5959
#[cfg(feature = "rr")]
6060
store.0.record_event(|| PostReturnEvent {
6161
instance: instance.into(),
62-
func_index: func_index.into(),
62+
func_index,
6363
})?;
6464
let _ = (instance, func_index, store);
6565
Ok(())
@@ -93,7 +93,7 @@ where
9393
#[cfg(feature = "rr")]
9494
{
9595
if let Err(e) = &result {
96-
log::warn!("Wasm function call exited with error: {:?}", e);
96+
log::warn!("Wasm function call exited with error: {e:?}");
9797
}
9898
let flat_results = types.flat_types_storage_or_pointer(
9999
&InterfaceType::Tuple(types[type_idx].results),

crates/wasmtime/src/runtime/rr/hooks/core_hooks.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where
4646
{
4747
if origin.is_some() {
4848
if let Err(e) = &result {
49-
log::warn!("Wasm function call exited with error: {:?}", e);
49+
log::warn!("Wasm function call exited with error: {e:?}");
5050
}
5151
let flat = ty.results().map(|t| t.to_wasm_type().byte_size());
5252
let result = result.map(|_| RRFuncArgVals::from_flat_iter(args, flat));
@@ -148,7 +148,7 @@ where
148148
}
149149
// Re-entrant call into wasm function: this resembles the implementation in [`ReplayInstance`]
150150
RREvent::CoreWasmFuncEntry(event) => {
151-
let entity = Into::<EntityIndex>::into(event.func_index);
151+
let entity = EntityIndex::from(event.func_index);
152152

153153
// Unwrapping the `replay_buffer_mut()` above ensures that we are in replay mode
154154
// passing the safety contract for `replay_data_from_store`
@@ -182,10 +182,7 @@ where
182182
}
183183
}
184184
_ => {
185-
bail!(
186-
"Unexpected event during core wasm host function replay: {:?}",
187-
event
188-
);
185+
bail!("Unexpected event during core wasm host function replay: {event:?}",);
189186
}
190187
}
191188
}

crates/wasmtime/src/runtime/rr/replay_driver.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ impl ReplayInstance {
325325
let instance = self.component_instances.get_mut(event.instance)?;
326326

327327
// Replay lowering steps and obtain raw value arguments to raw function call
328-
let func =
329-
component::Func::from_lifted_func(*instance, Into::into(event.func_index));
328+
let func = component::Func::from_lifted_func(*instance, event.func_index);
330329
let store = self.store.as_context_mut();
331330
// Call the function
332331
//
@@ -371,8 +370,7 @@ impl ReplayInstance {
371370
}
372371
RREvent::ComponentPostReturn(event) => {
373372
let instance = self.component_instances.get_mut(event.instance)?;
374-
let func =
375-
component::Func::from_lifted_func(*instance, Into::into(event.func_index));
373+
let func = component::Func::from_lifted_func(*instance, event.func_index);
376374
let mut store = self.store.as_context_mut();
377375
func.post_return(&mut store)?;
378376
}
@@ -386,8 +384,8 @@ impl ReplayInstance {
386384
self.insert_module_instance(instance);
387385
}
388386
RREvent::CoreWasmFuncEntry(event) => {
389-
let instance = self.module_instances.get_mut(event.instance.into())?;
390-
let entity = Into::<EntityIndex>::into(event.func_index);
387+
let instance = self.module_instances.get_mut(event.instance)?;
388+
let entity = EntityIndex::from(event.func_index);
391389
let mut store = self.store.as_context_mut();
392390
let func = instance
393391
._get_export(store.0, entity)
@@ -409,7 +407,7 @@ impl ReplayInstance {
409407
}
410408

411409
_ => {
412-
log::error!("Unexpected top-level RR event: {:?}", rr_event);
410+
log::error!("Unexpected top-level RR event: {rr_event:?}");
413411
Err(ReplayError::IncorrectEventVariant)?
414412
}
415413
}
@@ -434,8 +432,7 @@ impl ReplayInstance {
434432
let instance = self.component_instances.get_mut(event.instance)?;
435433

436434
// Replay lowering steps and obtain raw value arguments to raw function call
437-
let func =
438-
component::Func::from_lifted_func(*instance, Into::into(event.func_index));
435+
let func = component::Func::from_lifted_func(*instance, event.func_index);
439436
let mut store = self.store.as_context_mut();
440437
// Call the function
441438
//
@@ -486,8 +483,7 @@ impl ReplayInstance {
486483
}
487484
RREvent::ComponentPostReturn(event) => {
488485
let instance = self.component_instances.get_mut(event.instance)?;
489-
let func =
490-
component::Func::from_lifted_func(*instance, Into::into(event.func_index));
486+
let func = component::Func::from_lifted_func(*instance, event.func_index);
491487
let mut store = self.store.as_context_mut();
492488
func.post_return_async(&mut store).await?;
493489
}
@@ -503,7 +499,7 @@ impl ReplayInstance {
503499
}
504500
RREvent::CoreWasmFuncEntry(event) => {
505501
let instance = self.module_instances.get_mut(event.instance)?;
506-
let entity = Into::<EntityIndex>::into(event.func_index);
502+
let entity = EntityIndex::from(event.func_index);
507503
let mut store = self.store.as_context_mut();
508504
let func = instance
509505
._get_export(store.0, entity)
@@ -529,7 +525,7 @@ impl ReplayInstance {
529525
}
530526

531527
_ => {
532-
log::error!("Unexpected top-level RR event: {:?}", rr_event);
528+
log::error!("Unexpected top-level RR event: {rr_event:?}");
533529
Err(ReplayError::IncorrectEventVariant)?
534530
}
535531
}

tests/all/rr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ where
225225
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>,
226226
{
227227
// === RECORDING PHASE ===
228-
log::info!("Recording | Validate: {}, Async: {}", validate, is_async);
228+
log::info!("Recording | Validate: {validate}, Async: {is_async}");
229229
let engine = create_recording_engine(is_async)?;
230230
let component = Component::new(&engine, component_wat)?;
231231

@@ -255,7 +255,7 @@ where
255255
trace_reader.set_position(0);
256256

257257
// === REPLAY PHASE ===
258-
log::info!("Replaying | Validate: {}, Async: {}", validate, is_async);
258+
log::info!("Replaying | Validate: {validate}, Async: {is_async}");
259259
let engine = create_replay_engine(is_async)?;
260260
let component = Component::new(&engine, component_wat)?;
261261
let replay_settings = ReplaySettings {
@@ -1550,7 +1550,7 @@ fn cabi_realloc_wat() -> String {
15501550
fn shims_wat(params: &str) -> String {
15511551
let count = params.split_whitespace().count();
15521552
let locals_get = (0..count)
1553-
.map(|i| format!("local.get {}", i))
1553+
.map(|i| format!("local.get {i}"))
15541554
.collect::<Vec<_>>()
15551555
.join("\n");
15561556
format!(

0 commit comments

Comments
 (0)