Skip to content

Commit

Permalink
Stop using #[macro_use] on lazy_static
Browse files Browse the repository at this point in the history
  • Loading branch information
goffrie committed Feb 12, 2024
1 parent 5ad7c0d commit 07f7882
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 121 deletions.
4 changes: 1 addition & 3 deletions pb-jelly-gen/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> {
});
});

block(ctx, "lazy_static!", |ctx| {
block(ctx, "::lazy_static::lazy_static!", |ctx| {
ctx.write(format!(
"pub static ref {name}_default: {escaped_name} = {escaped_name}::default();"
));
Expand Down Expand Up @@ -2442,8 +2442,6 @@ impl<'a> Context<'a> {

for crate_name in self.deps_map.borrow().keys() {
let mut librs = String::new();
writeln!(&mut librs, "#[macro_use]").unwrap();
writeln!(&mut librs, "extern crate lazy_static;").unwrap();
if derive_serde {
writeln!(&mut librs, "#[macro_use]").unwrap();
writeln!(&mut librs, "extern crate serde;").unwrap();
Expand Down
3 changes: 0 additions & 3 deletions pb-jelly-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ use std::{
};
use walkdir::WalkDir;

#[macro_use]
extern crate lazy_static;

pub mod codegen;
/// Don't depend on this module, it's only public so that `protoc-gen-jellyrust` can use it
#[doc(hidden)]
Expand Down
72 changes: 36 additions & 36 deletions pb-jelly-gen/src/protos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref Version_default: Version = Version::default();
}
impl ::pb_jelly::Message for Version {
Expand Down Expand Up @@ -456,7 +456,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref CodeGeneratorRequest_default: CodeGeneratorRequest = CodeGeneratorRequest::default();
}
impl ::pb_jelly::Message for CodeGeneratorRequest {
Expand Down Expand Up @@ -716,7 +716,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref CodeGeneratorResponse_default: CodeGeneratorResponse = CodeGeneratorResponse::default();
}
impl ::pb_jelly::Message for CodeGeneratorResponse {
Expand Down Expand Up @@ -972,7 +972,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref CodeGeneratorResponse_File_default: CodeGeneratorResponse_File = CodeGeneratorResponse_File::default();
}
impl ::pb_jelly::Message for CodeGeneratorResponse_File {
Expand Down Expand Up @@ -3165,7 +3165,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FileDescriptorSet_default: FileDescriptorSet = FileDescriptorSet::default();
}
impl ::pb_jelly::Message for FileDescriptorSet {
Expand Down Expand Up @@ -3451,7 +3451,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FileDescriptorProto_default: FileDescriptorProto = FileDescriptorProto::default();
}
impl ::pb_jelly::Message for FileDescriptorProto {
Expand Down Expand Up @@ -4033,7 +4033,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref DescriptorProto_default: DescriptorProto = DescriptorProto::default();
}
impl ::pb_jelly::Message for DescriptorProto {
Expand Down Expand Up @@ -4431,7 +4431,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref DescriptorProto_ExtensionRange_default: DescriptorProto_ExtensionRange = DescriptorProto_ExtensionRange::default();
}
impl ::pb_jelly::Message for DescriptorProto_ExtensionRange {
Expand Down Expand Up @@ -4602,7 +4602,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref DescriptorProto_ReservedRange_default: DescriptorProto_ReservedRange = DescriptorProto_ReservedRange::default();
}
impl ::pb_jelly::Message for DescriptorProto_ReservedRange {
Expand Down Expand Up @@ -4779,7 +4779,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref ExtensionRangeOptions_default: ExtensionRangeOptions = ExtensionRangeOptions::default();
}
impl ::pb_jelly::Message for ExtensionRangeOptions {
Expand Down Expand Up @@ -5038,7 +5038,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref ExtensionRangeOptions_Declaration_default: ExtensionRangeOptions_Declaration = ExtensionRangeOptions_Declaration::default();
}
impl ::pb_jelly::Message for ExtensionRangeOptions_Declaration {
Expand Down Expand Up @@ -5419,7 +5419,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FieldDescriptorProto_default: FieldDescriptorProto = FieldDescriptorProto::default();
}
impl ::pb_jelly::Message for FieldDescriptorProto {
Expand Down Expand Up @@ -5823,7 +5823,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref OneofDescriptorProto_default: OneofDescriptorProto = OneofDescriptorProto::default();
}
impl ::pb_jelly::Message for OneofDescriptorProto {
Expand Down Expand Up @@ -6019,7 +6019,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref EnumDescriptorProto_default: EnumDescriptorProto = EnumDescriptorProto::default();
}
impl ::pb_jelly::Message for EnumDescriptorProto {
Expand Down Expand Up @@ -6259,7 +6259,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref EnumDescriptorProto_EnumReservedRange_default: EnumDescriptorProto_EnumReservedRange = EnumDescriptorProto_EnumReservedRange::default();
}
impl ::pb_jelly::Message for EnumDescriptorProto_EnumReservedRange {
Expand Down Expand Up @@ -6413,7 +6413,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref EnumValueDescriptorProto_default: EnumValueDescriptorProto = EnumValueDescriptorProto::default();
}
impl ::pb_jelly::Message for EnumValueDescriptorProto {
Expand Down Expand Up @@ -6603,7 +6603,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref ServiceDescriptorProto_default: ServiceDescriptorProto = ServiceDescriptorProto::default();
}
impl ::pb_jelly::Message for ServiceDescriptorProto {
Expand Down Expand Up @@ -6836,7 +6836,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref MethodDescriptorProto_default: MethodDescriptorProto = MethodDescriptorProto::default();
}
impl ::pb_jelly::Message for MethodDescriptorProto {
Expand Down Expand Up @@ -7446,7 +7446,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FileOptions_default: FileOptions = FileOptions::default();
}
impl ::pb_jelly::Message for FileOptions {
Expand Down Expand Up @@ -8289,7 +8289,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref MessageOptions_default: MessageOptions = MessageOptions::default();
}
impl ::pb_jelly::Message for MessageOptions {
Expand Down Expand Up @@ -8777,7 +8777,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FieldOptions_default: FieldOptions = FieldOptions::default();
}
impl ::pb_jelly::Message for FieldOptions {
Expand Down Expand Up @@ -9232,7 +9232,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FieldOptions_EditionDefault_default: FieldOptions_EditionDefault = FieldOptions_EditionDefault::default();
}
impl ::pb_jelly::Message for FieldOptions_EditionDefault {
Expand Down Expand Up @@ -9381,7 +9381,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref OneofOptions_default: OneofOptions = OneofOptions::default();
}
impl ::pb_jelly::Message for OneofOptions {
Expand Down Expand Up @@ -9588,7 +9588,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref EnumOptions_default: EnumOptions = EnumOptions::default();
}
impl ::pb_jelly::Message for EnumOptions {
Expand Down Expand Up @@ -9860,7 +9860,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref EnumValueOptions_default: EnumValueOptions = EnumValueOptions::default();
}
impl ::pb_jelly::Message for EnumValueOptions {
Expand Down Expand Up @@ -10096,7 +10096,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref ServiceOptions_default: ServiceOptions = ServiceOptions::default();
}
impl ::pb_jelly::Message for ServiceOptions {
Expand Down Expand Up @@ -10316,7 +10316,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref MethodOptions_default: MethodOptions = MethodOptions::default();
}
impl ::pb_jelly::Message for MethodOptions {
Expand Down Expand Up @@ -10597,7 +10597,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref UninterpretedOption_default: UninterpretedOption = UninterpretedOption::default();
}
impl ::pb_jelly::Message for UninterpretedOption {
Expand Down Expand Up @@ -10888,7 +10888,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref UninterpretedOption_NamePart_default: UninterpretedOption_NamePart = UninterpretedOption_NamePart::default();
}
impl ::pb_jelly::Message for UninterpretedOption_NamePart {
Expand Down Expand Up @@ -11082,7 +11082,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FeatureSet_default: FeatureSet = FeatureSet::default();
}
impl ::pb_jelly::Message for FeatureSet {
Expand Down Expand Up @@ -11358,7 +11358,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FeatureSetDefaults_default: FeatureSetDefaults = FeatureSetDefaults::default();
}
impl ::pb_jelly::Message for FeatureSetDefaults {
Expand Down Expand Up @@ -11531,7 +11531,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref FeatureSetDefaults_FeatureSetEditionDefault_default: FeatureSetDefaults_FeatureSetEditionDefault = FeatureSetDefaults_FeatureSetEditionDefault::default();
}
impl ::pb_jelly::Message for FeatureSetDefaults_FeatureSetEditionDefault {
Expand Down Expand Up @@ -11710,7 +11710,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref SourceCodeInfo_default: SourceCodeInfo = SourceCodeInfo::default();
}
impl ::pb_jelly::Message for SourceCodeInfo {
Expand Down Expand Up @@ -11945,7 +11945,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref SourceCodeInfo_Location_default: SourceCodeInfo_Location = SourceCodeInfo_Location::default();
}
impl ::pb_jelly::Message for SourceCodeInfo_Location {
Expand Down Expand Up @@ -12186,7 +12186,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref GeneratedCodeInfo_default: GeneratedCodeInfo = GeneratedCodeInfo::default();
}
impl ::pb_jelly::Message for GeneratedCodeInfo {
Expand Down Expand Up @@ -12345,7 +12345,7 @@ pub mod google {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref GeneratedCodeInfo_Annotation_default: GeneratedCodeInfo_Annotation = GeneratedCodeInfo_Annotation::default();
}
impl ::pb_jelly::Message for GeneratedCodeInfo_Annotation {
Expand Down
2 changes: 0 additions & 2 deletions pb-test/gen/pb-jelly/proto_google/src/lib.rs.expected
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
// TODO: Ideally we don't allow this
#![allow(clippy::match_single_binding)]

#[macro_use]
extern crate lazy_static;

pub mod protobuf;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl ::std::default::Default for Empty {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref Empty_default: Empty = Empty::default();
}
impl ::pb_jelly::Message for Empty {
Expand Down
2 changes: 0 additions & 2 deletions pb-test/gen/pb-jelly/proto_nopackage/src/lib.rs.expected
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
// TODO: Ideally we don't allow this
#![allow(clippy::match_single_binding)]

#[macro_use]
extern crate lazy_static;

pub mod proto_nopackage;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl ::std::default::Default for NoPackage {
}
}
}
lazy_static! {
::lazy_static::lazy_static! {
pub static ref NoPackage_default: NoPackage = NoPackage::default();
}
impl ::pb_jelly::Message for NoPackage {
Expand Down
Loading

0 comments on commit 07f7882

Please sign in to comment.