Skip to content

Commit

Permalink
Remove DeprecationNotes feature
Browse files Browse the repository at this point in the history
This was never used within the crate
  • Loading branch information
TedDriggs committed Oct 2, 2024
1 parent 2418ab4 commit d2efc54
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 135 deletions.
9 changes: 1 addition & 8 deletions derive_builder_core/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use quote::{format_ident, ToTokens, TokenStreamExt};
use syn::punctuated::Punctuated;
use syn::{Path, TraitBound, TraitBoundModifier, TypeParamBound};

use crate::{
doc_comment_from, BuildMethod, BuilderField, BuilderPattern, DeprecationNotes, Setter,
};
use crate::{doc_comment_from, BuildMethod, BuilderField, BuilderPattern, Setter};

const ALLOC_NOT_ENABLED_ERROR: &str = r#"`alloc` is disabled within 'derive_builder', consider one of the following:
* enable feature `alloc` on 'dervie_builder' if a `global_allocator` is present
Expand Down Expand Up @@ -146,8 +144,6 @@ pub struct Builder<'a> {
pub must_derive_clone: bool,
/// Doc-comment of the builder struct.
pub doc_comment: Option<syn::Attribute>,
/// Emit deprecation notes to the user.
pub deprecation_notes: DeprecationNotes,
/// Whether or not a libstd is used.
pub std: bool,
}
Expand Down Expand Up @@ -192,7 +188,6 @@ impl<'a> ToTokens for Builder<'a> {
let impl_attrs = self.impl_attrs;

let builder_doc_comment = &self.doc_comment;
let deprecation_notes = &self.deprecation_notes.as_item();

#[cfg(not(feature = "clippy"))]
tokens.append_all(quote!(#[allow(clippy::all)]));
Expand All @@ -217,7 +212,6 @@ impl<'a> ToTokens for Builder<'a> {
#[allow(dead_code)]
impl #impl_generics #builder_ident #impl_ty_generics #impl_where_clause {
#(#functions)*
#deprecation_notes

/// Create an empty builder, with all fields set to `None` or `PhantomData`.
fn #create_empty() -> Self {
Expand Down Expand Up @@ -396,7 +390,6 @@ macro_rules! default_builder {
no_alloc: false,
must_derive_clone: true,
doc_comment: None,
deprecation_notes: DeprecationNotes::default(),
std: true,
}
};
Expand Down
103 changes: 0 additions & 103 deletions derive_builder_core/src/deprecation_notes.rs

This file was deleted.

2 changes: 0 additions & 2 deletions derive_builder_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ mod builder;
mod builder_field;
mod change_span;
mod default_expression;
mod deprecation_notes;
mod doc_comment;
mod initializer;
mod macro_options;
Expand All @@ -47,7 +46,6 @@ pub(crate) use builder_field::{BuilderField, BuilderFieldType};
pub(crate) use change_span::change_span;
use darling::FromDeriveInput;
pub(crate) use default_expression::DefaultExpression;
pub(crate) use deprecation_notes::DeprecationNotes;
pub(crate) use doc_comment::doc_comment_from;
pub(crate) use initializer::{FieldConversion, Initializer};
pub(crate) use options::{BuilderPattern, Each};
Expand Down
11 changes: 1 addition & 10 deletions derive_builder_core/src/macro_options/darling_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use syn::{spanned::Spanned, Attribute, Generics, Ident, Meta, Path};

use crate::{
BlockContents, Builder, BuilderField, BuilderFieldType, BuilderPattern, DefaultExpression,
DeprecationNotes, Each, FieldConversion, Initializer, Setter,
Each, FieldConversion, Initializer, Setter,
};

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -587,9 +587,6 @@ pub struct Options {

#[darling(default)]
field: VisibilityAttr,

#[darling(skip, default)]
deprecation_notes: DeprecationNotes,
}

/// Accessors for parsed properties.
Expand Down Expand Up @@ -689,7 +686,6 @@ impl Options {
no_alloc: cfg!(not(any(feature = "alloc", feature = "lib_has_std"))),
must_derive_clone: self.requires_clone(),
doc_comment: None,
deprecation_notes: Default::default(),
std: !self.no_std.is_present(),
}
}
Expand Down Expand Up @@ -855,10 +851,6 @@ impl<'a> FieldWithDefaults<'a> {
pub fn use_parent_default(&self) -> bool {
self.field.default.is_none() && self.parent.default.is_some()
}

pub fn deprecation_notes(&self) -> &DeprecationNotes {
&self.parent.deprecation_notes
}
}

/// Converters to codegen structs
Expand All @@ -877,7 +869,6 @@ impl<'a> FieldWithDefaults<'a> {
field_type: self.field_type(),
generic_into: self.setter_into(),
strip_option: self.setter_strip_option(),
deprecation_notes: self.deprecation_notes(),
each: self.field.setter.each.as_ref(),
}
}
Expand Down
13 changes: 1 addition & 12 deletions derive_builder_core/src/setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::borrow::Cow;
use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, TokenStreamExt};

