Clippy fixes for toolchain bump (#13497)

- **Suggested default impl for the new `*Stack`s**
- **Change a hashmap to make clippy happy**
- **Clone from fix**
- **Fix conditional unused in test**
- then **Bump rust toolchain**
This commit is contained in:
Stefan Holderbach 2024-07-31 14:49:22 +02:00 committed by GitHub
parent d2bf82d22b
commit 813aac89bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 16 deletions

View File

@ -321,16 +321,10 @@ mod test {
let env = engine_state.render_env_vars();
assert!(
matches!(env.get(&"FOO".to_string()), Some(&Value::String { val, .. }) if val == "foo")
);
assert!(
matches!(env.get(&"SYMBOLS".to_string()), Some(&Value::String { val, .. }) if val == symbols)
);
assert!(
matches!(env.get(&symbols.to_string()), Some(&Value::String { val, .. }) if val == "symbols")
);
assert!(env.get(&"PWD".to_string()).is_some());
assert!(matches!(env.get("FOO"), Some(&Value::String { val, .. }) if val == "foo"));
assert!(matches!(env.get("SYMBOLS"), Some(&Value::String { val, .. }) if val == symbols));
assert!(matches!(env.get(symbols), Some(&Value::String { val, .. }) if val == "symbols"));
assert!(env.contains_key("PWD"));
assert_eq!(env.len(), 4);
}
}

View File

@ -1,8 +1,10 @@
#[cfg(not(windows))]
use nu_path::AbsolutePath;
use nu_test_support::fs::{files_exist_at, Stub::EmptyFile};
use nu_test_support::nu;
use nu_test_support::playground::Playground;
use rstest::rstest;
#[cfg(not(windows))]
use std::fs;
use std::path::Path;
@ -405,16 +407,19 @@ fn removes_file_after_cd() {
})
}
#[cfg(not(windows))]
struct Cleanup<'a> {
dir_to_clean: &'a AbsolutePath,
}
#[cfg(not(windows))]
fn set_dir_read_only(directory: &AbsolutePath, read_only: bool) {
let mut permissions = fs::metadata(directory).unwrap().permissions();
permissions.set_readonly(read_only);
fs::set_permissions(directory, permissions).expect("failed to set directory permissions");
}
#[cfg(not(windows))]
impl<'a> Drop for Cleanup<'a> {
/// Restores write permissions to the given directory so that the Playground can be successfully
/// cleaned up.

View File

@ -198,7 +198,7 @@ pub fn redirect_env(engine_state: &EngineState, caller_stack: &mut Stack, callee
}
// set config to callee config, to capture any updates to that
caller_stack.config = callee_stack.config.clone();
caller_stack.config.clone_from(&callee_stack.config);
}
fn eval_external(

View File

@ -71,7 +71,7 @@ impl Argument {
}
/// Stores the argument context for calls in IR evaluation.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ArgumentStack {
arguments: Vec<Argument>,
}

View File

@ -428,13 +428,13 @@ impl EngineState {
.1
}
pub fn render_env_vars(&self) -> HashMap<&String, &Value> {
let mut result = HashMap::new();
pub fn render_env_vars(&self) -> HashMap<&str, &Value> {
let mut result: HashMap<&str, &Value> = HashMap::new();
for overlay_name in self.active_overlay_names(&[]) {
let name = String::from_utf8_lossy(overlay_name);
if let Some(env_vars) = self.env_vars.get(name.as_ref()) {
result.extend(env_vars);
result.extend(env_vars.iter().map(|(k, v)| (k.as_str(), v)));
}
}

View File

@ -10,7 +10,7 @@ pub struct ErrorHandler {
}
/// Keeps track of error handlers pushed during evaluation of an IR block.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ErrorHandlerStack {
handlers: Vec<ErrorHandler>,
}