From 7b87813a5b108c06f351828cdf5f2e4080f68a5b Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 8 Oct 2019 00:21:57 +0900 Subject: [PATCH] Apply rustfmt to more places --- .editorconfig | 2 +- .github/workflows/ci.yml | 6 +++--- .rustfmt.toml | 10 ++++++++-- core/src/auto_enum/mod.rs | 6 ++++-- src/lib.rs | 19 +++++-------------- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.editorconfig b/.editorconfig index 75a2ac3d..2d145b10 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ # EditorConfig configuration -# http://EditorConfig.org +# https://editorconfig.org # Top-most EditorConfig file root = true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index beeb157f..f092229b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,9 +44,9 @@ jobs: - name: cargo test if: matrix.rust != '1.31.0' run: | - cargo test --all --no-default-features - cargo test --all - cargo test --features type_analysis + cargo test --all --tests --no-default-features + cargo test --all --tests + cargo test --tests --features type_analysis - name: cargo test --all-features if: matrix.rust == 'nightly' run: | diff --git a/.rustfmt.toml b/.rustfmt.toml index a992861f..7bd2a818 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,7 +1,13 @@ -version = "Two" +# Rustfmt configuration +# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md + +version = "Two" # https://github.com/rust-lang/rustfmt/issues/3383 use_small_heuristics = "Max" +merge_imports = true # https://github.com/rust-lang/rustfmt/issues/3362 +format_code_in_doc_comments = true # https://github.com/rust-lang/rustfmt/issues/3348 -# Set the default settings again to always apply the proper formatting without being affected by the editor settings. +# Set the default settings again to always apply the proper formatting without +# being affected by the editor settings. # Refs: https://github.com/rust-lang/rls/issues/501#issuecomment-333717736 edition = "2018" tab_spaces = 4 diff --git a/core/src/auto_enum/mod.rs b/core/src/auto_enum/mod.rs index af0f9ade..f9eb3798 100644 --- a/core/src/auto_enum/mod.rs +++ b/core/src/auto_enum/mod.rs @@ -10,8 +10,10 @@ mod expr; mod type_analysis; mod visitor; -use self::context::{Context, VisitLastMode, VisitMode, DEFAULT_MARKER}; -use self::expr::child_expr; +use self::{ + context::{Context, VisitLastMode, VisitMode, DEFAULT_MARKER}, + expr::child_expr, +}; /// The attribute name. const NAME: &str = "auto_enum"; diff --git a/src/lib.rs b/src/lib.rs index bc4b0f4a..75ceb2c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -522,15 +522,13 @@ //! When using `#[auto_enum]` for expressions and statements, `#[auto_enum]` for //! function is unnecessary. //! -#![cfg_attr(feature = "unstable", doc = "```rust")] -#![cfg_attr(not(feature = "unstable"), doc = "```ignore")] +//! ```rust //! // Add this to your crate root: //! #![feature(proc_macro_hygiene, stmt_expr_attributes)] //! # fn main() {} //! ``` //! -#![cfg_attr(feature = "unstable", doc = "```rust")] -#![cfg_attr(not(feature = "unstable"), doc = "```ignore")] +//! ```rust //! # #![cfg_attr(feature = "try_trait", feature(try_trait))] //! # #![feature(proc_macro_hygiene, stmt_expr_attributes)] //! # use auto_enums::auto_enum; @@ -548,24 +546,18 @@ //! //! You can also return closures. //! -#![cfg_attr(feature = "fn_traits", doc = "```rust")] -#![cfg_attr(not(feature = "fn_traits"), doc = "```ignore")] +//! ```rust //! // Add this to your crate root: //! #![feature(fn_traits, unboxed_closures)] //! # fn main() {} //! ``` //! -#![cfg_attr(feature = "fn_traits", doc = "```rust")] -#![cfg_attr(not(feature = "fn_traits"), doc = "```ignore")] +//! ```rust //! # #![feature(fn_traits, unboxed_closures)] //! # use auto_enums::auto_enum; //! #[auto_enum(Fn)] //! fn foo(x: bool) -> impl Fn(i32) -> i32 { -//! if x { -//! |y| y + 1 -//! } else { -//! |z| z - 1 -//! } +//! if x { |y| y + 1 } else { |z| z - 1 } //! } //! # fn main() { let _ = foo(false); } //! ``` @@ -829,7 +821,6 @@ //! * There needs to explicitly specify the trait to be implemented (`type_analysis` crate feature reduces this limitation). //! //! * There needs to be marker macros for unsupported expressions. -//! #![no_std] #![recursion_limit = "256"]