Skip to content

Commit d845841

Browse files
committed
review feedback on PR #412, round 2
Two more review comments: - Restore the `make_const!` macro in `visualizer::proportion_bar`. The matcher syntax (`$name:ident = $content:literal`) is now silenced by perfectionist `93cb529`'s extension of `looks_like_expression` to top-level `=` markers; adding `make_const` to `allow_extra` covers the residual unknown-macro flag from `AllowAndDeny` mode. - Drop the experiment with `perfectionist::non_exhaustive_error`. Remove the deny directive at the crate root, and remove the `#[cfg_attr(... expect(perfectionist::non_exhaustive_error, ...))]` suppressions added on `args::fraction::ConversionError` and `args::fraction::FromStrError` in the previous commit (those types are explicitly exhaustive, so the rule was telling them to add `#[non_exhaustive]` they did not want; the right resolution is to drop the rule, not work around it). https://claude.ai/code/session_01CoRidYHvni9nKNgxMPXmfQ
1 parent f792aa0 commit d845841

4 files changed

Lines changed: 12 additions & 24 deletions

File tree

dylint.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ prefix = [
2121

2222
["perfectionist::macro_argument_binding"]
2323
deny_extra = ["debug_assert_op", "debug_assert_op_expr"]
24-
allow_extra = ["bump", "link", "symlink", "test_case", "visualize"]
24+
allow_extra = ["bump", "link", "make_const", "symlink", "test_case", "visualize"]
2525

2626
["perfectionist::single_letter_closure_param"]
2727
comparison_methods = ["sort_by", "sort_unstable_by", "sort_by_key", "sort_unstable_by_key", "min_by", "max_by", "min_by_key", "max_by_key", "binary_search_by", "binary_search_by_key", "cmp_by", "partial_cmp_by", "eq_by", "fold", "sort_reflection_by", "into_sorted_by"]

src/args/fraction.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ pub struct Fraction(f32);
1111

1212
/// Error that occurs when calling [`Fraction::new`].
1313
#[derive(Debug, Display, Error, Clone, Copy, PartialEq, Eq)]
14-
#[cfg_attr(
15-
dylint_lib = "perfectionist",
16-
expect(
17-
perfectionist::non_exhaustive_error,
18-
reason = "this error type is explicitly exhaustive: `Fraction::new` can only fail in the two ways enumerated below, and any future failure mode would be a `Fraction::new` API change worth a SemVer-major bump",
19-
)
20-
)]
2114
pub enum ConversionError {
2215
/// Provided value is greater than or equal to 1.
2316
#[display("greater than or equal to 1")]
@@ -50,13 +43,6 @@ impl TryFrom<f32> for Fraction {
5043

5144
/// Error that occurs when parsing a string as [`Fraction`].
5245
#[derive(Debug, Display, Error, Clone, PartialEq, Eq)]
53-
#[cfg_attr(
54-
dylint_lib = "perfectionist",
55-
expect(
56-
perfectionist::non_exhaustive_error,
57-
reason = "this error type is explicitly exhaustive: `Fraction::from_str` can only fail in the two ways enumerated below, and any future failure mode would be a `Fraction::from_str` API change worth a SemVer-major bump",
58-
)
59-
)]
6046
pub enum FromStrError {
6147
ParseFloatError(ParseFloatError),
6248
Conversion(ConversionError),

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#![deny(warnings)]
77
#![cfg_attr(dylint_lib = "perfectionist", feature(register_tool))]
88
#![cfg_attr(dylint_lib = "perfectionist", register_tool(perfectionist))]
9-
#![cfg_attr(
10-
dylint_lib = "perfectionist",
11-
deny(perfectionist::non_exhaustive_error)
12-
)]
139

1410
#[cfg(feature = "json")]
1511
pub use serde;

src/visualizer/proportion_bar.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ use std::fmt::{Display, Error, Formatter};
77
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, AsRef, Deref, Into)]
88
pub struct ProportionBarBlock(char);
99

10-
pub const LEVEL0_BLOCK: ProportionBarBlock = ProportionBarBlock('█');
11-
pub const LEVEL1_BLOCK: ProportionBarBlock = ProportionBarBlock('▓');
12-
pub const LEVEL2_BLOCK: ProportionBarBlock = ProportionBarBlock('▒');
13-
pub const LEVEL3_BLOCK: ProportionBarBlock = ProportionBarBlock('░');
14-
pub const LEVEL4_BLOCK: ProportionBarBlock = ProportionBarBlock(' ');
10+
macro_rules! make_const {
11+
($name:ident = $content:literal) => {
12+
pub const $name: ProportionBarBlock = ProportionBarBlock($content);
13+
};
14+
}
15+
16+
make_const!(LEVEL0_BLOCK = '█');
17+
make_const!(LEVEL1_BLOCK = '▓');
18+
make_const!(LEVEL2_BLOCK = '▒');
19+
make_const!(LEVEL3_BLOCK = '░');
20+
make_const!(LEVEL4_BLOCK = ' ');
1521

1622
/// Proportion bar.
1723
#[derive(Debug, Clone, Copy, PartialEq, Eq, From, Into)]

0 commit comments

Comments
 (0)