diff --git a/crates/tinymist-analysis/src/syntax/matcher.rs b/crates/tinymist-analysis/src/syntax/matcher.rs index 3fc0ddb5..dcc87bf0 100644 --- a/crates/tinymist-analysis/src/syntax/matcher.rs +++ b/crates/tinymist-analysis/src/syntax/matcher.rs @@ -394,7 +394,7 @@ pub enum DefClass<'a> { impl DefClass<'_> { /// Gets the node of the def class. - pub fn node(&self) -> &LinkedNode { + pub fn node(&self) -> &LinkedNode<'_> { match self { DefClass::Let(node) => node, DefClass::Import(node) => node, @@ -402,7 +402,7 @@ impl DefClass<'_> { } /// Gets the name node of the def class. - pub fn name(&self) -> Option { + pub fn name(&self) -> Option> { match self { DefClass::Let(node) => { let lb: ast::LetBinding<'_> = node.cast()?; @@ -433,17 +433,17 @@ impl DefClass<'_> { // todo: whether we should distinguish between strict and loose def classes /// Classifies a definition loosely. -pub fn classify_def_loosely(node: LinkedNode) -> Option> { +pub fn classify_def_loosely(node: LinkedNode<'_>) -> Option> { classify_def_(node, false) } /// Classifies a definition strictly. -pub fn classify_def(node: LinkedNode) -> Option> { +pub fn classify_def(node: LinkedNode<'_>) -> Option> { classify_def_(node, true) } /// The internal implementation of classifying a definition. -fn classify_def_(node: LinkedNode, strict: bool) -> Option> { +fn classify_def_(node: LinkedNode<'_>, strict: bool) -> Option> { let mut ancestor = node; if ancestor.kind().is_trivia() || is_mark(ancestor.kind()) { ancestor = ancestor.prev_sibling()?; @@ -715,7 +715,7 @@ impl<'a> SyntaxClass<'a> { /// Classifies node's syntax (inner syntax) that can be operated on by IDE /// functionality. -pub fn classify_syntax(node: LinkedNode, cursor: usize) -> Option> { +pub fn classify_syntax(node: LinkedNode<'_>, cursor: usize) -> Option> { if matches!(node.kind(), SyntaxKind::Error) && node.text().starts_with('<') { return Some(SyntaxClass::error_as_label(node)); } @@ -1233,7 +1233,7 @@ pub fn classify_context_outer<'a>( /// Classifies node's context (outer syntax) that can be operated on by IDE /// functionality. -pub fn classify_context(node: LinkedNode, cursor: Option) -> Option> { +pub fn classify_context(node: LinkedNode<'_>, cursor: Option) -> Option> { let mut node = node; if node.kind().is_trivia() && node.parent_kind().is_some_and(possible_in_code_trivia) { loop { diff --git a/crates/tinymist-package/src/pack.rs b/crates/tinymist-package/src/pack.rs index b75273f0..158cdab1 100644 --- a/crates/tinymist-package/src/pack.rs +++ b/crates/tinymist-package/src/pack.rs @@ -72,11 +72,11 @@ pub trait PackFs: fmt::Debug { f: &mut (dyn FnMut(&str, PackFile) -> PackageResult<()> + Send + Sync), ) -> PackageResult<()>; /// Read a file from the package. - fn read(&self, _path: &str) -> io::Result { + fn read(&self, _path: &str) -> io::Result> { Err(unsupported()) } /// Read entries from the package. - fn entries(&self) -> io::Result { + fn entries(&self) -> io::Result> { Err(unsupported()) } } diff --git a/crates/tinymist-query/src/analysis/global.rs b/crates/tinymist-query/src/analysis/global.rs index 7ef34806..38b63955 100644 --- a/crates/tinymist-query/src/analysis/global.rs +++ b/crates/tinymist-query/src/analysis/global.rs @@ -420,7 +420,7 @@ impl LocalContext { } /// Fork a new context for searching in the workspace. - pub fn fork_for_search(&mut self) -> SearchCtx { + pub fn fork_for_search(&mut self) -> SearchCtx<'_> { SearchCtx { ctx: self, searched: Default::default(), diff --git a/crates/tinymist-render/src/lib.rs b/crates/tinymist-render/src/lib.rs index eabe0847..90865dc6 100644 --- a/crates/tinymist-render/src/lib.rs +++ b/crates/tinymist-render/src/lib.rs @@ -105,7 +105,8 @@ impl PeriscopeRenderer { let mut doc = UsingExporter::svg_doc(paged_doc); doc.module.prepare_glyphs(); let page0 = doc.pages.get(pos.page.get() - 1)?.clone(); - let mut svg_text = UsingExporter::render(&doc.module, &[page0.clone()], None); + let mut svg_text = + UsingExporter::render(&doc.module, std::slice::from_ref(&page0), None); // todo: let typst.ts expose it let svg_header = svg_text.get_mut(0)?; diff --git a/crates/tinymist-std/src/fs/flock.rs b/crates/tinymist-std/src/fs/flock.rs index 61093c48..e079db69 100644 --- a/crates/tinymist-std/src/fs/flock.rs +++ b/crates/tinymist-std/src/fs/flock.rs @@ -102,10 +102,10 @@ impl Write for FileLock { impl Drop for FileLock { fn drop(&mut self) { - if let Some(f) = self.f.take() { - if let Err(e) = unlock(&f) { - log::warn!("failed to release lock: {e:?}"); - } + if let Some(f) = self.f.take() + && let Err(e) = unlock(&f) + { + log::warn!("failed to release lock: {e:?}"); } } } diff --git a/crates/tinymist-std/src/fs/paths.rs b/crates/tinymist-std/src/fs/paths.rs index 9e6f7f7f..65ab8e56 100644 --- a/crates/tinymist-std/src/fs/paths.rs +++ b/crates/tinymist-std/src/fs/paths.rs @@ -360,10 +360,10 @@ impl<'a> Iterator for PathAncestors<'a> { if let Some(path) = self.current { self.current = path.parent(); - if let Some(ref stop_at) = self.stop_at { - if path == stop_at { - self.current = None; - } + if let Some(ref stop_at) = self.stop_at + && path == stop_at + { + self.current = None; } Some(path) @@ -668,11 +668,11 @@ pub fn create_dir_all_excluded_from_backups_atomic(p: impl AsRef) -> Resul // existing behavior. If we get an error at rename() and suddenly the // directory (which didn't exist a moment earlier) exists we can infer from // it's another cargo process doing work. - if let Err(e) = fs::rename(tempdir.path(), path) { - if !path.exists() { - return Err(anyhow::Error::from(e)) - .with_context(|| format!("failed to create directory `{}`", path.display())); - } + if let Err(e) = fs::rename(tempdir.path(), path) + && !path.exists() + { + return Err(anyhow::Error::from(e)) + .with_context(|| format!("failed to create directory `{}`", path.display())); } Ok(()) } diff --git a/crates/tinymist-vfs/src/lib.rs b/crates/tinymist-vfs/src/lib.rs index ba9c6588..8cf42d9a 100644 --- a/crates/tinymist-vfs/src/lib.rs +++ b/crates/tinymist-vfs/src/lib.rs @@ -324,7 +324,7 @@ impl Vfs { /// Obtains an object to revise. The object will update the original vfs /// when it is dropped. - pub fn revise(&mut self) -> RevisingVfs { + pub fn revise(&mut self) -> RevisingVfs<'_, M> { let managed = self.managed.lock().clone(); let paths = self.paths.lock().clone(); let goal_revision = self.revision.checked_add(1).expect("revision overflowed"); @@ -339,7 +339,7 @@ impl Vfs { } /// Obtains an object to display. - pub fn display(&self) -> DisplayVfs { + pub fn display(&self) -> DisplayVfs<'_, M> { DisplayVfs { inner: self } } @@ -604,7 +604,7 @@ impl EntryMap { } } - fn display(&self) -> DisplayEntryMap { + fn display(&self) -> DisplayEntryMap<'_> { DisplayEntryMap { map: self } } } @@ -660,7 +660,7 @@ impl PathMap { self.paths.get(path) } - fn display(&self) -> DisplayPathMap { + fn display(&self) -> DisplayPathMap<'_> { DisplayPathMap { map: self } } } diff --git a/crates/tinymist/src/task/export.rs b/crates/tinymist/src/task/export.rs index 11a3542b..d9bb4c94 100644 --- a/crates/tinymist/src/task/export.rs +++ b/crates/tinymist/src/task/export.rs @@ -141,7 +141,7 @@ impl ExportTask { pub(crate) fn signal( &self, snap: &LspCompiledArtifact, - client: &std::sync::Arc<(dyn ProjectClient + 'static)>, + client: &std::sync::Arc, ) { let config = self.factory.task(); @@ -153,7 +153,7 @@ impl ExportTask { &self, artifact: &LspCompiledArtifact, config: &Arc, - client: &std::sync::Arc<(dyn ProjectClient + 'static)>, + client: &std::sync::Arc, ) -> Option<()> { let doc = artifact.doc.as_ref()?; let s = artifact.snap.signal; diff --git a/crates/tinymist/src/tool/preview.rs b/crates/tinymist/src/tool/preview.rs index 9c90eb47..12ae0af6 100644 --- a/crates/tinymist/src/tool/preview.rs +++ b/crates/tinymist/src/tool/preview.rs @@ -325,7 +325,7 @@ impl ServerState { self.preview .start(cli_args, previewer, id, false, is_background) } else { - return Err(internal_error("entry file must be provided")); + Err(internal_error("entry file must be provided")) } } }