diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cf29e96..fefd1bc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,7 +12,7 @@ jobs: strategy: max-parallel: 2 matrix: - rust: [stable, beta, nightly, 1.46.0, 1.51.0, 1.57.0, 1.64.0] + rust: [stable, beta, nightly, 1.57.0, 1.64.0] steps: - uses: actions/checkout@v2 @@ -27,26 +27,7 @@ jobs: cd "${{github.workspace}}/const_format/" cargo test --features "__test" - - uses: actions/checkout@v2 - - name: ci-stable - if: ${{ matrix.rust == '1.51.0' }} - run: | - cargo update - - cd "${{github.workspace}}/const_format/" - cargo test --features "__test rust_1_51" - - - uses: actions/checkout@v2 - - name: ci-stable - if: ${{ matrix.rust == '1.57.0' }} - run: | - cargo update - - cd "${{github.workspace}}/const_format/" - cargo test --features "__test assertcp" - cargo test --features "__test rust_1_51" - - uses: actions/checkout@v2 - name: ci-stable @@ -78,7 +59,6 @@ jobs: cargo test --features "__test assertc" cargo test --features "__test derive" cargo test --features "__test constant_time_as_str" - cargo test --features "__test rust_1_51" cargo test --features "__test rust_1_64" cargo test --features "__test derive constant_time_as_str" cargo test --features "__test derive constant_time_as_str assertc" diff --git a/Changelog.md b/Changelog.md index c3c9c77..f6e9ba8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,14 @@ This is the changelog,summarising changes in each version(some minor changes may # 0.2 +### 0.2.32 + +Breaking change: bumped Minimum Supported Rust Version to Rust 1.57 and changed crate's edition to 2021. This change is motivated by proc-macro2 increasing its MSRV to 1.56. + +Changed these items that needed the `"rust_1_51"` feature into always being enabled: +- `map_ascii_case` +- `str_replace` + ### 0.2.31 Added a workaround for rustdoc bug (https://github.com/rust-lang/rust/issues/112085). diff --git a/README.md b/README.md index 8d22a8d..50a0548 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ This crate provides types and macros for formatting strings at compile-time. # Rust versions -There are some features that require a variety of stable Rust versions and -others that Rust nightly, +There are some features that require a variety of stable Rust versions and +others that require Rust nightly, the sections below describe the features that are available for each version. -### Rust 1.46.0 +### Rust 1.57.0 -These macros are the only things available in Rust 1.46.0: +These macros are available in Rust 1.57.0: - [`concatcp`]: Concatenates `integers`, `bool`, `char`, and `&str` constants into a `&'static str` constant. @@ -26,22 +26,18 @@ Concatenates `integers`, `bool`, `char`, and `&str` constants into a `&'static s [`format`]-like formatting which takes `integers`, `bool`, `char`, and `&str` constants, and emits a `&'static str` constant. -- [`str_get`]: -Indexes a `&'static str` constant, returning `None` when the index is out of bounds. +- [`str_get`]: +Indexes a `&'static str` constant, returning `None` when the index is out of bounds. -- [`str_index`]: -Indexes a `&'static str` constant. +- [`str_index`]: +Indexes a `&'static str` constant. -- [`str_repeat`]: +- [`str_repeat`]: Creates a `&'static str` by repeating a `&'static str` constant `times` times. -- [`str_splice`]: +- [`str_splice`]: Replaces a substring in a `&'static str` constant. -### Rust 1.51.0 - -By enabling the "const_generics" feature, you can use these macros: - - [`map_ascii_case`]: Converts a `&'static str` constant to a different casing style, determined by a [`Case`] argument. @@ -50,10 +46,9 @@ determined by a [`Case`] argument. Replaces all the instances of a pattern in a `&'static str` constant with another `&'static str` constant. -### Rust 1.57.0 -The "assertcp" feature enables the [`assertcp`], [`assertcp_eq`], -and [`assertcp_ne`] macros. +The `"assertcp"` feature enables the [`assertcp`], [`assertcp_eq`], +and [`assertcp_ne`] macros. These macros are like the standard library assert macros, but evaluated at compile-time, with the limitation that they can only have primitive types as arguments @@ -65,12 +60,11 @@ The `"rust_1_64"` feature enables these macros: - [`str_split`]: splits a string constant - ### Rust nightly By enabling the "fmt" feature, you can use a [`std::fmt`]-like API. -This requires the nightly compiler because it uses mutable references in const fn, +This requires the nightly compiler, because it uses mutable references in const fn, which have not been stabilized as of writing these docs. All the other features of this crate are implemented on top of the [`const_format::fmt`] API: @@ -86,22 +80,19 @@ a `&'static str` constant. [`write`]-like macro that can format many standard library and user defined types into a type that implements [`WriteMarker`]. -The "derive" feature enables the [`ConstDebug`] macro, -and the "fmt" feature.
+The `"derive"` feature enables the [`ConstDebug`] macro, +and the `"fmt"` feature.
[`ConstDebug`] derives the [`FormatMarker`] trait, and implements an inherent `const_debug_fmt` method for compile-time debug formatting. -The "assertc" feature enables the [`assertc`], [`assertc_eq`], [`assertc_ne`] macros, -and the "fmt" feature.
+The `"assertc"` feature enables the [`assertc`], [`assertc_eq`], [`assertc_ne`] macros, +and the `"fmt"` feature.
These macros are like the standard library assert macros, but evaluated at compile-time. - # Examples ### Concatenation of primitive types -This example works in Rust 1.46.0. - ```rust use const_format::concatcp; @@ -113,8 +104,6 @@ assert_eq!(FOO, "Bob, age 21!"); ### Formatting primitive types -This example works in Rust 1.46.0. - ```rust use const_format::formatcp; @@ -125,7 +114,6 @@ const FOO: &str = formatcp!("{NAME}, age {}!", compute_age(NAME)); assert_eq!(FOO, "John, age 24!"); const fn compute_age(s: &str) -> usize { s.len() * 6 } - ``` ### Formatting custom types @@ -133,8 +121,7 @@ const fn compute_age(s: &str) -> usize { s.len() * 6 } This example demonstrates how you can use the [`ConstDebug`] derive macro, and then format the type into a `&'static str` constant. -This example requires Rust nightly, and the "derive" feature. - +This example requires Rust nightly, and the `"derive"` feature. ```rust #![feature(const_mut_refs)] @@ -157,12 +144,11 @@ const MSG: Message = Message{ const FOO: &str = formatc!("{:?}", MSG); -fn main(){ - assert_eq!( - FOO, - "Message { ip: [Octet(127), Octet(0), Octet(0), Octet(1)], value: \"Hello, World!\" }" - ); -} +assert_eq!( + FOO, + "Message { ip: [Octet(127), Octet(0), Octet(0), Octet(1)], value: \"Hello, World!\" }" +); + ``` ### Formatted const assertions @@ -170,8 +156,7 @@ fn main(){ This example demonstrates how you can use the [`assertcp_ne`] macro to do compile-time inequality assertions with formatted error messages. -This requires the "assertcp" feature, -because using the `panic` macro at compile-time requires Rust 1.57.0. +This requires the `"assertcp"` feature. ```rust, compile_fail use const_format::assertcp_ne; @@ -190,6 +175,7 @@ macro_rules! check_valid_pizza{ check_valid_pizza!("John", "salami"); check_valid_pizza!("Dave", "sausage"); check_valid_pizza!("Bob", "pineapple"); + ``` This is the compiler output: @@ -209,8 +195,6 @@ You can't put pineapple on pizza, Bob ``` - -
# Limitations @@ -229,6 +213,7 @@ so while a `Type::::FOO` argument would be fine, So `#[doc = "foobar"]` cannot be replaced with `#[doc = concatcp!("foo", "bar") ]`. + ### Integer arguments Integer arguments must have a type inferrable from context. @@ -244,8 +229,7 @@ assert_eq!(const_format::concatcp!(2u32, 2 + 1u8, 3u8 + 1), "234"); ``` Example of what does not compile: - -```compile_fail +```rust,compile_fail assert_eq!(const_format::concatcp!(1 + 1, 2 + 1), "23"); ``` # Plans @@ -256,54 +240,48 @@ None right now. All function-like macros from `const_format` can be used when the crate is renamed. -The [`ConstDebug`] derive macro has the `#[cdeb(crate = "foo::bar")]` attribute to +The [`ConstDebug`] derive macro has the `#[cdeb(crate = "foo::bar")]` attribute to tell it where to find the `const_format` crate. Example of renaming the `const_format` crate in the Cargo.toml file: ```toml +[dependencies] cfmt = {version = "0.*", package = "const_format"} ``` # Cargo features -- "fmt": Enables the [`std::fmt`]-like API, +- `"fmt"`: Enables the [`std::fmt`]-like API, requires Rust nightly because it uses mutable references in const fn.
This feature includes the [`formatc`]/[`writec`] formatting macros. -- "derive": implies the "fmt" feature, +- `"derive"`: requires Rust nightly, implies the `"fmt"` feature, provides the [`ConstDebug`] derive macro to format user-defined types at compile-time.
This implicitly uses the `syn` crate, so clean compiles take a bit longer than without the feature. -- "assertc": implies the "fmt" feature, +- `"assertc"`: requires Rust nightly, implies the `"fmt"` feature, enables the [`assertc`], [`assertc_eq`], and [`assertc_ne`] assertion macros.
-This feature was previously named "assert", -but it was renamed to avoid confusion with the "assertcp" feature. +This feature was previously named `"assert"`, +but it was renamed to avoid confusion with the `"assertcp"` feature. -- "assertcp": Requires Rust 1.57.0, implies the "const_generics" feature. +- `"assertcp"`: Enables the [`assertcp`], [`assertcp_eq`], and [`assertcp_ne`] assertion macros. -- "rust_1_51": -Enables the macros listed in the [Rust 1.51.0](#rust-1510) section. -Also changes the the implementation of the [`concatcp`] and [`formatcp`] -macros to use const generics. - -- "rust_1_64": Enables the [`str_split`] macro. +- `"rust_1_64"`: Enables the [`str_split`] macro. Allows the `as_bytes_alt` methods and `slice_up_to_len_alt` methods to run -in constant time, rather than linear time proportional to the truncated part of the slice. - +in constant time, rather than linear time (proportional to the truncated part of the slice). # No-std support -`const_format` is `#![no_std]`, it can be used anywhere Rust can be used. +`const_format` is unconditionally `#![no_std]`, it can be used anywhere Rust can be used. # Minimum Supported Rust Version -`const_format` requires Rust 1.46.0, because it uses looping an branching in const contexts. +`const_format` requires Rust 1.57.0. Features that require newer versions of Rust, or the nightly compiler, need to be explicitly enabled with cargo features. - [`assertc`]: https://docs.rs/const_format/0.2.*/const_format/macro.assertc.html [`assertc_eq`]: https://docs.rs/const_format/0.2.*/const_format/macro.assertc_eq.html diff --git a/const_format/Cargo.toml b/const_format/Cargo.toml index 91bb666..8977e80 100644 --- a/const_format/Cargo.toml +++ b/const_format/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "const_format" -version = "0.2.31" +version = "0.2.32" authors = ["rodrimati1992 "] -edition = "2018" +rust-version = "1.57.0" +edition = "2021" license = "Zlib" description = "Compile-time string formatting" documentation = "https://docs.rs/const_format/" @@ -17,9 +18,6 @@ include = [ "LICENSE-ZLIB.md", ] -[badges] -travis-ci = { repository = "rodrimati1992/const_format_crates/" } - [features] default = [] const_generics = ["rust_1_51"] @@ -28,8 +26,10 @@ rust_1_51 = [] rust_1_64 = ["rust_1_51", "konst", "konst/rust_1_64"] fmt = ["rust_1_64"] derive = ["fmt", "const_format_proc_macros/derive"] + # soft-deprecated, use assertc instead. assert = ["assertc"] + assertc = ["fmt", "assertcp"] assertcp = ["rust_1_51"] constant_time_as_str = ["fmt"] @@ -53,7 +53,7 @@ __only_new_tests = ["__test"] __docsrs = [] [dependencies.const_format_proc_macros] -version = "=0.2.31" +version = "=0.2.32" path = "../const_format_proc_macros" [dependencies.konst] diff --git a/const_format/src/__str_methods.rs b/const_format/src/__str_methods.rs index 480ce86..145ab77 100644 --- a/const_format/src/__str_methods.rs +++ b/const_format/src/__str_methods.rs @@ -1,7 +1,5 @@ -#[cfg(feature = "rust_1_51")] mod str_replace; -#[cfg(feature = "rust_1_51")] pub use self::str_replace::{ReplaceInput, ReplaceInputConv}; mod str_repeat; @@ -19,13 +17,10 @@ mod str_split; #[cfg(feature = "rust_1_64")] pub use str_split::{SplitInput, SplitInputConv}; -#[cfg(feature = "rust_1_51")] mod pattern; -#[cfg(feature = "rust_1_51")] use pattern::{Pattern, PatternCtor, PatternNorm}; -#[cfg(feature = "rust_1_51")] mod ascii_byte { #[derive(Copy, Clone)] pub struct AsciiByte(u8); @@ -46,11 +41,9 @@ mod ascii_byte { } } } -#[cfg(feature = "rust_1_51")] pub use ascii_byte::AsciiByte; // copied from the konst crate, if that implementation is wrong, this needs to be fixed -#[cfg(feature = "rust_1_51")] const fn bytes_find(left: &[u8], right: &[u8], from: usize) -> Option { let mut matching = right; diff --git a/const_format/src/const_debug_derive.rs b/const_format/src/const_debug_derive.rs index b70883d..9444569 100644 --- a/const_format/src/const_debug_derive.rs +++ b/const_format/src/const_debug_derive.rs @@ -7,7 +7,7 @@ /// /// This derive macro is only available with the "derive" feature, /// and the nightly compiler, -/// because at the time of writing these docs (2021-08-XX) mutable references in const fn +/// because at the time of writing these docs (2023-10-XX) mutable references in const fn /// require the unstable /// [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349) feature. /// diff --git a/const_format/src/fmt.rs b/const_format/src/fmt.rs index d060ca8..b6fd005 100644 --- a/const_format/src/fmt.rs +++ b/const_format/src/fmt.rs @@ -4,7 +4,7 @@ //! # Features //! //! This module requires the "fmt" feature to be exported, and the nightly compiler, -//! because at the time of writing these docs (2021-08-XX) mutable references in const fn +//! because at the time of writing these docs (2023-10-XX) mutable references in const fn //! require the unstable //! [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349) feature. //! diff --git a/const_format/src/for_assert_macros.rs b/const_format/src/for_assert_macros.rs index 8acca18..fab1506 100644 --- a/const_format/src/for_assert_macros.rs +++ b/const_format/src/for_assert_macros.rs @@ -5,7 +5,7 @@ use crate::pargument::PArgument; #[track_caller] pub const fn assert_(cond: bool, message: &'static str) { if cond { - panic!(message) + panic!("{}", message) } } diff --git a/const_format/src/for_examples.rs b/const_format/src/for_examples.rs index ce760e8..098c083 100644 --- a/const_format/src/for_examples.rs +++ b/const_format/src/for_examples.rs @@ -3,7 +3,7 @@ //! # Features //! //! This module is only exported with the "fmt" feature, and the nightly compiler, -//! because at the time of writing these docs (2021-08-XX) mutable references in const fn +//! because at the time of writing these docs (2023-10-XX) mutable references in const fn //! require the unstable //! [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349) feature. diff --git a/const_format/src/lib.rs b/const_format/src/lib.rs index a05a7fa..7fe3016 100644 --- a/const_format/src/lib.rs +++ b/const_format/src/lib.rs @@ -5,12 +5,12 @@ //! # Rust versions //! //! There are some features that require a variety of stable Rust versions and -//! others that Rust nightly, +//! others that require Rust nightly, //! the sections below describe the features that are available for each version. //! -//! ### Rust 1.46.0 +//! ### Rust 1.57.0 //! -//! These macros are the only things available in Rust 1.46.0: +//! These macros are available in Rust 1.57.0: //! //! - [`concatcp`]: //! Concatenates `integers`, `bool`, `char`, and `&str` constants into a `&'static str` constant. @@ -31,11 +31,6 @@ //! - [`str_splice`]: //! Replaces a substring in a `&'static str` constant. //! -//! -//! ### Rust 1.51.0 -//! -//! By enabling the "rust_1_51" feature, you can use these macros: -//! //! - [`map_ascii_case`]: //! Converts a `&'static str` constant to a different casing style, //! determined by a [`Case`] argument. @@ -44,9 +39,8 @@ //! Replaces all the instances of a pattern in a `&'static str` constant with //! another `&'static str` constant. //! -//! ### Rust 1.57.0 //! -//! The "assertcp" feature enables the [`assertcp`], [`assertcp_eq`], +//! The `"assertcp"` feature enables the [`assertcp`], [`assertcp_eq`], //! and [`assertcp_ne`] macros. //! These macros are like the standard library assert macros, //! but evaluated at compile-time, @@ -63,7 +57,7 @@ //! //! By enabling the "fmt" feature, you can use a [`std::fmt`]-like API. //! -//! This requires the nightly compiler because it uses mutable references in const fn, +//! This requires the nightly compiler, because it uses mutable references in const fn, //! which have not been stabilized as of writing these docs. //! //! All the other features of this crate are implemented on top of the [`const_format::fmt`] API: @@ -79,20 +73,19 @@ //! [`write`]-like macro that can format many standard library and user defined types //! into a type that implements [`WriteMarker`]. //! -//! The "derive" feature enables the [`ConstDebug`] macro, -//! and the "fmt" feature.
+//! The `"derive"` feature enables the [`ConstDebug`] macro, +//! and the `"fmt"` feature.
//! [`ConstDebug`] derives the [`FormatMarker`] trait, //! and implements an inherent `const_debug_fmt` method for compile-time debug formatting. //! -//! The "assertc" feature enables the [`assertc`], [`assertc_eq`], [`assertc_ne`] macros, -//! and the "fmt" feature.
+//! The `"assertc"` feature enables the [`assertc`], [`assertc_eq`], [`assertc_ne`] macros, +//! and the `"fmt"` feature.
//! These macros are like the standard library assert macros, but evaluated at compile-time. +//! //! # Examples //! //! ### Concatenation of primitive types //! -//! This example works in Rust 1.46.0. -//! //! ```rust //! use const_format::concatcp; //! @@ -104,8 +97,6 @@ //! //! ### Formatting primitive types //! -//! This example works in Rust 1.46.0. -//! //! ```rust //! use const_format::formatcp; //! @@ -124,7 +115,7 @@ //! This example demonstrates how you can use the [`ConstDebug`] derive macro, //! and then format the type into a `&'static str` constant. //! -//! This example requires Rust nightly, and the "derive" feature. +//! This example requires Rust nightly, and the `"derive"` feature. //! #![cfg_attr(feature = "derive", doc = "```rust")] #![cfg_attr(not(feature = "derive"), doc = "```ignore")] @@ -160,8 +151,7 @@ //! This example demonstrates how you can use the [`assertcp_ne`] macro to //! do compile-time inequality assertions with formatted error messages. //! -//! This requires the "assertcp" feature, -//! because using the `panic` macro at compile-time requires Rust 1.57.0. +//! This requires the `"assertcp"` feature. //! #![cfg_attr(feature = "assertcp", doc = "```compile_fail")] #![cfg_attr(not(feature = "assertcp"), doc = "```ignore")] @@ -249,35 +239,31 @@ //! //! Example of renaming the `const_format` crate in the Cargo.toml file: //! ```toml +//! [dependencies] //! cfmt = {version = "0.*", package = "const_format"} //! ``` //! //! # Cargo features //! -//! - "fmt": Enables the [`std::fmt`]-like API, +//! - `"fmt"`: Enables the [`std::fmt`]-like API, //! requires Rust nightly because it uses mutable references in const fn.
//! This feature includes the [`formatc`]/[`writec`] formatting macros. //! -//! - "derive": implies the "fmt" feature, +//! - `"derive"`: requires Rust nightly, implies the `"fmt"` feature, //! provides the [`ConstDebug`] derive macro to format user-defined types at compile-time.
//! This implicitly uses the `syn` crate, so clean compiles take a bit longer than without the feature. //! -//! - "assertc": implies the "fmt" feature, +//! - `"assertc"`: requires Rust nightly, implies the `"fmt"` feature, //! enables the [`assertc`], [`assertc_eq`], and [`assertc_ne`] assertion macros.
-//! This feature was previously named "assert", -//! but it was renamed to avoid confusion with the "assertcp" feature. +//! This feature was previously named `"assert"`, +//! but it was renamed to avoid confusion with the `"assertcp"` feature. //! -//! - "assertcp": Requires Rust 1.57.0, implies the "rust_1_51" feature. +//! - `"assertcp"`: //! Enables the [`assertcp`], [`assertcp_eq`], and [`assertcp_ne`] assertion macros. //! -//! - "rust_1_51": -//! Enables the macros listed in the [Rust 1.51.0](#rust-1510) section. -//! Also changes the the implementation of the [`concatcp`] and [`formatcp`] -//! macros to use const generics. -//! -//! - "rust_1_64": Enables the [`str_split`] macro. +//! - `"rust_1_64"`: Enables the [`str_split`] macro. //! Allows the `as_bytes_alt` methods and `slice_up_to_len_alt` methods to run -//! in constant time, rather than linear time proportional to the truncated part of the slice. +//! in constant time, rather than linear time (proportional to the truncated part of the slice). //! //! # No-std support //! @@ -285,7 +271,7 @@ //! //! # Minimum Supported Rust Version //! -//! `const_format` requires Rust 1.46.0, because it uses looping an branching in const contexts. +//! `const_format` requires Rust 1.57.0. //! //! Features that require newer versions of Rust, or the nightly compiler, //! need to be explicitly enabled with cargo features. @@ -385,7 +371,6 @@ mod char_encoding; mod pargument; -#[cfg(feature = "rust_1_51")] mod const_generic_concatcp; #[cfg_attr(feature = "__docsrs", doc(cfg(feature = "fmt")))] @@ -427,7 +412,6 @@ pub mod msg; pub mod wrapper_types; #[doc(hidden)] -#[cfg(feature = "rust_1_51")] pub mod __ascii_case_conv; #[doc(hidden)] @@ -435,8 +419,6 @@ pub mod __str_methods; pub use __str_methods::SplicedStr; -#[cfg_attr(feature = "__docsrs", doc(cfg(feature = "rust_1_51")))] -#[cfg(feature = "rust_1_51")] pub use __ascii_case_conv::Case; #[cfg(feature = "fmt")] @@ -480,7 +462,6 @@ pub mod pmr { result::Result::{self, Err, Ok}, }; - #[cfg(feature = "rust_1_51")] pub use crate::const_generic_concatcp::__priv_concatenate; #[cfg(feature = "assertcp")] diff --git a/const_format/src/macros.rs b/const_format/src/macros.rs index 90550fb..e9f4768 100644 --- a/const_format/src/macros.rs +++ b/const_format/src/macros.rs @@ -19,7 +19,6 @@ mod fmt_macros; mod impl_fmt; #[macro_use] -#[cfg(feature = "rust_1_51")] mod map_ascii_case; #[macro_use] diff --git a/const_format/src/macros/assertions/assertc_macros.rs b/const_format/src/macros/assertions/assertc_macros.rs index f38f0b7..16856e7 100644 --- a/const_format/src/macros/assertions/assertc_macros.rs +++ b/const_format/src/macros/assertions/assertc_macros.rs @@ -11,13 +11,12 @@ macro_rules! with_shared_docs {( ) => ( $(#[$before_clarification])* /// - /// This macro requires the "assertcp" feature to be exported. + /// This macro requires the `"assertc"` feature to be exported. /// $(#[$before_syntax])* - /// # Syntax /// /// This macro uses [the same syntax](./fmt/index.html#fmtsyntax) - /// for the format string and formatting arguments as the + /// for the format string and supports the same formatting arguments as the /// [`formatc`] macro. /// $(#[$after_syntax])* @@ -75,7 +74,7 @@ with_shared_docs! { /// ### Failing assertion /// /// This example demonstrates a failing assertion, - /// and how the compiler error looks like as of 2021-09-18. + /// and how the compiler error looks like as of 2023-10-14. /// /// ```compile_fail /// #![feature(const_mut_refs)] @@ -94,14 +93,13 @@ with_shared_docs! { /// /// ```text /// error[E0080]: evaluation of constant value failed - /// --> src/macros/assertions.rs:132:10 + /// --> const_format/src/macros/assertions/assertc_macros.rs:109:10 /// | - /// 12 | assertc!(L + R == 5, "{} plus {} isn't 5, buddy", L, R); + /// 11 | assertc!(L + R == 5, "{} plus {} isn't 5, buddy", L, R); /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' /// assertion failed. /// 2 plus 2 isn't 5, buddy - /// ', src/macros/assertions.rs:12:10 - /// + /// ', const_format/src/macros/assertions/assertc_macros.rs:11:10 /// ``` /// #[cfg_attr(feature = "__docsrs", doc(cfg(feature = "assertc")))] @@ -128,7 +126,7 @@ macro_rules! assert_eq_docs { with_shared_docs! { $(#[$documentation])* ;clarification - /// # Comparison Arguments + /// # Arguments /// /// This macro accepts these types for comparison and debug printing: /// @@ -175,7 +173,7 @@ assert_eq_docs! { /// ### Failing assertion /// /// This example demonstrates a failing assertion, - /// and how the compiler error looks like as of 2021-09-18. + /// and how the compiler error looks like as of 2023-10-14. /// /// ```compile_fail /// #![feature(const_mut_refs)] @@ -193,14 +191,13 @@ assert_eq_docs! { /// /// ```text /// error[E0080]: evaluation of constant value failed - /// --> src/macros/assertions.rs:296:13 - /// | - /// 9 | assertc_eq!(size_of::(), size_of::()); - /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' + /// --> const_format/src/macros/assertions/assertc_macros.rs:222:13 + /// | + /// 10 | assertc_eq!(size_of::(), size_of::()); + /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' /// assertion failed: `(left == right)` /// left: `4` - /// right: `1`', src/macros/assertions.rs:9:13 - /// + /// right: `1`', const_format/src/macros/assertions/assertc_macros.rs:10:13 /// ``` /// /// ### Comparing user-defined types @@ -302,7 +299,7 @@ assert_eq_docs! { /// ### Failing assertion /// /// This example demonstrates a failing assertion, - /// and how the compiler error looks like as of 2021-09-18. + /// and how the compiler error looks like as of 2023-10-14. /// /// ```compile_fail /// #![feature(const_mut_refs)] @@ -322,14 +319,13 @@ assert_eq_docs! { /// /// ```text /// error[E0080]: evaluation of constant value failed - /// --> src/macros/assertions.rs:465:13 + /// --> const_format/src/macros/assertions/assertc_macros.rs:350:13 /// | - /// 11 | assertc_ne!(size_of::(), size_of::()); + /// 12 | assertc_ne!(size_of::(), size_of::()); /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' /// assertion failed: `(left != right)` /// left: `4` - /// right: `4`', src/macros/assertions.rs:11:13 - /// + /// right: `4`', const_format/src/macros/assertions/assertc_macros.rs:12:13 /// ``` /// /// ### Comparing user-defined types diff --git a/const_format/src/macros/assertions/assertcp_macros.rs b/const_format/src/macros/assertions/assertcp_macros.rs index d4c6e8a..79ff7fb 100644 --- a/const_format/src/macros/assertions/assertcp_macros.rs +++ b/const_format/src/macros/assertions/assertcp_macros.rs @@ -11,14 +11,14 @@ macro_rules! with_shared_docs {( /// /// [For **examples** look here](#examples) /// - /// This macro requires the "assertcp" feature to be exported.
+ /// This macro requires the `"assertcp"` feature to be exported.
/// $(#[$before_syntax])* /// # Syntax /// /// This macro uses the same syntax /// for the format string and formatting arguments as the - /// [`formatcp`] macro. + /// [`formatcp`](crate::formatcp) macro. /// $(#[$after_syntax])* /// # Limitations @@ -75,7 +75,7 @@ with_shared_docs! { /// ### Failing assertion /// /// This example demonstrates a failing assertion, - /// and how the compiler error looks like as of 2021-09-18. + /// and how the compiler error looks like as of 2023-10-14. /// /// ```compile_fail /// use const_format::assertcp; @@ -92,13 +92,13 @@ with_shared_docs! { /// /// ```text /// error[E0080]: evaluation of constant value failed - /// --> src/macros/assertions/assertcp_macros.rs:124:11 - /// | - /// 10 | assertcp!(L.pow(R) == 64, "{L} to the {R} isn't 64, it's {}", L.pow(R)); - /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' + /// --> const_format/src/macros/assertions/assertcp_macros.rs:116:11 + /// | + /// 9 | assertcp!(L.pow(R) == 64, "{L} to the {R} isn't 64, it's {}", L.pow(R)); + /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' /// assertion failed. /// 2 to the 5 isn't 64, it's 32 - /// ', src/macros/assertions/assertcp_macros.rs:10:11 + /// ', const_format/src/macros/assertions/assertcp_macros.rs:9:11 /// /// ``` /// @@ -192,7 +192,7 @@ with_shared_docs! { /// ### Failing assertion /// /// This example demonstrates a failing assertion, - /// and how the compiler error looks like as of 2021-09-18. + /// and how the compiler error looks like as of 2023-10-14. /// /// ```compile_fail /// use const_format::assertcp_eq; @@ -210,15 +210,15 @@ with_shared_docs! { /// /// ```text /// error[E0080]: evaluation of constant value failed - /// --> src/macros/assertions/assertcp_macros.rs:226:14 + /// --> const_format/src/macros/assertions/assertcp_macros.rs:235:14 /// | - /// 11 | assertcp_eq!(size_of::(), size_of::<[u16; 2]>(), "Whoops, `Type` is too large"); + /// 12 | assertcp_eq!(size_of::(), size_of::<[u16; 2]>(), "Whoops, `Type` is too large"); /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' /// assertion failed: `(left == right)` /// left: `6` /// right: `4` /// Whoops, `Type` is too large - /// ', src/macros/assertions/assertcp_macros.rs:11:14 + /// ', const_format/src/macros/assertions/assertcp_macros.rs:12:14 /// /// ``` /// @@ -258,7 +258,7 @@ with_shared_docs! { /// ### Failing assertion /// /// This example demonstrates a failing assertion, - /// and how the compiler error looks like as of 2021-09-18. + /// and how the compiler error looks like as of 2023-10-14. /// /// ```compile_fail /// use const_format::assertcp_ne; @@ -272,15 +272,15 @@ with_shared_docs! { /// /// ```text /// error[E0080]: evaluation of constant value failed - /// --> src/macros/assertions/assertcp_macros.rs:298:14 + /// --> const_format/src/macros/assertions/assertcp_macros.rs:297:14 /// | - /// 7 | assertcp_ne!(NAME, "", "NAME must not be empty!"); + /// 8 | assertcp_ne!(NAME, "", "NAME must not be empty!"); /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at ' /// assertion failed: `(left != right)` /// left: `""` /// right: `""` /// NAME must not be empty! - /// ', src/macros/assertions/assertcp_macros.rs:7:14 + /// ', const_format/src/macros/assertions/assertcp_macros.rs:8:14 /// ``` /// #[cfg_attr(feature = "__docsrs", doc(cfg(feature = "assertcp")))] diff --git a/const_format/src/macros/fmt_macros.rs b/const_format/src/macros/fmt_macros.rs index 23e06f8..69a5b94 100644 --- a/const_format/src/macros/fmt_macros.rs +++ b/const_format/src/macros/fmt_macros.rs @@ -67,51 +67,6 @@ macro_rules! concatcp { #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "rust_1_51"))] -macro_rules! __concatcp_inner { - ($variables:expr) => {{ - #[doc(hidden)] - const ARR_LEN: usize = $crate::pmr::PArgument::calc_len($variables); - - #[doc(hidden)] - const CONCAT_ARR: &$crate::pmr::LenAndArray<[u8; ARR_LEN]> = { - use $crate::{__write_pvariant, pmr::PVariant}; - - let mut out = $crate::pmr::LenAndArray { - len: 0, - array: [0u8; ARR_LEN], - }; - - let input = $variables; - - $crate::__for_range! { outer_i in 0..input.len() => - let current = &input[outer_i]; - - match current.elem { - PVariant::Str(s) => __write_pvariant!(str, current, s => out), - PVariant::Int(int) => __write_pvariant!(int, current, int => out), - PVariant::Char(c) => __write_pvariant!(char, current, c => out), - } - } - &{ out } - }; - - #[doc(hidden)] - #[allow(clippy::transmute_ptr_to_ptr)] - const CONCAT_STR: &str = unsafe { - // This transmute truncates the length of the array to the amound of written bytes. - let slice = - $crate::pmr::transmute::<&[u8; ARR_LEN], &[u8; CONCAT_ARR.len]>(&CONCAT_ARR.array); - - $crate::__priv_transmute_bytes_to_str!(slice) - }; - CONCAT_STR - }}; -} - -#[doc(hidden)] -#[macro_export] -#[cfg(feature = "rust_1_51")] macro_rules! __concatcp_inner { ($variables:expr) => {{ #[doc(hidden)] @@ -294,7 +249,7 @@ macro_rules! formatcp { /// /// # Stable equivalent /// -/// For an equivalent macro which can be used in stable Rust (1.46.0 onwards), +/// For an equivalent macro which can be used in stable Rust, /// but can only concatenate primitive types, /// you can use the [`concatcp`](crate::concatcp) macro. /// @@ -441,7 +396,7 @@ macro_rules! __concatc_inner { /// /// # Stable equivalent /// -/// For an equivalent macro which can be used in stable Rust (1.46.0 onwards), +/// For an equivalent macro which can be used in stable Rust, /// but can only format primitive types, /// you can use the [`formatcp`](crate::formatcp) macro. /// diff --git a/const_format/src/macros/map_ascii_case.rs b/const_format/src/macros/map_ascii_case.rs index 5899bc3..b063859 100644 --- a/const_format/src/macros/map_ascii_case.rs +++ b/const_format/src/macros/map_ascii_case.rs @@ -73,7 +73,6 @@ /// /// /// ``` -#[cfg_attr(feature = "__docsrs", doc(cfg(feature = "rust_1_51")))] #[macro_export] macro_rules! map_ascii_case { ($case:expr, $str:expr) => {{ diff --git a/const_format/src/macros/str_methods.rs b/const_format/src/macros/str_methods.rs index 00a91fc..9b56565 100644 --- a/const_format/src/macros/str_methods.rs +++ b/const_format/src/macros/str_methods.rs @@ -64,8 +64,6 @@ /// /// [`str::replace`]: https://doc.rust-lang.org/std/primitive.str.html#method.replace #[macro_export] -#[cfg(feature = "rust_1_51")] -#[cfg_attr(feature = "__docsrs", doc(cfg(feature = "rust_1_51")))] macro_rules! str_replace { ($input:expr, $pattern:expr, $replace_with:expr $(,)*) => {{ const ARGS_OSRCTFL4A: $crate::__str_methods::ReplaceInput = diff --git a/const_format/tests/str_methods.rs b/const_format/tests/str_methods.rs index 377580e..ac315c3 100644 --- a/const_format/tests/str_methods.rs +++ b/const_format/tests/str_methods.rs @@ -1,8 +1,6 @@ mod str_methods_modules { - #[cfg(feature = "rust_1_51")] mod conv_ascii_case; - #[cfg(feature = "rust_1_51")] mod str_replace; mod str_splice; diff --git a/const_format_proc_macros/Cargo.toml b/const_format_proc_macros/Cargo.toml index 2eb819e..0e404ea 100644 --- a/const_format_proc_macros/Cargo.toml +++ b/const_format_proc_macros/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "const_format_proc_macros" -version = "0.2.31" +version = "0.2.32" authors = ["rodrimati1992 "] -edition = "2018" +rust-version = "1.57.0" +edition = "2021" license = "Zlib" description = "Implementation detail of the `const_format` crate" keywords = ["no-std", "format", "concat"] @@ -15,9 +16,6 @@ include = [ "LICENSE-ZLIB.md", ] -[badges] -travis-ci = { repository = "rodrimati1992/const_format_crates/" } - [lib] proc-macro = true