Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
lightningcss_derive is only really intended to be used by lightningcss itself and not by other crates, so just use `crate` to refer to it.
  • Loading branch information
devongovett committed Oct 9, 2023
1 parent 8f7ada0 commit fe91be4
Show file tree
Hide file tree
Showing 41 changed files with 7 additions and 90 deletions.
8 changes: 4 additions & 4 deletions derive/src/into_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub(crate) fn derive_into_owned(input: TokenStream) -> TokenStream {

for type_param in type_param_names {
generics.make_where_clause().predicates.push_value(parse_quote! {
#type_param: 'static + for<'aa> lightningcss::traits::IntoOwned<'aa>
#type_param: 'static + for<'aa> crate::traits::IntoOwned<'aa>
})
}

Expand All @@ -142,7 +142,7 @@ pub(crate) fn derive_into_owned(input: TokenStream) -> TokenStream {

let into_owned = if !has_lifetime {
quote! {
impl #impl_generics lightningcss::traits::IntoOwned<'any> for #self_name #ty_generics #where_clause {
impl #impl_generics crate::traits::IntoOwned<'any> for #self_name #ty_generics #where_clause {
type Owned = Self;

#[inline]
Expand All @@ -154,11 +154,11 @@ pub(crate) fn derive_into_owned(input: TokenStream) -> TokenStream {
} else {
let params = generics.type_params();
quote! {
impl #impl_generics lightningcss::traits::IntoOwned<'any> for #self_name #ty_generics #where_clause {
impl #impl_generics crate::traits::IntoOwned<'any> for #self_name #ty_generics #where_clause {
type Owned = #self_name<'any, #(#params),*>;
/// Consumes the value and returns an owned clone.
fn into_owned(self) -> Self::Owned {
use lightningcss::traits::IntoOwned;
use crate::traits::IntoOwned;

#res
}
Expand Down
2 changes: 0 additions & 2 deletions src/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use std::ops::Range;

use crate::context::PropertyHandlerContext;
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::parser::ParserOptions;
use crate::printer::Printer;
use crate::properties::box_shadow::BoxShadowHandler;
Expand Down
2 changes: 0 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Error types.

#[cfg(not(doctest))]
use crate::lightningcss;
use crate::properties::custom::Token;
use crate::rules::Location;
#[cfg(feature = "into_owned")]
Expand Down
5 changes: 0 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ pub mod visitor;
#[cfg(feature = "serde")]
mod serialization;

/// hack for derive
mod lightningcss {
pub use crate::traits;
}

#[cfg(test)]
mod tests {
use crate::css_modules::{CssModuleExport, CssModuleExports, CssModuleReference, CssModuleReferences};
Expand Down
3 changes: 0 additions & 3 deletions src/media_query.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! Media queries.
use crate::error::{ErrorWithLocation, MinifyError, MinifyErrorKind, ParserError, PrinterError};
#[cfg(feature = "into_owned")]
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::enum_property;
use crate::parser::starts_with_ignore_ascii_case;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::*;
use crate::prefixes::Feature;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::*;
use crate::prefixes::Feature;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/border_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::prefixes::Feature;
use crate::printer::Printer;
use crate::properties::{Property, PropertyId, VendorPrefix};
Expand Down
2 changes: 0 additions & 2 deletions src/properties/contain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#![allow(non_upper_case_globals)]

#[cfg(not(doctest))]
use crate::lightningcss;
use cssparser::*;
use smallvec::SmallVec;

Expand Down
2 changes: 0 additions & 2 deletions src/properties/css_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use crate::dependencies::Location;
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::traits::{Parse, ToCss};
use crate::values::ident::{CustomIdent, CustomIdentList};
Expand Down
2 changes: 0 additions & 2 deletions src/properties/custom.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! CSS custom properties and unparsed token values.

use crate::error::{ParserError, PrinterError, PrinterErrorKind};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::enum_property;
use crate::prefixes::Feature;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/effects.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! CSS properties related to filters and effects.

use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::targets::{Browsers, Targets};
use crate::traits::{FallbackValues, IsCompatible, Parse, ToCss, Zero};
Expand Down
2 changes: 0 additions & 2 deletions src/properties/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use crate::compat::Feature;
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::*;
use crate::printer::Printer;
use crate::targets::should_compile;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{Error, ErrorLocation, ParserError, PrinterError, PrinterErrorKind};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::{define_shorthand, impl_shorthand};
use crate::printer::Printer;
use crate::properties::{Property, PropertyId};
Expand Down
2 changes: 0 additions & 2 deletions src/properties/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use super::{Property, PropertyId};
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::{define_shorthand, enum_property, shorthand_handler, shorthand_property};
use crate::printer::Printer;
use crate::targets::{Browsers, Targets};
Expand Down
2 changes: 0 additions & 2 deletions src/properties/masking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use super::PropertyId;
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::{define_list_shorthand, define_shorthand, enum_property, property_bitflags};
use crate::prefixes::Feature;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ pub mod ui;

use crate::declaration::DeclarationBlock;
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::logical::{LogicalGroup, PropertyCategory};
use crate::parser::starts_with_ignore_ascii_case;
use crate::parser::ParserOptions;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/svg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! CSS properties used in SVG.

use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::enum_property;
use crate::printer::Printer;
use crate::targets::{Browsers, Targets};
Expand Down
2 changes: 0 additions & 2 deletions src/properties/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use crate::compat;
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::{define_shorthand, enum_property};
use crate::prefixes::Feature;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use crate::compat;
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::define_list_shorthand;
use crate::prefixes::Feature;
use crate::printer::Printer;
Expand Down
2 changes: 0 additions & 2 deletions src/properties/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use crate::declaration::DeclarationBlock;
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::{define_shorthand, enum_property, shorthand_property};
use crate::printer::Printer;
use crate::properties::{Property, PropertyId};
Expand Down
2 changes: 0 additions & 2 deletions src/rules/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use cssparser::*;
use super::Location;
use super::{CssRuleList, MinifyContext};
use crate::error::{MinifyError, ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::media_query::{
define_query_features, operation_to_css, parse_query_condition, to_css_with_parens_if_needed, FeatureToCss,
MediaFeatureType, Operator, QueryCondition, QueryConditionFlags, QueryFeature, ValueType,
Expand Down
2 changes: 0 additions & 2 deletions src/rules/counter_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use super::Location;
use crate::declaration::DeclarationBlock;
use crate::error::PrinterError;
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::traits::ToCss;
use crate::values::ident::CustomIdent;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/custom_media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use super::Location;
use crate::error::PrinterError;
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::media_query::MediaList;
use crate::printer::Printer;
use crate::traits::ToCss;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use super::Location;
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::enum_property;
use crate::printer::Printer;
use crate::properties::custom::CustomProperty;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/font_palette_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use super::supports::SupportsRule;
use super::{CssRule, CssRuleList, Location, MinifyContext};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::properties::custom::CustomProperty;
use crate::properties::font::FontFamily;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use super::supports::SupportsCondition;
use super::Location;
use crate::dependencies::{Dependency, ImportDependency};
use crate::error::PrinterError;
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::media_query::MediaList;
use crate::printer::Printer;
use crate::traits::ToCss;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/keyframes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use super::{CssRule, CssRuleList, Location};
use crate::context::DeclarationContext;
use crate::declaration::DeclarationBlock;
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::parser::ParserOptions;
use crate::printer::Printer;
use crate::properties::custom::{CustomProperty, UnparsedProperty};
Expand Down
2 changes: 0 additions & 2 deletions src/rules/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use super::{CssRuleList, Location, MinifyContext};
use crate::error::{MinifyError, ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::parser::DefaultAtRule;
use crate::printer::Printer;
use crate::traits::{Parse, ToCss};
Expand Down
2 changes: 0 additions & 2 deletions src/rules/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use super::Location;
use crate::error::PrinterError;
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::traits::ToCss;
use crate::values::ident::Ident;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use super::Location;
use crate::declaration::{parse_declaration, DeclarationBlock};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::macros::enum_property;
use crate::printer::Printer;
use crate::stylesheet::ParserOptions;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/property.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! The `@property` rule.

use super::Location;
#[cfg(not(doctest))]
use crate::lightningcss;
#[cfg(feature = "visitor")]
use crate::visitor::Visit;
use crate::{
Expand Down
2 changes: 0 additions & 2 deletions src/rules/supports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use super::Location;
use super::{CssRuleList, MinifyContext};
use crate::error::{MinifyError, ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::parser::DefaultAtRule;
use crate::printer::Printer;
use crate::properties::PropertyId;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/unknown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use super::Location;
use crate::error::PrinterError;
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::properties::custom::TokenList;
use crate::traits::ToCss;
Expand Down
2 changes: 0 additions & 2 deletions src/rules/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use super::Location;
use crate::declaration::DeclarationBlock;
use crate::error::PrinterError;
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::traits::ToCss;
use crate::vendor_prefix::VendorPrefix;
Expand Down
2 changes: 0 additions & 2 deletions src/stylesheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::css_modules::{CssModule, CssModuleExports, CssModuleReferences};
use crate::declaration::{DeclarationBlock, DeclarationHandler};
use crate::dependencies::Dependency;
use crate::error::{Error, ErrorLocation, MinifyErrorKind, ParserError, PrinterError, PrinterErrorKind};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::parser::{DefaultAtRule, DefaultAtRuleParser, TopLevelRuleParser};
use crate::printer::Printer;
use crate::rules::{CssRule, CssRuleList, MinifyContext};
Expand Down
2 changes: 0 additions & 2 deletions src/values/ident.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! CSS identifiers.

use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::properties::css_modules::Specifier;
use crate::traits::{Parse, ParseWithOptions, ToCss};
Expand Down
2 changes: 0 additions & 2 deletions src/values/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use super::resolution::Resolution;
use crate::compat;
use crate::dependencies::{Dependency, UrlDependency};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::prefixes::{is_webkit_gradient, Feature};
use crate::printer::Printer;
use crate::targets::{Browsers, Targets};
Expand Down
7 changes: 3 additions & 4 deletions src/values/string.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Types used to represent strings.

#[cfg(not(doctest))]
use crate::lightningcss;
use crate::traits::{IntoOwned, Parse, ToCss};
use crate::traits::{Parse, ToCss};
#[cfg(feature = "visitor")]
use crate::visitor::{Visit, VisitTypes, Visitor};
use cssparser::{serialize_string, CowRcStr};
Expand Down Expand Up @@ -133,7 +131,8 @@ impl<'a> CowArcStr<'a> {
}
}

impl<'any> IntoOwned<'any> for CowArcStr<'_> {
#[cfg(feature = "into_owned")]
impl<'any> crate::traits::IntoOwned<'any> for CowArcStr<'_> {
type Owned = CowArcStr<'any>;

/// Consumes the value and returns an owned clone.
Expand Down
2 changes: 0 additions & 2 deletions src/values/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use super::ident::Ident;
use super::number::{CSSInteger, CSSNumber};
use crate::error::{ParserError, PrinterError};
#[cfg(not(doctest))]
use crate::lightningcss;
use crate::printer::Printer;
use crate::traits::{Parse, ToCss};
use crate::values;
Expand Down

0 comments on commit fe91be4

Please sign in to comment.