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:
parent
d2bf82d22b
commit
813aac89bd
|
@ -321,16 +321,10 @@ mod test {
|
||||||
|
|
||||||
let env = engine_state.render_env_vars();
|
let env = engine_state.render_env_vars();
|
||||||
|
|
||||||
assert!(
|
assert!(matches!(env.get("FOO"), Some(&Value::String { val, .. }) if val == "foo"));
|
||||||
matches!(env.get(&"FOO".to_string()), 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!(
|
assert!(env.contains_key("PWD"));
|
||||||
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_eq!(env.len(), 4);
|
assert_eq!(env.len(), 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
#[cfg(not(windows))]
|
||||||
use nu_path::AbsolutePath;
|
use nu_path::AbsolutePath;
|
||||||
use nu_test_support::fs::{files_exist_at, Stub::EmptyFile};
|
use nu_test_support::fs::{files_exist_at, Stub::EmptyFile};
|
||||||
use nu_test_support::nu;
|
use nu_test_support::nu;
|
||||||
use nu_test_support::playground::Playground;
|
use nu_test_support::playground::Playground;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
#[cfg(not(windows))]
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -405,16 +407,19 @@ fn removes_file_after_cd() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
struct Cleanup<'a> {
|
struct Cleanup<'a> {
|
||||||
dir_to_clean: &'a AbsolutePath,
|
dir_to_clean: &'a AbsolutePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn set_dir_read_only(directory: &AbsolutePath, read_only: bool) {
|
fn set_dir_read_only(directory: &AbsolutePath, read_only: bool) {
|
||||||
let mut permissions = fs::metadata(directory).unwrap().permissions();
|
let mut permissions = fs::metadata(directory).unwrap().permissions();
|
||||||
permissions.set_readonly(read_only);
|
permissions.set_readonly(read_only);
|
||||||
fs::set_permissions(directory, permissions).expect("failed to set directory permissions");
|
fs::set_permissions(directory, permissions).expect("failed to set directory permissions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
impl<'a> Drop for Cleanup<'a> {
|
impl<'a> Drop for Cleanup<'a> {
|
||||||
/// Restores write permissions to the given directory so that the Playground can be successfully
|
/// Restores write permissions to the given directory so that the Playground can be successfully
|
||||||
/// cleaned up.
|
/// cleaned up.
|
||||||
|
|
|
@ -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
|
// 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(
|
fn eval_external(
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl Argument {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores the argument context for calls in IR evaluation.
|
/// Stores the argument context for calls in IR evaluation.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ArgumentStack {
|
pub struct ArgumentStack {
|
||||||
arguments: Vec<Argument>,
|
arguments: Vec<Argument>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,13 +428,13 @@ impl EngineState {
|
||||||
.1
|
.1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_env_vars(&self) -> HashMap<&String, &Value> {
|
pub fn render_env_vars(&self) -> HashMap<&str, &Value> {
|
||||||
let mut result = HashMap::new();
|
let mut result: HashMap<&str, &Value> = HashMap::new();
|
||||||
|
|
||||||
for overlay_name in self.active_overlay_names(&[]) {
|
for overlay_name in self.active_overlay_names(&[]) {
|
||||||
let name = String::from_utf8_lossy(overlay_name);
|
let name = String::from_utf8_lossy(overlay_name);
|
||||||
if let Some(env_vars) = self.env_vars.get(name.as_ref()) {
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub struct ErrorHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Keeps track of error handlers pushed during evaluation of an IR block.
|
/// Keeps track of error handlers pushed during evaluation of an IR block.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ErrorHandlerStack {
|
pub struct ErrorHandlerStack {
|
||||||
handlers: Vec<ErrorHandler>,
|
handlers: Vec<ErrorHandler>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user