use crate::{BuilderFieldType, BuilderPattern, DeprecationNotes, Each};
use crate::{BuilderFieldType, BuilderPattern, Each};

/// Setter for the struct fields in the build method, implementing
/// `quote::ToTokens`.
Expand Down Expand Up @@ -62,8 +62,6 @@ pub struct Setter<'a> {
/// Make the setter remove the Option wrapper from the setter, remove the need to call Some(...).
/// when combined with into, the into is used on the content Type of the Option.
pub strip_option: bool,
/// Emit deprecation notes to the user.
pub deprecation_notes: &'a DeprecationNotes,
/// Emit extend method.
pub each: Option<&'a Each>,
}
Expand All @@ -77,7 +75,6 @@ impl<'a> ToTokens for Setter<'a> {
let field_ident = self.field_ident;
let ident = &self.ident;
let attrs = self.attrs;
let deprecation_notes = self.deprecation_notes;

let self_param: TokenStream;
let return_ty: TokenStream;
Expand Down Expand Up @@ -143,7 +140,6 @@ impl<'a> ToTokens for Setter<'a> {
#vis fn #ident #ty_params (#self_param, value: #param_ty)
-> #return_ty
{
#deprecation_notes
let mut new = #self_into_return_ty;
new.#field_ident = #into_value;
new
Expand Down Expand Up @@ -214,7 +210,6 @@ impl<'a> ToTokens for Setter<'a> {
where
#ty: #crate_root::export::core::default::Default + #crate_root::export::core::iter::Extend<VALUE>,
{
#deprecation_notes
let mut new = #self_into_return_ty;
new.#field_ident
.#get_initialized_collection
Expand Down Expand Up @@ -299,7 +294,6 @@ macro_rules! default_setter {
field_type: BuilderFieldType::Optional(Box::leak(Box::new(parse_quote!(Foo)))),
generic_into: false,
strip_option: false,
deprecation_notes: &Default::default(),
each: None,
}
};
Expand Down Expand Up @@ -508,13 +502,9 @@ mod tests {
//let attrs = outer_attrs.parse_str("#[some_attr]").unwrap();
let attrs: Vec<syn::Attribute> = vec![parse_quote!(#[some_attr])];

let mut deprecated = DeprecationNotes::default();
deprecated.push("Some example.".to_string());

let mut setter = default_setter!();
setter.attrs = attrs.as_slice();
setter.generic_into = true;
setter.deprecation_notes = &deprecated;
setter.try_setter = true;

assert_eq!(
Expand All @@ -523,7 +513,6 @@ mod tests {
#[some_attr]
#[allow(unused_mut)]
pub fn foo <VALUE: ::db::export::core::convert::Into<Foo>>(&mut self, value: VALUE) -> &mut Self {
#deprecated
let mut new = self;
new.foo = ::db::export::core::option::Option::Some(value.into());
new
Expand Down

0 comments on commit d2efc54

Please sign in to comment.