Disallow clippy::used_underscore_binding lint (#15988)

This commit is contained in:
Stefan Holderbach
2025-06-18 10:19:57 +02:00
committed by GitHub
parent 29b3512494
commit 70aa7ad993
4 changed files with 37 additions and 31 deletions

View File

@ -195,6 +195,7 @@ webpki-roots = "1.0"
# Warning: workspace lints affect library code as well as tests, so don't enable lints that would be too noisy in tests like that. # Warning: workspace lints affect library code as well as tests, so don't enable lints that would be too noisy in tests like that.
# todo = "warn" # todo = "warn"
unchecked_duration_subtraction = "warn" unchecked_duration_subtraction = "warn"
used_underscore_binding = "warn"
[lints] [lints]
workspace = true workspace = true

View File

@ -17,7 +17,7 @@ pub struct NuHighlighter {
} }
impl Highlighter for NuHighlighter { impl Highlighter for NuHighlighter {
fn highlight(&self, line: &str, _cursor: usize) -> StyledText { fn highlight(&self, line: &str, cursor: usize) -> StyledText {
trace!("highlighting: {}", line); trace!("highlighting: {}", line);
let config = self.stack.get_config(&self.engine_state); let config = self.stack.get_config(&self.engine_state);
@ -58,7 +58,7 @@ impl Highlighter for NuHighlighter {
let mut output = StyledText::default(); let mut output = StyledText::default();
let mut last_seen_span = global_span_offset; let mut last_seen_span = global_span_offset;
let global_cursor_offset = _cursor + global_span_offset; let global_cursor_offset = cursor + global_span_offset;
let matching_brackets_pos = find_matching_brackets( let matching_brackets_pos = find_matching_brackets(
line, line,
&working_set, &working_set,

View File

@ -142,7 +142,7 @@ fn into_binary(
} }
} }
fn action(input: &Value, _args: &Arguments, span: Span) -> Value { fn action(input: &Value, args: &Arguments, span: Span) -> Value {
let value = match input { let value = match input {
Value::Binary { .. } => input.clone(), Value::Binary { .. } => input.clone(),
Value::Int { val, .. } => Value::binary(val.to_ne_bytes().to_vec(), span), Value::Int { val, .. } => Value::binary(val.to_ne_bytes().to_vec(), span),
@ -168,7 +168,7 @@ fn action(input: &Value, _args: &Arguments, span: Span) -> Value {
), ),
}; };
if _args.compact { if args.compact {
let val_span = value.span(); let val_span = value.span();
if let Value::Binary { val, .. } = value { if let Value::Binary { val, .. } = value {
let val = if cfg!(target_endian = "little") { let val = if cfg!(target_endian = "little") {

View File

@ -422,29 +422,31 @@ fn mv_change_case_of_directory() {
let original_dir = String::from("somedir"); let original_dir = String::from("somedir");
let new_dir = String::from("SomeDir"); let new_dir = String::from("SomeDir");
let _actual = nu!( #[allow(unused)]
let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
format!("mv {original_dir} {new_dir}") format!("mv {original_dir} {new_dir}")
); );
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
{
// Doing this instead of `Path::exists()` because we need to check file existence in // Doing this instead of `Path::exists()` because we need to check file existence in
// a case-sensitive way. `Path::exists()` is understandably case-insensitive on NTFS // a case-sensitive way. `Path::exists()` is understandably case-insensitive on NTFS
let _files_in_test_directory: Vec<String> = std::fs::read_dir(dirs.test()) let files_in_test_directory: Vec<String> = std::fs::read_dir(dirs.test())
.unwrap() .unwrap()
.map(|de| de.unwrap().file_name().to_string_lossy().into_owned()) .map(|de| de.unwrap().file_name().to_string_lossy().into_owned())
.collect(); .collect();
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
assert!( assert!(
!_files_in_test_directory.contains(&original_dir) !files_in_test_directory.contains(&original_dir)
&& _files_in_test_directory.contains(&new_dir) && files_in_test_directory.contains(&new_dir)
); );
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
assert!(files_exist_at(&["somefile.txt"], dirs.test().join(new_dir))); assert!(files_exist_at(&["somefile.txt"], dirs.test().join(new_dir)));
}
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))] #[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
_actual.err.contains("to a subdirectory of itself"); actual.err.contains("to a subdirectory of itself");
}) })
} }
@ -458,24 +460,27 @@ fn mv_change_case_of_file() {
let original_file_name = String::from("somefile.txt"); let original_file_name = String::from("somefile.txt");
let new_file_name = String::from("SomeFile.txt"); let new_file_name = String::from("SomeFile.txt");
let _actual = nu!( #[allow(unused)]
let actual = nu!(
cwd: dirs.test(), cwd: dirs.test(),
format!("mv {original_file_name} -f {new_file_name}") format!("mv {original_file_name} -f {new_file_name}")
); );
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
{
// Doing this instead of `Path::exists()` because we need to check file existence in // Doing this instead of `Path::exists()` because we need to check file existence in
// a case-sensitive way. `Path::exists()` is understandably case-insensitive on NTFS // a case-sensitive way. `Path::exists()` is understandably case-insensitive on NTFS
let _files_in_test_directory: Vec<String> = std::fs::read_dir(dirs.test()) let files_in_test_directory: Vec<String> = std::fs::read_dir(dirs.test())
.unwrap() .unwrap()
.map(|de| de.unwrap().file_name().to_string_lossy().into_owned()) .map(|de| de.unwrap().file_name().to_string_lossy().into_owned())
.collect(); .collect();
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
assert!( assert!(
!_files_in_test_directory.contains(&original_file_name) !files_in_test_directory.contains(&original_file_name)
&& _files_in_test_directory.contains(&new_file_name) && files_in_test_directory.contains(&new_file_name)
); );
}
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))] #[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
_actual.err.contains("are the same file"); actual.err.contains("are the same file");
}) })
} }