Open
Description
rustfmt currently provides the ability to print configuration details in various forms:
default
(documented briefly here) which dumps the full set of configuration options with their default values, regardless any existing detected or specified configuration inputscurrent
- dumps the configuration incorporating specified and detected values (e.g. any additionally included command line flags, detected configuration files, etc.)minimal
- the subset of the configurations fromcurrent
that are actively utilized when formatting some specified input code/file (the primary use case for this is to help users locate unused/inoperable options and to be able to remove them from their rustfmt config file)
in #6247 there was some discussion about potential enhancements to this current configuration printing feature, and I'd suggest there's two potential (non mutually exclusive) items we could consider:
- show the full set of configuration options with the default values based on the specified style edition
- show the subset of configuration options that changed for a specified style edition
Activity
calebcartwright commentedon Jul 28, 2024
This could technically be obtained via the existing
current
variant in some situations (but not always). I think there's value in being able to do this explicitly in all situations, so I'd support a future enhancement that enabled this use case/capability.However, I would be firmly opposed to modifying the existing behavior of the
default
variant for a few reasons:One example of the confusing behavior relates to RFC 3338 which dictates that:
which means that, unless a style edition is otherwise explicitly specified,
rustfmt
will use the same edition of the style guide that it does for parsing, i.e.rustfmt foo.rs --edition 2024 ...
is analogous torustfmt foo.rs --style-edition 2024 ...
today the output of
rustfmt --edition 2024 --print-config default
will includeedition = "2015"
(remember thatdefault
is explicitly outputting defaults, independent of inputs).however, the inclusion of RFC 3338 meaning that the
--edition 2024
flag is the same as--style-edition 2024
which means that the output of this command would (a) change from what it's always printed (as the 2024 style edition has different defaults) and (b) would either require additional changes or the output would be confusing, e.g. what should theedition = ?
value be?)in my opinion, the best path forward to support this would be a new variant on the
--print-config
behavior, one that just directly adds the ability to display the config defaults for a specified style editioncalebcartwright commentedon Jul 28, 2024
This seems useful as well, though it's also something I'd prefer to see as a net new variant/feature instead of trying to mash it into one of the existing ones