Skip to content

Commit f6db378

Browse files
authored
feat: allow use statements to be marked unstable (#11)
This allows the pattern of re-exporting code defined in private modules, while still requiring the unstable feature to be enabled.
1 parent 71210c1 commit f6db378

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

example/src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,17 @@ pub fn risky_function() {
1818
pub struct RiskyStruct {
1919
pub x: u8,
2020
}
21+
22+
mod private {
23+
/// This function does something really risky!
24+
///
25+
/// Don't use it yet!
26+
#[stability::unstable(feature = "risky-private-function")]
27+
pub fn risky_private_function() {
28+
unimplemented!()
29+
}
30+
}
31+
32+
#[allow(unused_imports)]
33+
#[stability::unstable(feature = "risky-private-function")]
34+
pub use private::risky_private_function;

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub fn unstable(args: TokenStream, input: TokenStream) -> TokenStream {
122122
Item::Trait(item_trait) => attributes.expand(item_trait),
123123
Item::Const(item_const) => attributes.expand(item_const),
124124
Item::Static(item_static) => attributes.expand(item_static),
125+
Item::Use(item_use) => attributes.expand(item_use),
125126
_ => panic!("unsupported item type"),
126127
}
127128
}

src/unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl_has_visibility!(
136136
syn::ItemTrait,
137137
syn::ItemConst,
138138
syn::ItemStatic,
139+
syn::ItemUse,
139140
);
140141

141142
impl ItemLike for syn::ItemStruct {

0 commit comments

Comments
 (0)