Skip to content
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

feat: allow use statements to be marked unstable #3

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,17 @@ pub fn risky_function() {
pub struct RiskyStruct {
pub x: u8,
}

mod private {
/// This function does something really risky!
///
/// Don't use it yet!
#[stability::unstable(feature = "risky-private-function")]
pub fn risky_private_function() {
unimplemented!()
}
}

#[allow(unused_imports)]
#[stability::unstable(feature = "risky-private-function")]
pub use private::risky_private_function;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn unstable(args: TokenStream, input: TokenStream) -> TokenStream {
Item::Trait(item_trait) => attributes.expand(item_trait),
Item::Const(item_const) => attributes.expand(item_const),
Item::Static(item_static) => attributes.expand(item_static),
Item::Use(item_use) => attributes.expand(item_use),
_ => panic!("unsupported item type"),
}
}
2 changes: 2 additions & 0 deletions src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl UnstableAttribute {
}

pub(crate) trait ItemLike {
#[allow(unused)]
fn attrs(&self) -> &[syn::Attribute];

fn push_attr(&mut self, attr: syn::Attribute);
Expand Down Expand Up @@ -136,6 +137,7 @@ impl_has_visibility!(
syn::ItemTrait,
syn::ItemConst,
syn::ItemStatic,
syn::ItemUse,
);

impl ItemLike for syn::ItemStruct {
Expand Down