chore: clean up clippy lints (#11377)
Using clippy 1.80.0. Also cleans up some that were windows only.
This commit is contained in:
parent
3fcf168c33
commit
86aecc96a1
13 changed files with 46 additions and 41 deletions
|
@ -75,9 +75,9 @@ impl From<(&char, &char)> for Pair {
|
||||||
|
|
||||||
impl AutoPairs {
|
impl AutoPairs {
|
||||||
/// Make a new AutoPairs set with the given pairs and default conditions.
|
/// Make a new AutoPairs set with the given pairs and default conditions.
|
||||||
pub fn new<'a, V: 'a, A>(pairs: V) -> Self
|
pub fn new<'a, V, A>(pairs: V) -> Self
|
||||||
where
|
where
|
||||||
V: IntoIterator<Item = A>,
|
V: IntoIterator<Item = A> + 'a,
|
||||||
A: Into<Pair>,
|
A: Into<Pair>,
|
||||||
{
|
{
|
||||||
let mut auto_pairs = HashMap::new();
|
let mut auto_pairs = HashMap::new();
|
||||||
|
|
|
@ -457,7 +457,7 @@ fn query_indents<'a>(
|
||||||
// Skip matches where not all custom predicates are fulfilled
|
// Skip matches where not all custom predicates are fulfilled
|
||||||
if !query.general_predicates(m.pattern_index).iter().all(|pred| {
|
if !query.general_predicates(m.pattern_index).iter().all(|pred| {
|
||||||
match pred.operator.as_ref() {
|
match pred.operator.as_ref() {
|
||||||
"not-kind-eq?" => match (pred.args.get(0), pred.args.get(1)) {
|
"not-kind-eq?" => match (pred.args.first(), pred.args.get(1)) {
|
||||||
(
|
(
|
||||||
Some(QueryPredicateArg::Capture(capture_idx)),
|
Some(QueryPredicateArg::Capture(capture_idx)),
|
||||||
Some(QueryPredicateArg::String(kind)),
|
Some(QueryPredicateArg::String(kind)),
|
||||||
|
@ -473,7 +473,7 @@ fn query_indents<'a>(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"same-line?" | "not-same-line?" => {
|
"same-line?" | "not-same-line?" => {
|
||||||
match (pred.args.get(0), pred.args.get(1)) {
|
match (pred.args.first(), pred.args.get(1)) {
|
||||||
(
|
(
|
||||||
Some(QueryPredicateArg::Capture(capt1)),
|
Some(QueryPredicateArg::Capture(capt1)),
|
||||||
Some(QueryPredicateArg::Capture(capt2))
|
Some(QueryPredicateArg::Capture(capt2))
|
||||||
|
@ -495,7 +495,7 @@ fn query_indents<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"one-line?" | "not-one-line?" => match pred.args.get(0) {
|
"one-line?" | "not-one-line?" => match pred.args.first() {
|
||||||
Some(QueryPredicateArg::Capture(capture_idx)) => {
|
Some(QueryPredicateArg::Capture(capture_idx)) => {
|
||||||
let node = m.nodes_for_capture_index(*capture_idx).next();
|
let node = m.nodes_for_capture_index(*capture_idx).next();
|
||||||
|
|
||||||
|
@ -786,6 +786,7 @@ fn init_indent_query<'a, 'b>(
|
||||||
/// - The line after the node. This is defined by:
|
/// - The line after the node. This is defined by:
|
||||||
/// - The scope `tail`.
|
/// - The scope `tail`.
|
||||||
/// - The scope `all` if this node is not the first node on its line.
|
/// - The scope `all` if this node is not the first node on its line.
|
||||||
|
///
|
||||||
/// Intuitively, `all` applies to everything contained in this node while `tail` applies to everything except for the first line of the node.
|
/// Intuitively, `all` applies to everything contained in this node while `tail` applies to everything except for the first line of the node.
|
||||||
/// The indents from different nodes for the same line are then combined.
|
/// The indents from different nodes for the same line are then combined.
|
||||||
/// The result [Indentation] is simply the sum of the [Indentation] for all lines.
|
/// The result [Indentation] is simply the sum of the [Indentation] for all lines.
|
||||||
|
|
|
@ -1431,8 +1431,11 @@ impl Syntax {
|
||||||
// The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
|
// The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
|
||||||
// prevents them from being moved. But both of these values are really just
|
// prevents them from being moved. But both of these values are really just
|
||||||
// pointers, so it's actually ok to move them.
|
// pointers, so it's actually ok to move them.
|
||||||
let cursor_ref =
|
let cursor_ref = unsafe {
|
||||||
unsafe { mem::transmute::<_, &'static mut QueryCursor>(&mut cursor) };
|
mem::transmute::<&mut tree_sitter::QueryCursor, &mut tree_sitter::QueryCursor>(
|
||||||
|
&mut cursor,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
// if reusing cursors & no range this resets to whole range
|
// if reusing cursors & no range this resets to whole range
|
||||||
cursor_ref.set_byte_range(range.clone().unwrap_or(0..usize::MAX));
|
cursor_ref.set_byte_range(range.clone().unwrap_or(0..usize::MAX));
|
||||||
|
@ -1737,7 +1740,7 @@ pub(crate) fn generate_edits(
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::{iter, mem, ops, str, usize};
|
use std::{iter, mem, ops, str};
|
||||||
use tree_sitter::{
|
use tree_sitter::{
|
||||||
Language as Grammar, Node, Parser, Point, Query, QueryCaptures, QueryCursor, QueryError,
|
Language as Grammar, Node, Parser, Point, Query, QueryCaptures, QueryCursor, QueryError,
|
||||||
QueryMatch, Range, TextProvider, Tree,
|
QueryMatch, Range, TextProvider, Tree,
|
||||||
|
|
|
@ -295,21 +295,21 @@ mod imp {
|
||||||
let mut privileges_length = std::mem::size_of::<PRIVILEGE_SET>() as u32;
|
let mut privileges_length = std::mem::size_of::<PRIVILEGE_SET>() as u32;
|
||||||
let mut result = 0;
|
let mut result = 0;
|
||||||
|
|
||||||
let mut mapping = GENERIC_MAPPING {
|
let mapping = GENERIC_MAPPING {
|
||||||
GenericRead: FILE_GENERIC_READ,
|
GenericRead: FILE_GENERIC_READ,
|
||||||
GenericWrite: FILE_GENERIC_WRITE,
|
GenericWrite: FILE_GENERIC_WRITE,
|
||||||
GenericExecute: FILE_GENERIC_EXECUTE,
|
GenericExecute: FILE_GENERIC_EXECUTE,
|
||||||
GenericAll: FILE_ALL_ACCESS,
|
GenericAll: FILE_ALL_ACCESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe { MapGenericMask(&mut mode, &mut mapping) };
|
unsafe { MapGenericMask(&mut mode, &mapping) };
|
||||||
|
|
||||||
if unsafe {
|
if unsafe {
|
||||||
AccessCheck(
|
AccessCheck(
|
||||||
*sd.descriptor(),
|
*sd.descriptor(),
|
||||||
*token.as_handle(),
|
*token.as_handle(),
|
||||||
mode,
|
mode,
|
||||||
&mut mapping,
|
&mapping,
|
||||||
&mut privileges,
|
&mut privileges,
|
||||||
&mut privileges_length,
|
&mut privileges_length,
|
||||||
&mut granted_access,
|
&mut granted_access,
|
||||||
|
|
|
@ -66,18 +66,16 @@ mod windows_rc {
|
||||||
.output();
|
.output();
|
||||||
|
|
||||||
match find_reg_key {
|
match find_reg_key {
|
||||||
Err(find_reg_key) => {
|
Err(find_reg_key) => Err(io::Error::new(
|
||||||
return Err(io::Error::new(
|
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
format!("Failed to run registry query: {}", find_reg_key),
|
format!("Failed to run registry query: {}", find_reg_key),
|
||||||
))
|
)),
|
||||||
}
|
|
||||||
Ok(find_reg_key) => {
|
Ok(find_reg_key) => {
|
||||||
if find_reg_key.status.code().unwrap() != 0 {
|
if find_reg_key.status.code().unwrap() != 0 {
|
||||||
return Err(io::Error::new(
|
Err(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
"Can not find Windows SDK",
|
"Can not find Windows SDK",
|
||||||
));
|
))
|
||||||
} else {
|
} else {
|
||||||
let lines = String::from_utf8(find_reg_key.stdout)
|
let lines = String::from_utf8(find_reg_key.stdout)
|
||||||
.expect("Should be able to parse the output");
|
.expect("Should be able to parse the output");
|
||||||
|
|
|
@ -35,7 +35,9 @@ use log::{debug, error, info, warn};
|
||||||
use std::io::stdout;
|
use std::io::stdout;
|
||||||
use std::{collections::btree_map::Entry, io::stdin, path::Path, sync::Arc};
|
use std::{collections::btree_map::Entry, io::stdin, path::Path, sync::Arc};
|
||||||
|
|
||||||
use anyhow::{Context, Error};
|
#[cfg(not(windows))]
|
||||||
|
use anyhow::Context;
|
||||||
|
use anyhow::Error;
|
||||||
|
|
||||||
use crossterm::{event::Event as CrosstermEvent, tty::IsTty};
|
use crossterm::{event::Event as CrosstermEvent, tty::IsTty};
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|
|
@ -34,7 +34,7 @@ use crate::{
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::{BTreeMap, HashSet},
|
collections::{BTreeMap, HashSet},
|
||||||
fmt::Write,
|
fmt::{Display, Write},
|
||||||
future::Future,
|
future::Future,
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
@ -832,13 +832,13 @@ pub enum ApplyEditErrorKind {
|
||||||
// InvalidEdit,
|
// InvalidEdit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for ApplyEditErrorKind {
|
impl Display for ApplyEditErrorKind {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ApplyEditErrorKind::DocumentChanged => "document has changed".to_string(),
|
ApplyEditErrorKind::DocumentChanged => f.write_str("document has changed"),
|
||||||
ApplyEditErrorKind::FileNotFound => "file not found".to_string(),
|
ApplyEditErrorKind::FileNotFound => f.write_str("file not found"),
|
||||||
ApplyEditErrorKind::UnknownURISchema => "URI schema not supported".to_string(),
|
ApplyEditErrorKind::UnknownURISchema => f.write_str("URI schema not supported"),
|
||||||
ApplyEditErrorKind::IoError(err) => err.to_string(),
|
ApplyEditErrorKind::IoError(err) => f.write_str(&format!("{err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2498,7 +2498,7 @@ fn read(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
|
||||||
ensure!(!args.is_empty(), "file name is expected");
|
ensure!(!args.is_empty(), "file name is expected");
|
||||||
ensure!(args.len() == 1, "only the file name is expected");
|
ensure!(args.len() == 1, "only the file name is expected");
|
||||||
|
|
||||||
let filename = args.get(0).unwrap();
|
let filename = args.first().unwrap();
|
||||||
let path = PathBuf::from(filename.to_string());
|
let path = PathBuf::from(filename.to_string());
|
||||||
ensure!(
|
ensure!(
|
||||||
path.exists() && path.is_file(),
|
path.exists() && path.is_file(),
|
||||||
|
|
|
@ -117,10 +117,9 @@ FLAGS:
|
||||||
setup_logging(args.verbosity).context("failed to initialize logging")?;
|
setup_logging(args.verbosity).context("failed to initialize logging")?;
|
||||||
|
|
||||||
// Before setting the working directory, resolve all the paths in args.files
|
// Before setting the working directory, resolve all the paths in args.files
|
||||||
for (path, _) in args.files.iter_mut() {
|
for (path, _) in &mut args.files {
|
||||||
*path = helix_stdx::path::canonicalize(&path);
|
*path = helix_stdx::path::canonicalize(&*path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Set the working directory early so the correct configuration is loaded. Be aware that
|
// NOTE: Set the working directory early so the correct configuration is loaded. Be aware that
|
||||||
// Application::new() depends on this logic so it must be updated if this changes.
|
// Application::new() depends on this logic so it must be updated if this changes.
|
||||||
if let Some(path) = &args.working_directory {
|
if let Some(path) = &args.working_directory {
|
||||||
|
|
|
@ -1245,7 +1245,7 @@ impl Document {
|
||||||
/// Initializes a new selection and view_data for the given view
|
/// Initializes a new selection and view_data for the given view
|
||||||
/// if it does not already have them.
|
/// if it does not already have them.
|
||||||
pub fn ensure_view_init(&mut self, view_id: ViewId) {
|
pub fn ensure_view_init(&mut self, view_id: ViewId) {
|
||||||
if self.selections.get(&view_id).is_none() {
|
if !self.selections.contains_key(&view_id) {
|
||||||
self.reset_selection(view_id);
|
self.reset_selection(view_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub async fn select_thread_id(editor: &mut Editor, thread_id: ThreadId, force: b
|
||||||
debugger.thread_id = Some(thread_id);
|
debugger.thread_id = Some(thread_id);
|
||||||
fetch_stack_trace(debugger, thread_id).await;
|
fetch_stack_trace(debugger, thread_id).await;
|
||||||
|
|
||||||
let frame = debugger.stack_frames[&thread_id].get(0).cloned();
|
let frame = debugger.stack_frames[&thread_id].first().cloned();
|
||||||
if let Some(frame) = &frame {
|
if let Some(frame) = &frame {
|
||||||
jump_to_stack_frame(editor, frame);
|
jump_to_stack_frame(editor, frame);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use crate::editor::Action;
|
use crate::editor::Action;
|
||||||
use crate::Editor;
|
use crate::Editor;
|
||||||
use crate::{DocumentId, ViewId};
|
use crate::{DocumentId, ViewId};
|
||||||
|
@ -73,13 +75,13 @@ impl From<helix_core::uri::UrlConversionError> for ApplyEditErrorKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for ApplyEditErrorKind {
|
impl Display for ApplyEditErrorKind {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ApplyEditErrorKind::DocumentChanged => "document has changed".to_string(),
|
ApplyEditErrorKind::DocumentChanged => f.write_str("document has changed"),
|
||||||
ApplyEditErrorKind::FileNotFound => "file not found".to_string(),
|
ApplyEditErrorKind::FileNotFound => f.write_str("file not found"),
|
||||||
ApplyEditErrorKind::InvalidUrl(err) => err.to_string(),
|
ApplyEditErrorKind::InvalidUrl(err) => f.write_str(&format!("{err}")),
|
||||||
ApplyEditErrorKind::IoError(err) => err.to_string(),
|
ApplyEditErrorKind::IoError(err) => f.write_str(&format!("{err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue