-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use proc macro to define Config #3873
Conversation
impl std::fmt::Display for ConfigError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { | ||
match self { | ||
ConfigError::UnstableConfigOption(unstables) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will resolve #3872 correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no, IIRC the issue is that we are parsing the same rustfmt.toml and emitting errors multiple times.
@@ -243,11 +242,11 @@ fn format_string(input: String, options: GetOptsOptions) -> Result<i32, FailureE | |||
let (mut config, _) = load_config(Some(Path::new(".")), Some(options.clone()))?; | |||
|
|||
// emit mode is always Stdout for Stdin. | |||
config.set().emit_mode(EmitMode::Stdout); | |||
config.set().verbose(Verbosity::Quiet); | |||
config.set_emit_mode(EmitMode::Stdout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 definitely a friendly interface on getters/setters
To be honest, I am not sure if this is correct :(
These are now hidden from users
18b683a
to
0474e1b
Compare
I will try this again after 2.0 release 🤷♂️ |
This PR implements a proc macro for defining
Config
struct, which replaces the currentdefine_config
macro.The ultimate goal is to define the config like the following:
and let the config proc macro generate Configurations.md and test code under test/source/configs/ and tests/target/configs/. This PR is the first step toward the goal.
Other minor benefits include the following:
Since the
Config
is part of the public API of rustfmt-as-a-lib, and this PR changes its interface, we should merge this as a part of the preparation for 2.0 release. I am creating a PR at the moment, however, for early feedback.