From e1422bb976e2761577c8e570e7641ee27b500ab5 Mon Sep 17 00:00:00 2001 From: Domenic Quirl Date: Tue, 20 Aug 2024 20:12:41 +0200 Subject: [PATCH] make clippy happy --- cstree/src/getting_started.rs | 10 +++++----- cstree/src/green/element.rs | 4 ++-- cstree/src/lib.rs | 16 ++++++++++------ cstree/src/syntax/node.rs | 1 + 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cstree/src/getting_started.rs b/cstree/src/getting_started.rs index 1cec620..bf75495 100644 --- a/cstree/src/getting_started.rs +++ b/cstree/src/getting_started.rs @@ -4,15 +4,15 @@ //! to happen to go from input text to a `cstree` syntax tree: //! //! 1. Define an enumeration of the types of tokens (like keywords) and nodes (like "an expression") that you want to -//! have in your syntax and implement [`Syntax`] +//! have in your syntax and implement [`Syntax`] //! //! 2. Create a [`GreenNodeBuilder`](crate::build::GreenNodeBuilder) and call -//! [`start_node`](crate::build::GreenNodeBuilder::start_node), [`token`](crate::build::GreenNodeBuilder::token) and -//! [`finish_node`](crate::build::GreenNodeBuilder::finish_node) from your parser +//! [`start_node`](crate::build::GreenNodeBuilder::start_node), [`token`](crate::build::GreenNodeBuilder::token) and +//! [`finish_node`](crate::build::GreenNodeBuilder::finish_node) from your parser //! //! 3. Call [`SyntaxNode::new_root`](crate::syntax::SyntaxNode::new_root) or -//! [`SyntaxNode::new_root_with_resolver`](crate::syntax::SyntaxNode::new_root_with_resolver) with the resulting -//! [`GreenNode`](crate::green::GreenNode) to obtain a syntax tree that you can traverse +//! [`SyntaxNode::new_root_with_resolver`](crate::syntax::SyntaxNode::new_root_with_resolver) with the resulting +//! [`GreenNode`](crate::green::GreenNode) to obtain a syntax tree that you can traverse //! //! Let's walk through the motions of parsing a (very) simple language into `cstree` syntax trees. //! We'll just support addition and subtraction on integers, from which the user is allowed to construct a single, diff --git a/cstree/src/green/element.rs b/cstree/src/green/element.rs index 9298551..6387b35 100644 --- a/cstree/src/green/element.rs +++ b/cstree/src/green/element.rs @@ -131,7 +131,7 @@ impl PackedGreenElement { pub(crate) fn into_node(self) -> Option { if self.is_node() { - unsafe { Some(mem::transmute(self)) } + unsafe { Some(mem::transmute::(self)) } } else { None } @@ -147,7 +147,7 @@ impl PackedGreenElement { pub(crate) fn into_token(self) -> Option { if !self.is_node() { - unsafe { Some(mem::transmute(self)) } + unsafe { Some(mem::transmute::(self)) } } else { None } diff --git a/cstree/src/lib.rs b/cstree/src/lib.rs index 094eddf..74d5b78 100644 --- a/cstree/src/lib.rs +++ b/cstree/src/lib.rs @@ -58,15 +58,15 @@ //! to happen to go from input text to a `cstree` syntax tree: //! //! 1. Define an enumeration of the types of tokens (like keywords) and nodes (like "an expression") that you want to -//! have in your syntax and implement [`Syntax`] +//! have in your syntax and implement [`Syntax`] //! //! 2. Create a [`GreenNodeBuilder`](build::GreenNodeBuilder) and call -//! [`start_node`](build::GreenNodeBuilder::start_node), [`token`](build::GreenNodeBuilder::token) and -//! [`finish_node`](build::GreenNodeBuilder::finish_node) from your parser +//! [`start_node`](build::GreenNodeBuilder::start_node), [`token`](build::GreenNodeBuilder::token) and +//! [`finish_node`](build::GreenNodeBuilder::finish_node) from your parser //! //! 3. Call [`SyntaxNode::new_root`](syntax::SyntaxNode::new_root) or -//! [`SyntaxNode::new_root_with_resolver`](syntax::SyntaxNode::new_root_with_resolver) with the resulting -//! [`GreenNode`](green::GreenNode) to obtain a syntax tree that you can traverse +//! [`SyntaxNode::new_root_with_resolver`](syntax::SyntaxNode::new_root_with_resolver) with the resulting +//! [`GreenNode`](green::GreenNode) to obtain a syntax tree that you can traverse //! //! There's a full [getting started guide] that walks through each of the above steps in detail in the documentation for //! the `getting_started` module. The walkthrough goes through the necessary steps bit by bit and skips the lexer, but @@ -86,7 +86,11 @@ #![forbid(missing_debug_implementations, unconditional_recursion)] #![deny(unsafe_code, future_incompatible)] -#![allow(unstable_name_collisions)] // strict provenance - must come after `future_incompatible` to take precedence +#![allow( + unstable_name_collisions, // strict provenance - must come after `future_incompatible` to take precedence + unexpected_cfgs, // nightly docs.rs features and `salsa-2022` feature until that is figured out + clippy::duplicated_attributes, // interning modules +)] #![warn(missing_docs)] // Docs.rs #![doc(html_root_url = "https://docs.rs/cstree/0.12.0")] diff --git a/cstree/src/syntax/node.rs b/cstree/src/syntax/node.rs index 3b39b98..429b1da 100644 --- a/cstree/src/syntax/node.rs +++ b/cstree/src/syntax/node.rs @@ -400,6 +400,7 @@ impl SyntaxNode { } /// Returns the data associated with this node, if any. + #[allow(clippy::useless_asref)] // make `Arc::clone` explicit pub fn get_data(&self) -> Option> { let ptr = self.data().data.read(); (*ptr).as_ref().map(Arc::clone)