Description
rustfmt's configuration loading/building process includes a flag that indicates whether the user explicitly set the value. However, for unknown reasons, that flag is only captured when the config option is specified from two of the three possible ways.
The third way configuration values can be set is directly via a CLI flag, such as --edition
or --unstable-features
, but when options are set this way they aren't properly "flagged" as having been set by the user.
Internally rustfmt uses this was_set()
flag for various options for various reasons, so this gap has been a minor inconvenience in the past. While working on some 2024 edition work I found this inconvenience had escalated to a more problematic state and I think it's something that we need to address (though I think we can technically work around it if we must)
Some relevant code blocks
rustfmt/src/config/config_type.rs
Lines 86 to 92 in ea02de2
Lines 729 to 733 in ea02de2
Here the flag is set (for options specified in the config file or via the --config ...
command line
rustfmt/src/config/config_type.rs
Lines 188 to 196 in ea02de2
rustfmt/src/config/config_type.rs
Lines 262 to 286 in ea02de2
Whereas config options set programmatically by rustfmt (e.g. via a top-level cli option) are not:
rustfmt/src/config/config_type.rs
Lines 114 to 119 in ea02de2