Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Apr 11, 2023
1 parent 5df8630 commit 537f3ce
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

//! Emit warnings from inside proc macros.
use core::ops::Deref;
use proc_macro2::Span;

/// Creates a compile-time warning for proc macro use. See [DeprecatedWarningBuilder] for usage.
Expand All @@ -23,23 +24,23 @@ pub struct Warning {
/// use proc_macro_warning::Warning;
///
/// let warning = Warning::new_deprecated("my_macro")
/// .old("my_macro()")
/// .new("my_macro::new()")
/// .help_link("https:://example.com")
/// .span(proc_macro2::Span::call_site())
/// .build();
/// .old("my_macro()")
/// .new("my_macro::new()")
/// .help_link("https:://example.com")
/// .span(proc_macro2::Span::call_site())
/// .build();
///
/// // Use the warning in a proc macro
/// let tokens = quote::quote!(#warning);
///
/// let warnings = vec![warning];
/// // In a proc macro you would expand them inside a module:
/// quote::quote! {
/// mod warnings {
/// #(
/// #warnings
/// )*
/// }
/// mod warnings {
/// #(
/// #warnings
/// )*
/// }
/// };
/// ```
#[derive(Default)]
Expand Down Expand Up @@ -94,7 +95,7 @@ impl DeprecatedWarningBuilder {
/// Multiple help links for the user to explain the transition and justification.
#[must_use]
pub fn help_links(self, links: &[&str]) -> DeprecatedWarningBuilder {
DeprecatedWarningBuilder { links: links.iter().map(|s| s.clone().into()).collect(), ..self }
DeprecatedWarningBuilder { links: links.iter().map(|s| s.deref().into()).collect(), ..self }
}

/// The span of the warning.
Expand All @@ -104,7 +105,6 @@ impl DeprecatedWarningBuilder {
}

/// Build the warning.
#[must_use]
pub fn maybe_build(self) -> Result<Warning, String> {
let span = self.span.unwrap_or_else(Span::call_site);
let title = self.title;
Expand Down

0 comments on commit 537f3ce

Please sign in to comment.