Skip to content

Commit 54bf9ca

Browse files
authored
Make prettyplease non-optional (#2491)
* Make `prettyplease` non-optional This PR makes the `prettyplease` dependency on `bindgen` non-optional. Meaning that the `Builder::no_rustfmt_bindings` method and its equivalent flag are now deprecated.
1 parent 5d1c79a commit 54bf9ca

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,16 @@
162162
# Unreleased
163163

164164
## Added
165-
* Added the `Bindgen::default_visibility` method and the
165+
* Added the `Builder::default_visibility` method and the
166166
`--default-visibility` flag to set the default visibility of fields.
167167
* Added the `--formatter` CLI flag with the values `none`, `rustfmt` and
168168
`prettyplease` to select which tool will be used to format the bindings. The
169169
default value is `rustfmt`.
170170
* Added the `Builder::formatter` method and the `Formatter` type to select
171-
which tool will be used to format the bindings. The
172-
`Formatter::Prettyplease` variant is only available if the
173-
`"prettyplease"` feature is enabled.
171+
which tool will be used to format the bindings.
174172
* Added the `Builder::emit_diagnostics` method and the `--emit-diagnostics`
175-
flag to enable emission of diagnostic messages.
173+
flag to enable emission of diagnostic messages under the `experimental`
174+
feature.
176175
* Added support for the `"efiapi"` calling convention.
177176
* Added the `ParseCallbacks::read_env_var` method which runs everytime
178177
`bindgen` reads and environment variable.
@@ -189,11 +188,12 @@
189188
* The documentation of the generated `type` aliases now matches the comments
190189
of their `typedef` counterparts instead of using the comments of the aliased
191190
types.
191+
* The `Builder::rustfmt_bindings` methods and the `--no-rustfmt-bindings` flag
192+
are now deprecated in favor of the formatter API.
192193

193194
## Removed
194195
* The following deprecated flags were removed: `--use-msvc-mangling`,
195196
`--rustfmt-bindings` and `--size_t-is-usize`.
196-
* The `--no-rustfmt-bindings` flag was removed in favor of `--formatter=none`.
197197
* The `Bindings::emit_warnings` and `Bindings::warnings` methods were removed
198198
in favor of `--emit-diagnostics`.
199199
* Bindgen no longer generates C string constants that cannot be represented as

bindgen-cli/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ env_logger = { version = "0.10.0", optional = true }
2828
log = { version = "0.4", optional = true }
2929

3030
[features]
31-
default = ["logging", "runtime", "which-rustfmt", "prettyplease"]
31+
default = ["logging", "runtime", "which-rustfmt"]
3232
logging = ["bindgen/logging", "env_logger", "log"]
3333
static = ["bindgen/static"]
3434
runtime = ["bindgen/runtime"]
3535
# Dynamically discover a `rustfmt` binary using the `which` crate
3636
which-rustfmt = ["bindgen/which-rustfmt"]
37-
prettyplease = ["bindgen/prettyplease"]

bindgen-cli/options.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ struct BindgenCommand {
266266
/// Do not bind size_t as usize (useful on platforms where those types are incompatible).
267267
#[arg(long = "no-size_t-is-usize")]
268268
no_size_t_is_usize: bool,
269-
/// Do not format the generated bindings with rustfmt.
269+
/// Do not format the generated bindings with rustfmt. This option is deprecated, please use
270+
/// `--formatter=none` instead.
270271
#[arg(long)]
271272
no_rustfmt_bindings: bool,
272273
/// Which tool should be used to format the bindings
@@ -833,9 +834,8 @@ where
833834
builder = builder.size_t_is_usize(false);
834835
}
835836

836-
#[allow(deprecated)]
837837
if no_rustfmt_bindings {
838-
builder = builder.rustfmt_bindings(false);
838+
builder = builder.formatter(Formatter::None);
839839
}
840840

841841
if let Some(formatter) = formatter {

bindgen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ quote = { version = "1", default-features = false }
3535
syn = { version = "2.0", features = ["full", "extra-traits", "visit-mut"]}
3636
regex = { version = "1.5", default-features = false , features = ["std", "unicode"] }
3737
which = { version = "4.2.1", optional = true, default-features = false }
38-
prettyplease = { version = "0.2.0", optional = true }
38+
prettyplease = { version = "0.2.0" }
3939
annotate-snippets = { version = "0.9.1", features = ["color"], optional = true }
4040
shlex = "1"
4141
rustc-hash = "1.0.1"

bindgen/options/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,13 +1574,13 @@ options! {
15741574
/// The tool that should be used to format the generated bindings.
15751575
formatter: Formatter {
15761576
methods: {
1577-
#[cfg_attr(feature = "prettyplease", deprecated)]
15781577
/// Set whether `rustfmt` should be used to format the generated bindings.
15791578
///
15801579
/// `rustfmt` is used by default.
15811580
///
15821581
/// This method overlaps in functionality with the more general [`Builder::formatter`].
15831582
/// Thus, the latter should be preferred.
1583+
#[cfg(deprecated)]
15841584
pub fn rustfmt_bindings(mut self, doit: bool) -> Self {
15851585
self.options.formatter = if doit {
15861586
Formatter::Rustfmt

0 commit comments

Comments
 (0)