#clippy #expect #warnings #lint #macro

macro flexpect

#[flexpect::e(...)] compiles to #[expect(...)] for newer versions of Rust and to #[allow(...)] when not supported

6 releases

0.1.1 Mar 16, 2025
0.1.0 Mar 16, 2025
0.0.4 Sep 28, 2024

#890 in Procedural macros

Download history 392/week @ 2026-02-16 431/week @ 2026-02-23 430/week @ 2026-03-02 343/week @ 2026-03-09 361/week @ 2026-03-16 382/week @ 2026-03-23 291/week @ 2026-03-30 348/week @ 2026-04-06 1036/week @ 2026-04-13 843/week @ 2026-04-20 969/week @ 2026-04-27 1006/week @ 2026-05-04 988/week @ 2026-05-11 1059/week @ 2026-05-18 871/week @ 2026-05-25 1641/week @ 2026-06-01

4,687 downloads per month
Used in simdutf8-cli

MIT/Apache

9KB
51 lines

flexpect

#[flexpect::e(...)] compiles to #[expect(...)] for newer versions of Rust and to #[allow(...)] when not supported.

Purpose

This crate enables getting the benefits of #[expect(...)] while maintaining a minimum supported Rust version that's earlier than 1.81.

Usage

Add flexpect to your Cargo.toml:

[dependencies]
flexpect = "0.1.0"

Then use the #[flexpect::e(...)] or #[flexpect::flexpect(...)] attributes instead of #[expect(...)]:

// instead of #[expect(unused_variables)]
#[flexpect::e(unused_variables)]
fn example() {
    let x = 1;
}
use flexpect::flexpect;

// instead of #[expect(clippy::clone_on_copy)]
#[flexpect(clippy::clone_on_copy)]
fn clippy_example() {
    let _ = 32.clone();
}

How it works

  • On Rust versions before 1.43.0, the attribute is ignored due to compiler bugs.
  • From Rust 1.43.0 to 1.80, it translates to #[allow(...)].
  • From Rust 1.81 onwards, it translates to #[expect(...)].

The minimum supported Rust version is 1.38.

Limitations

flexpect does not work as inner attributes (#![flexpect::e(...)]) nor on statements, expressions or blocks due to compiler limitations.

Dependencies