Various clippy fixes. (#403)
This commit is contained in:
@@ -39,13 +39,11 @@ lazy_static! {
|
||||
.map_err(|_| warn!("Failed to get metadata of current executable"))
|
||||
.ok()
|
||||
})
|
||||
.and_then(|mtime| {
|
||||
Some(match mtime.duration_since(std::time::UNIX_EPOCH) {
|
||||
Ok(duration) => format!("{}", duration.as_millis()),
|
||||
Err(err) => format!("m{}", err.duration().as_millis()),
|
||||
})
|
||||
.map(|mtime| match mtime.duration_since(std::time::UNIX_EPOCH) {
|
||||
Ok(duration) => format!("{}", duration.as_millis()),
|
||||
Err(err) => format!("m{}", err.duration().as_millis()),
|
||||
})
|
||||
.unwrap_or("no-mtime".to_string())
|
||||
.unwrap_or_else(|| "no-mtime".to_string())
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
6
wasmtime-environ/src/cache/config.rs
vendored
6
wasmtime-environ/src/cache/config.rs
vendored
@@ -103,7 +103,7 @@ static INIT_CALLED: AtomicBool = AtomicBool::new(false);
|
||||
/// If system has not been initialized, it disables it.
|
||||
/// You mustn't call init() after it.
|
||||
pub fn cache_config() -> &'static CacheConfig {
|
||||
CONFIG.call_once(|| CacheConfig::new_cache_disabled())
|
||||
CONFIG.call_once(CacheConfig::new_cache_disabled)
|
||||
}
|
||||
|
||||
/// Initializes the cache system. Should be called exactly once,
|
||||
@@ -196,7 +196,7 @@ lazy_static! {
|
||||
static ref DEFAULT_CONFIG_PATH: Result<PathBuf, String> = PROJECT_DIRS
|
||||
.as_ref()
|
||||
.map(|proj_dirs| proj_dirs.config_dir().join("wasmtime-cache-config.toml"))
|
||||
.ok_or("Config file not specified and failed to get the default".to_string());
|
||||
.ok_or_else(|| "Config file not specified and failed to get the default".to_string());
|
||||
}
|
||||
|
||||
// Default settings, you're welcome to tune them!
|
||||
@@ -312,7 +312,7 @@ generate_deserializer!(deserialize_percent(num: u8, unit: &str) -> Option<u8> {
|
||||
}
|
||||
});
|
||||
|
||||
static CACHE_IMPROPER_CONFIG_ERROR_MSG: &'static str =
|
||||
static CACHE_IMPROPER_CONFIG_ERROR_MSG: &str =
|
||||
"Cache system should be enabled and all settings must be validated or defaulted";
|
||||
|
||||
macro_rules! generate_setting_getter {
|
||||
|
||||
12
wasmtime-environ/src/cache/worker.rs
vendored
12
wasmtime-environ/src/cache/worker.rs
vendored
@@ -105,7 +105,7 @@ impl Worker {
|
||||
Self {
|
||||
sender: tx,
|
||||
#[cfg(test)]
|
||||
stats: stats,
|
||||
stats,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ impl WorkerThread {
|
||||
(0..=1, true) => enter_dir(vec, &path, level + 1, cache_config),
|
||||
(0..=1, false) => {
|
||||
if level == 0 && path.file_stem() == Some(OsStr::new(".cleanup")) {
|
||||
if let Some(_) = path.extension() {
|
||||
if path.extension().is_some() {
|
||||
// assume it's cleanup lock
|
||||
if !is_fs_lock_expired(
|
||||
Some(&entry),
|
||||
@@ -699,9 +699,11 @@ impl WorkerThread {
|
||||
"Failed to get metadata/mtime, deleting the file",
|
||||
stats_path
|
||||
);
|
||||
// .into() called for the SystemTimeStub if cfg(test)
|
||||
#[allow(clippy::identity_conversion)]
|
||||
vec.push(CacheEntry::Recognized {
|
||||
path: mod_path.to_path_buf(),
|
||||
mtime: stats_mtime.into(), // .into() called for the SystemTimeStub if cfg(test)
|
||||
mtime: stats_mtime.into(),
|
||||
size: mod_metadata.len(),
|
||||
})
|
||||
}
|
||||
@@ -715,9 +717,11 @@ impl WorkerThread {
|
||||
"Failed to get metadata/mtime, deleting the file",
|
||||
mod_path
|
||||
);
|
||||
// .into() called for the SystemTimeStub if cfg(test)
|
||||
#[allow(clippy::identity_conversion)]
|
||||
vec.push(CacheEntry::Recognized {
|
||||
path: mod_path.to_path_buf(),
|
||||
mtime: mod_mtime.into(), // .into() called for the SystemTimeStub if cfg(test)
|
||||
mtime: mod_mtime.into(),
|
||||
size: mod_metadata.len(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ impl crate::compilation::Compiler for Cranelift {
|
||||
if let Some(address_transform) = address_transform {
|
||||
address_transforms.push(address_transform);
|
||||
}
|
||||
value_ranges.push(ranges.unwrap_or(std::collections::HashMap::new()));
|
||||
value_ranges.push(ranges.unwrap_or_default());
|
||||
stack_slots.push(sss);
|
||||
traps.push(function_traps);
|
||||
},
|
||||
|
||||
@@ -239,13 +239,13 @@ impl lightbeam::ModuleContext for FuncEnvironment<'_> {
|
||||
fn defined_func_index(&self, func_index: u32) -> Option<u32> {
|
||||
self.module
|
||||
.defined_func_index(FuncIndex::from_u32(func_index))
|
||||
.map(|i| i.as_u32())
|
||||
.map(DefinedFuncIndex::as_u32)
|
||||
}
|
||||
|
||||
fn defined_global_index(&self, global_index: u32) -> Option<u32> {
|
||||
self.module
|
||||
.defined_global_index(GlobalIndex::from_u32(global_index))
|
||||
.map(|i| i.as_u32())
|
||||
.map(DefinedGlobalIndex::as_u32)
|
||||
}
|
||||
|
||||
fn global_type(&self, global_index: u32) -> &Self::GlobalType {
|
||||
@@ -263,13 +263,13 @@ impl lightbeam::ModuleContext for FuncEnvironment<'_> {
|
||||
fn defined_table_index(&self, table_index: u32) -> Option<u32> {
|
||||
self.module
|
||||
.defined_table_index(TableIndex::from_u32(table_index))
|
||||
.map(|i| i.as_u32())
|
||||
.map(DefinedTableIndex::as_u32)
|
||||
}
|
||||
|
||||
fn defined_memory_index(&self, memory_index: u32) -> Option<u32> {
|
||||
self.module
|
||||
.defined_memory_index(MemoryIndex::from_u32(memory_index))
|
||||
.map(|i| i.as_u32())
|
||||
.map(DefinedMemoryIndex::as_u32)
|
||||
}
|
||||
|
||||
fn vmctx_vmfunction_import_body(&self, func_index: u32) -> u32 {
|
||||
|
||||
@@ -61,7 +61,7 @@ impl MemoryStyle {
|
||||
// it static.
|
||||
assert!(tunables.static_memory_bound >= memory.minimum);
|
||||
return (
|
||||
MemoryStyle::Static {
|
||||
Self::Static {
|
||||
bound: tunables.static_memory_bound,
|
||||
},
|
||||
tunables.static_memory_offset_guard_size,
|
||||
@@ -70,10 +70,7 @@ impl MemoryStyle {
|
||||
}
|
||||
|
||||
// Otherwise, make it dynamic.
|
||||
(
|
||||
MemoryStyle::Dynamic,
|
||||
tunables.dynamic_memory_offset_guard_size,
|
||||
)
|
||||
(Self::Dynamic, tunables.dynamic_memory_offset_guard_size)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +108,7 @@ pub enum TableStyle {
|
||||
impl TableStyle {
|
||||
/// Decide on an implementation style for the given `Table`.
|
||||
pub fn for_table(_table: Table, _tunables: &Tunables) -> Self {
|
||||
TableStyle::CallerChecksSignature
|
||||
Self::CallerChecksSignature
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -557,11 +557,11 @@ pub struct TargetSharedSignatureIndex(u32);
|
||||
impl TargetSharedSignatureIndex {
|
||||
/// Constructs `TargetSharedSignatureIndex`.
|
||||
pub fn new(value: u32) -> Self {
|
||||
TargetSharedSignatureIndex(value)
|
||||
Self(value)
|
||||
}
|
||||
|
||||
/// Returns index value.
|
||||
pub fn index(&self) -> u32 {
|
||||
pub fn index(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user