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

Delete Visibility::Crate and VisCrate #1339

Merged
merged 1 commit into from
Jan 30, 2023
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
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
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