mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 18:28:02 +00:00
fix: clippy error in rust 1.84 and deny warnings in CI (#1178)
* fix: clippy error in 1.84 * fix: deny warnings * fix: clippy warnings and doc errors * fix: warnings * fix: warnings * fix: warnings * fix: compile error
This commit is contained in:
parent
31b22d9333
commit
448ce484d8
12 changed files with 30 additions and 30 deletions
3
.github/workflows/release-vscode.yml
vendored
3
.github/workflows/release-vscode.yml
vendored
|
@ -15,6 +15,7 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
RUSTFLAGS: '-Dwarnings'
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
||||
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
|
||||
|
||||
|
@ -311,7 +312,7 @@ jobs:
|
|||
env:
|
||||
target: alpine-x64
|
||||
RUST_TARGET: x86_64-unknown-linux-musl
|
||||
RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
|
||||
RUSTFLAGS: "-Dwarnings -C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
steps:
|
||||
|
|
|
@ -199,7 +199,7 @@ impl Filesystem {
|
|||
/// This function will create a file at `path` if it doesn't already exist
|
||||
/// (including intermediate directories), and then it will acquire an
|
||||
/// exclusive lock on `path`. If the process must block waiting for the
|
||||
/// lock, the `msg` is printed to [`GlobalContext`].
|
||||
/// lock, the `msg` is printed to stderr.
|
||||
///
|
||||
/// The returned file can be accessed to look at the path and also has
|
||||
/// read/write access to the underlying file.
|
||||
|
@ -239,7 +239,7 @@ impl Filesystem {
|
|||
///
|
||||
/// This function will fail if `path` doesn't already exist, but if it does
|
||||
/// then it will acquire a shared lock on `path`. If the process must block
|
||||
/// waiting for the lock, the `msg` is printed to [`GlobalContext`].
|
||||
/// waiting for the lock, the `msg` is printed to stderr.
|
||||
///
|
||||
/// The returned file can be accessed to look at the path and also has read
|
||||
/// access to the underlying file. Any writes to the file will return an
|
||||
|
@ -389,6 +389,7 @@ fn is_on_nfs_mount(path: &Path) -> bool {
|
|||
return false;
|
||||
};
|
||||
|
||||
// SAFETY: this is implemented by the cargo
|
||||
unsafe {
|
||||
let mut buf: libc::statfs = mem::zeroed();
|
||||
let r = libc::statfs(path.as_ptr(), &mut buf);
|
||||
|
@ -429,7 +430,7 @@ mod sys {
|
|||
}
|
||||
|
||||
pub(super) fn error_contended(err: &Error) -> bool {
|
||||
err.raw_os_error().map_or(false, |x| x == libc::EWOULDBLOCK)
|
||||
err.raw_os_error() == Some(libc::EWOULDBLOCK)
|
||||
}
|
||||
|
||||
pub(super) fn error_unsupported(err: &Error) -> bool {
|
||||
|
@ -445,6 +446,7 @@ mod sys {
|
|||
|
||||
#[cfg(not(target_os = "solaris"))]
|
||||
fn flock(file: &File, flag: libc::c_int) -> Result<()> {
|
||||
// SAFETY: this is implemented by the cargo
|
||||
let ret = unsafe { libc::flock(file.as_raw_fd(), flag) };
|
||||
if ret < 0 {
|
||||
Err(Error::last_os_error())
|
||||
|
@ -520,13 +522,11 @@ mod sys {
|
|||
}
|
||||
|
||||
pub(super) fn error_contended(err: &Error) -> bool {
|
||||
err.raw_os_error()
|
||||
.map_or(false, |x| x == ERROR_LOCK_VIOLATION as i32)
|
||||
err.raw_os_error() == Some(ERROR_LOCK_VIOLATION as i32)
|
||||
}
|
||||
|
||||
pub(super) fn error_unsupported(err: &Error) -> bool {
|
||||
err.raw_os_error()
|
||||
.map_or(false, |x| x == ERROR_INVALID_FUNCTION as i32)
|
||||
err.raw_os_error() == Some(ERROR_INVALID_FUNCTION as i32)
|
||||
}
|
||||
|
||||
pub(super) fn unlock(file: &File) -> Result<()> {
|
||||
|
|
|
@ -195,6 +195,7 @@ pub fn write_atomic<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Res
|
|||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
// these constants are u16 on macOS
|
||||
#[allow(clippy::useless_conversion)]
|
||||
let mask = u32::from(libc::S_IRWXU | libc::S_IRWXG | libc::S_IRWXO);
|
||||
let mode = meta.permissions().mode() & mask;
|
||||
|
||||
|
@ -782,9 +783,9 @@ mod tests {
|
|||
fn write_atomic_permissions() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let original_perms = std::fs::Permissions::from_mode(u32::from(
|
||||
libc::S_IRWXU | libc::S_IRGRP | libc::S_IWGRP | libc::S_IROTH,
|
||||
));
|
||||
#[allow(clippy::useless_conversion)]
|
||||
let perms = u32::from(libc::S_IRWXU | libc::S_IRGRP | libc::S_IWGRP | libc::S_IROTH);
|
||||
let original_perms = std::fs::Permissions::from_mode(perms);
|
||||
|
||||
let tmp = tempfile::Builder::new().tempfile().unwrap();
|
||||
|
||||
|
@ -800,6 +801,7 @@ mod tests {
|
|||
|
||||
let new_perms = std::fs::metadata(tmp.path()).unwrap().permissions();
|
||||
|
||||
#[allow(clippy::useless_conversion)]
|
||||
let mask = u32::from(libc::S_IRWXU | libc::S_IRWXG | libc::S_IRWXO);
|
||||
assert_eq!(original_perms.mode(), new_perms.mode() & mask);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub enum TaskWhen {
|
|||
OnSave,
|
||||
/// Run task on type.
|
||||
OnType,
|
||||
/// [DEPRECATED] Run task when a document has a title and on saved, which is
|
||||
/// *DEPRECATED* Run task when a document has a title and on saved, which is
|
||||
/// useful to filter out template files.
|
||||
///
|
||||
/// Note: this is deprecating.
|
||||
|
@ -86,7 +86,7 @@ display_possible_values!(PdfStandard);
|
|||
/// `CompileCommand.pages` argument, through the `FromStr` trait instead of a
|
||||
/// value parser, in order to generate better errors.
|
||||
///
|
||||
/// See also: https://github.com/clap-rs/clap/issues/5065
|
||||
/// See also: <https://github.com/clap-rs/clap/issues/5065>
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Pages(pub RangeInclusive<Option<NonZeroUsize>>);
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ impl FnCompletionFeat {
|
|||
let pos_size = sig.positional_params().len();
|
||||
self.has_rest = self.has_rest || sig.rest_param().is_some();
|
||||
self.next_arg_is_content =
|
||||
self.next_arg_is_content || sig.pos(idx).map_or(false, |ty| ty.is_content(&()));
|
||||
self.next_arg_is_content || sig.pos(idx).is_some_and(|ty| ty.is_content(&()));
|
||||
let name_size = sig.named_params().len();
|
||||
let left_pos = pos_size.saturating_sub(idx);
|
||||
self.min_pos = self
|
||||
|
|
|
@ -617,7 +617,7 @@ fn token_from_ident(ei: &ExprInfo, ident: &LinkedNode, modifier: &mut ModifierSe
|
|||
let next = ident.next_leaf();
|
||||
let next_is_adjacent = next
|
||||
.as_ref()
|
||||
.map_or(false, |n| n.range().start == ident.range().end);
|
||||
.is_some_and(|n| n.range().start == ident.range().end);
|
||||
let next_parent = next.as_ref().and_then(|n| n.parent_kind());
|
||||
let next_kind = next.map(|n| n.kind());
|
||||
let lexical_function_call = next_is_adjacent
|
||||
|
@ -699,7 +699,7 @@ fn ns(modifier: &mut ModifierSet) -> TokenType {
|
|||
fn get_expr_following_hashtag<'a>(hashtag: &LinkedNode<'a>) -> Option<LinkedNode<'a>> {
|
||||
hashtag
|
||||
.next_sibling()
|
||||
.filter(|next| next.cast::<ast::Expr>().map_or(false, |expr| expr.hash()))
|
||||
.filter(|next| next.cast::<ast::Expr>().is_some_and(|expr| expr.hash()))
|
||||
.and_then(|node| node.leftmost_leaf())
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ impl RenameFileWorker<'_> {
|
|||
fn rename_module_path(&mut self, span: Span, r: &RefExpr, src: &Source) -> Option<TextEdit> {
|
||||
let importing = r.root.as_ref()?.file_id();
|
||||
|
||||
if importing.map_or(true, |fid| fid != self.def_fid) {
|
||||
if importing != Some(self.def_fid) {
|
||||
return None;
|
||||
}
|
||||
crate::log_debug_ct!("import: {span:?} -> {importing:?} v.s. {:?}", self.def_fid);
|
||||
|
|
|
@ -188,7 +188,7 @@ impl ExprInfo {
|
|||
let of = Expr::Decl(decl.clone());
|
||||
self.exports
|
||||
.get(decl.name())
|
||||
.map_or(false, |export| match export {
|
||||
.is_some_and(|export| match export {
|
||||
Expr::Ref(ref_expr) => ref_expr.root == Some(of),
|
||||
exprt => *exprt == of,
|
||||
})
|
||||
|
|
|
@ -279,8 +279,7 @@ pub fn interpret_mode_at(mut leaf: Option<&LinkedNode>) -> InterpretMode {
|
|||
|
||||
if !t.kind().is_trivia() && {
|
||||
// Previous leaf is hash
|
||||
t.prev_leaf()
|
||||
.map_or(false, |n| n.kind() == SyntaxKind::Hash)
|
||||
t.prev_leaf().is_some_and(|n| n.kind() == SyntaxKind::Hash)
|
||||
} {
|
||||
return InterpretMode::Code;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
use std::borrow::Cow;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
use std::sync::{Arc, LazyLock};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
ops::Range,
|
||||
|
@ -397,6 +397,8 @@ fn pos(v: &Value) -> String {
|
|||
|
||||
impl Redact for RedactFields {
|
||||
fn redact(&self, json_val: Value) -> Value {
|
||||
static REG: LazyLock<regex::Regex> =
|
||||
LazyLock::new(|| regex::Regex::new(r#"data:image/svg\+xml;base64,([^"]+)"#).unwrap());
|
||||
match json_val {
|
||||
Value::Object(mut map) => {
|
||||
for (_, val) in map.iter_mut() {
|
||||
|
@ -432,11 +434,7 @@ impl Redact for RedactFields {
|
|||
}
|
||||
"contents" => {
|
||||
let res = t.as_str().unwrap();
|
||||
static REG: OnceLock<regex::Regex> = OnceLock::new();
|
||||
let reg = REG.get_or_init(|| {
|
||||
regex::Regex::new(r#"data:image/svg\+xml;base64,([^"]+)"#).unwrap()
|
||||
});
|
||||
let res = reg.replace_all(res, |_captures: ®ex::Captures| {
|
||||
let res = REG.replace_all(res, |_captures: ®ex::Captures| {
|
||||
"data:image-hash/svg+xml;base64,redacted"
|
||||
});
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ impl PathPreference {
|
|||
|
||||
pub fn is_match(&self, path: &Path) -> bool {
|
||||
let ext = path.extension().and_then(|ext| ext.to_str());
|
||||
ext.map_or(false, |ext| self.ext_matcher().is_match(ext))
|
||||
ext.is_some_and(|ext| self.ext_matcher().is_match(ext))
|
||||
}
|
||||
|
||||
pub fn from_ext(path: &str) -> Option<Self> {
|
||||
|
|
|
@ -765,9 +765,9 @@ impl LanguageState {
|
|||
|
||||
fn completion(&mut self, req_id: RequestId, params: CompletionParams) -> ScheduledResult {
|
||||
let (path, position) = as_path_pos(params.text_document_position);
|
||||
let explicit = params.context.as_ref().map_or(false, |context| {
|
||||
context.trigger_kind == CompletionTriggerKind::INVOKED
|
||||
});
|
||||
let context = params.context.as_ref();
|
||||
let explicit =
|
||||
context.is_some_and(|context| context.trigger_kind == CompletionTriggerKind::INVOKED);
|
||||
let trigger_character = params
|
||||
.context
|
||||
.and_then(|c| c.trigger_character)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue