From 545fd578473ebec5c52dfe468dbe56aa6dc1425e Mon Sep 17 00:00:00 2001 From: Michael Watzko Date: Thu, 30 Apr 2020 20:58:30 +0200 Subject: [PATCH] Simplyfied required imports --- asn1rs-model/src/gen/rust/walker.rs | 4 +--- src/lib.rs | 7 +++++++ tests/basic_proc_macro_attribute.rs | 8 ++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/asn1rs-model/src/gen/rust/walker.rs b/asn1rs-model/src/gen/rust/walker.rs index 7c3f71df..243983ba 100644 --- a/asn1rs-model/src/gen/rust/walker.rs +++ b/asn1rs-model/src/gen/rust/walker.rs @@ -458,9 +458,7 @@ impl AsnDefWalker { } impl GeneratorSupplement for AsnDefWalker { - fn add_imports(&self, scope: &mut Scope) { - scope.raw("use asn1rs::prelude::*;"); - } + fn add_imports(&self, _scope: &mut Scope) {} fn impl_supplement(&self, scope: &mut Scope, definition: &Definition) { self.write_type_definitions(scope, definition); diff --git a/src/lib.rs b/src/lib.rs index 1b4acd95..2be8847b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,10 @@ extern crate postgres; #[cfg(feature = "macros")] pub extern crate asn1rs_macros as macros; +// provide an empty module, so that `use asn1rs::macros::*;` does not fail +#[cfg(not(feature = "macros"))] +pub mod macros {} + #[cfg(feature = "model")] pub mod converter; #[cfg(feature = "model")] @@ -20,5 +24,8 @@ pub mod io; pub mod syn; pub mod prelude { + #[cfg(feature = "macros")] + pub use crate::macros::*; + pub use crate::syn::io::*; pub use crate::syn::*; } diff --git a/tests/basic_proc_macro_attribute.rs b/tests/basic_proc_macro_attribute.rs index 7be18bec..5a58ef88 100644 --- a/tests/basic_proc_macro_attribute.rs +++ b/tests/basic_proc_macro_attribute.rs @@ -1,8 +1,4 @@ -#![allow(unused)] - -use asn1rs::syn::io::{PrintlnWriter, UperReader, UperWriter}; -use asn1rs::syn::Reader; -use asn1rs_macros::asn; +use asn1rs::prelude::*; #[asn(sequence)] #[derive(Debug, Default, PartialOrd, PartialEq)] @@ -19,7 +15,7 @@ pub struct Potato { #[test] fn test_compiles() { - let p = Potato { + let _p = Potato { size: 123, size2: 1234, size3: 234,