Skip to content

Commit

Permalink
Clamp width settings to max_width before warning about exceeding it
Browse files Browse the repository at this point in the history
Within a macro scope, max_width is reduced, which can trigger warnings
if it is reduced below some other width setting (e.g. struct_lit_width.)
Width settings were already being clamped to max_width, but only after
the warning fired.  The order is now reversed.
  • Loading branch information
rs-sac committed Oct 7, 2024
1 parent 5f48fe9 commit c01937b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,18 +431,24 @@ macro_rules! create_config {
heuristic_value: usize,
config_key: &str,
| -> usize {
if !was_set {
return heuristic_value;
}
if override_value > max_width {
let value = if !was_set {
heuristic_value
} else {
override_value
};

let value = value.min(max_width);

if value > max_width {
eprintln!(
"`{0}` cannot have a value that exceeds `max_width`. \
`{0}` will be set to the same value as `max_width`",
config_key,
);
return max_width;
max_width
} else {
value
}
override_value
};

let fn_call_width = get_width_value(
Expand Down

0 comments on commit c01937b

Please sign in to comment.