From 81a9fc3122ab135e4ccbc9ee1b77eb56b4493fd9 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 5 Oct 2024 08:02:28 +0800 Subject: [PATCH] Fix clippy lints (#316) --- full-moon/Cargo.toml | 4 ++-- full-moon/src/ast/mod.rs | 2 +- full-moon/src/lib.rs | 17 +++++++++-------- full-moon/src/tokenizer/structs.rs | 6 ++++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/full-moon/Cargo.toml b/full-moon/Cargo.toml index 8569cc6e..7f6f5482 100644 --- a/full-moon/Cargo.toml +++ b/full-moon/Cargo.toml @@ -11,9 +11,9 @@ keywords = ["lua", "parser", "lua51", "lua52", "luau"] edition = "2021" [package.metadata.docs.rs] -# Build Locally: RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --features luau,lua52,lua53,lua54,luajit --no-deps --open +# Build Locally: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features luau,lua52,lua53,lua54,luajit --no-deps --open features = ["luau", "lua52", "lua53", "lua54", "luajit"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "docsrs"] [features] default = ["serde"] diff --git a/full-moon/src/ast/mod.rs b/full-moon/src/ast/mod.rs index 372c7a94..49756602 100644 --- a/full-moon/src/ast/mod.rs +++ b/full-moon/src/ast/mod.rs @@ -50,7 +50,7 @@ use lua54::*; #[display( "{}{}", display_optional_punctuated_vec(stmts), - display_option(&last_stmt.as_ref().map(display_optional_punctuated)) + display_option(last_stmt.as_ref().map(display_optional_punctuated)) )] pub struct Block { stmts: Vec<(Stmt, Option)>, diff --git a/full-moon/src/lib.rs b/full-moon/src/lib.rs index 3d4d0d38..5863d2ce 100644 --- a/full-moon/src/lib.rs +++ b/full-moon/src/lib.rs @@ -1,6 +1,6 @@ #![warn(missing_docs)] #![allow(clippy::large_enum_variant)] -#![cfg_attr(doc_cfg, feature(doc_auto_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] //! # Full Moon //! //! `full_moon` is a lossless parser for Lua, supporting Lua 5.1, 5.2, 5.3, 5.4 and Luau @@ -95,16 +95,17 @@ pub fn parse(code: &str) -> Result> { /// Given code and a pinned Lua version, will produce an [`ast::AstResult`]. /// This AstResult always produces some [`Ast`](ast::Ast), regardless of errors. -/// If a partial Ast is produced (i.e. if there are any errors), a few guarantees are lost. +/// If a partial Ast is produced (i.e. if there are any errors), a few guarantees are lost: +/// /// 1. Tokens may be produced that aren't in the code itself. For example, `if x == 2 code()` -/// will produce a phantom `then` token in order to produce a usable [`If`](ast::If) struct. -/// These phantom tokens will have a null position. If you need accurate positions from the -/// phantom tokens, you can call [`Ast::update_positions`](ast::Ast::update_positions). +/// will produce a phantom `then` token in order to produce a usable [`If`](ast::If) struct. +/// These phantom tokens will have a null position. If you need accurate positions from the +/// phantom tokens, you can call [`Ast::update_positions`](ast::Ast::update_positions). /// 2. The code, when printed, is not guaranteed to be valid Lua. -/// This can happen in the case of something like `local x = if`, which will produce a -/// [`LocalAssignment`](ast::LocalAssignment) that would print to `local x =`. +/// This can happen in the case of something like `local x = if`, which will produce a +/// [`LocalAssignment`](ast::LocalAssignment) that would print to `local x =`. /// 3. There are no stability guarantees for partial Ast results, but they are consistent -/// within the same exact version of full-moon. +/// within the same exact version of full-moon. pub fn parse_fallible(code: &str, lua_version: LuaVersion) -> ast::AstResult { ast::AstResult::parse_fallible(code, lua_version) } diff --git a/full-moon/src/tokenizer/structs.rs b/full-moon/src/tokenizer/structs.rs index 59de04aa..70079082 100644 --- a/full-moon/src/tokenizer/structs.rs +++ b/full-moon/src/tokenizer/structs.rs @@ -914,8 +914,9 @@ impl fmt::Display for TokenizerError { impl std::error::Error for TokenizerError {} -// #[cfg(test)] -#[cfg(feature = "rewrite todo: tokenizer tests")] +/* +// rewrite TODO: tokenizer tests + mod tests { use crate::tokenizer::*; use pretty_assertions::assert_eq; @@ -1193,3 +1194,4 @@ mod tests { let _ = tokens("ยน;"); } } +*/