Skip to content

Commit

Permalink
Merge pull request 1339 from dtolnay/viscrate
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 30, 2023
2 parents 8903d4d + a70085f commit 0911436
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 178 deletions.
30 changes: 0 additions & 30 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ ast_enum_of_structs! {
/// A public visibility level: `pub`.
Public(VisPublic),

/// A crate-level visibility: `crate`.
Crate(VisCrate),

/// A visibility level restricted to some path: `pub(self)` or
/// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
Restricted(VisRestricted),
Expand All @@ -189,14 +186,6 @@ ast_struct! {
}
}

ast_struct! {
/// A crate-level visibility: `crate`.
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))]
pub struct VisCrate {
pub crate_token: Token![crate],
}
}

ast_struct! {
/// A visibility level restricted to some path: `pub(self)` or
/// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
Expand Down Expand Up @@ -313,8 +302,6 @@ pub mod parsing {

if input.peek(Token![pub]) {
Self::parse_pub(input)
} else if input.peek(Token![crate]) {
Self::parse_crate(input)
} else {
Ok(Visibility::Inherited)
}
Expand Down Expand Up @@ -366,16 +353,6 @@ pub mod parsing {
Ok(Visibility::Public(VisPublic { pub_token }))
}

fn parse_crate(input: ParseStream) -> Result<Self> {
if input.peek2(Token![::]) {
Ok(Visibility::Inherited)
} else {
Ok(Visibility::Crate(VisCrate {
crate_token: input.parse()?,
}))
}
}

#[cfg(feature = "full")]
pub(crate) fn is_some(&self) -> bool {
match self {
Expand Down Expand Up @@ -444,13 +421,6 @@ mod printing {
}
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for VisCrate {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.crate_token.to_tokens(tokens);
}
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for VisRestricted {
fn to_tokens(&self, tokens: &mut TokenStream) {
Expand Down
10 changes: 0 additions & 10 deletions src/gen/clone.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions src/gen/debug.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/gen/eq.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions src/gen/fold.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions src/gen/hash.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions src/gen/visit.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions src/gen/visit_mut.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ mod custom_punctuation;
mod data;
#[cfg(any(feature = "full", feature = "derive"))]
pub use crate::data::{
Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted,
Visibility,
Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisPublic, VisRestricted, Visibility,
};

#[cfg(any(feature = "full", feature = "derive"))]
Expand Down
2 changes: 1 addition & 1 deletion src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ mod printing {
use crate::attr::FilterAttrs;
use proc_macro2::TokenStream;
use quote::{ToTokens, TokenStreamExt};

#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for PatIdent {
fn to_tokens(&self, tokens: &mut TokenStream) {
Expand Down
19 changes: 0 additions & 19 deletions syn.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions tests/debug/gen.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions tests/test_derive_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,25 +469,6 @@ fn test_pub_restricted() {
"###);
}

#[test]
fn test_vis_crate() {
let input = quote! {
crate struct S;
};

snapshot!(input as DeriveInput, @r###"
DeriveInput {
vis: Visibility::Crate,
ident: "S",
generics: Generics,
data: Data::Struct {
fields: Unit,
semi_token: Some,
},
}
"###);
}

#[test]
fn test_pub_restricted_crate() {
let input = quote! {
Expand Down
5 changes: 0 additions & 5 deletions tests/test_visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ fn test_pub() {
assert_vis_parse!("pub", Ok(Visibility::Public(_)));
}

#[test]
fn test_crate() {
assert_vis_parse!("crate", Ok(Visibility::Crate(_)));
}

#[test]
fn test_inherited() {
assert_vis_parse!("", Ok(Visibility::Inherited));
Expand Down

0 comments on commit 0911436

Please sign in to comment.