Skip to content

Commit 154f320

Browse files
authored
Mark unstable parts of config unstable (#3215)
* Mark unstable parts of config unstable * Unstable
1 parent bcb6481 commit 154f320

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

esp-hal-procmacros/src/builder.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const KNOWN_HELPERS: &[&str] = &[
2525
"skip_setter",
2626
// Do not generate a getter
2727
"skip_getter",
28+
// Feature gate the generated setters and getters by the "unstable" feature
29+
"unstable",
2830
];
2931

3032
pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
@@ -53,6 +55,15 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
5355
continue;
5456
}
5557

58+
let unstable = if helper_attributes.iter().any(|h| h == "unstable") {
59+
quote! {
60+
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
61+
#[cfg(feature = "unstable")]
62+
}
63+
} else {
64+
quote! {}
65+
};
66+
5667
let field_ident = field.ident.as_ref().unwrap();
5768
let field_type = &field.ty;
5869

@@ -86,6 +97,7 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
8697
if !helper_attributes.iter().any(|h| h == "skip_setter") {
8798
fns.push(quote! {
8899
#[doc = concat!(" Assign the given value to the `", stringify!(#field_ident) ,"` field.")]
100+
#unstable
89101
#[must_use]
90102
pub fn #function_ident(mut self, #field_ident: #field_setter_type) -> Self {
91103
self.#field_ident = #field_assigns;
@@ -97,6 +109,7 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
97109
let function_ident = format_ident!("with_{}_none", field_ident);
98110
fns.push(quote! {
99111
#[doc = concat!(" Set the value of `", stringify!(#field_ident), "` to `None`.")]
112+
#unstable
100113
#[must_use]
101114
pub fn #function_ident(mut self) -> Self {
102115
self.#field_ident = None;
@@ -121,6 +134,7 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
121134
});
122135
fns.push(quote! {
123136
#(#docs)*
137+
#unstable
124138
pub fn #field_ident(&self) -> #field_type {
125139
self.#field_ident
126140
}

esp-hal/src/spi/master.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ pub struct Config {
449449
frequency: Rate,
450450

451451
/// The clock source
452-
#[cfg_attr(not(feature = "unstable"), builder_lite(skip))]
452+
#[builder_lite(unstable)]
453453
#[builder_lite(skip_setter)]
454454
clock_source: ClockSource,
455455

esp-hal/src/uart.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ pub struct Config {
242242
baudrate: u32,
243243
/// Determines how close to the desired baud rate value the driver should
244244
/// set the baud rate.
245+
#[builder_lite(unstable)]
245246
baudrate_tolerance: BaudrateTolerance,
246247
/// Number of data bits in each frame (5, 6, 7, or 8 bits).
247248
data_bits: DataBits,
@@ -250,7 +251,7 @@ pub struct Config {
250251
/// Number of stop bits in each frame (1, 1.5, or 2 bits).
251252
stop_bits: StopBits,
252253
/// Clock source used by the UART peripheral.
253-
#[cfg_attr(not(feature = "unstable"), builder_lite(skip))]
254+
#[builder_lite(unstable)]
254255
clock_source: ClockSource,
255256
/// UART Receive part configuration.
256257
rx: RxConfig,

0 commit comments

Comments
 (0)