Skip to content

Commit

Permalink
rustfmt: set style_edition = "2024"
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 23, 2025
1 parent f49dc13 commit aa6dbe2
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ error_on_line_overflow = true
# Override the default formatting style.
# See https://internals.rust-lang.org/t/running-rustfmt-on-rust-lang-rust-and-other-rust-lang-repositories/8732/81.
use_small_heuristics = "Max"
# This is the default of 2024 edition https://github.com/rust-lang/rust/pull/114764.
# This is unstable (tracking issue: https://github.com/rust-lang/rustfmt/issues/3370)
overflow_delimited_expr = true
# This is unstable (tracking issue: https://github.com/rust-lang/rustfmt/issues/4991).
Expand All @@ -27,6 +26,7 @@ use_try_shorthand = true
# Set the default settings again to always apply the proper formatting without
# being affected by the editor settings.
edition = "2021"
style_edition = "2024"
hard_tabs = false
newline_style = "Unix"
tab_spaces = 4
2 changes: 1 addition & 1 deletion examples/unsafe_unpin-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
clippy::undocumented_unsafe_blocks
)]

use pin_project::{pin_project, UnsafeUnpin};
use pin_project::{UnsafeUnpin, pin_project};

// #[pin_project(UnsafeUnpin)]
struct Struct<T, U> {
Expand Down
2 changes: 1 addition & 1 deletion examples/unsafe_unpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#![allow(dead_code, clippy::undocumented_unsafe_blocks)]

use pin_project::{pin_project, UnsafeUnpin};
use pin_project::{UnsafeUnpin, pin_project};

#[pin_project(UnsafeUnpin)]
struct Struct<T, U> {
Expand Down
2 changes: 1 addition & 1 deletion pin-project-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ use proc_macro::TokenStream;
/// argument to `#[pin_project]`.
///
/// ```
/// use pin_project::{pin_project, UnsafeUnpin};
/// use pin_project::{UnsafeUnpin, pin_project};
///
/// #[pin_project(UnsafeUnpin)]
/// struct Struct<T, U> {
Expand Down
8 changes: 2 additions & 6 deletions pin-project-internal/src/pin_project/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use proc_macro2::{Span, TokenStream};
use quote::quote;
use syn::{
Attribute, Error, Ident, Result, Token,
parse::{Parse, ParseStream},
spanned::Spanned as _,
Attribute, Error, Ident, Result, Token,
};

use super::PIN;
Expand Down Expand Up @@ -245,10 +245,6 @@ impl ProjReplace {
}

pub(super) fn ident(&self) -> Option<&Ident> {
if let Self::Named { ident, .. } = self {
Some(ident)
} else {
None
}
if let Self::Named { ident, .. } = self { Some(ident) } else { None }
}
}
2 changes: 1 addition & 1 deletion pin-project-internal/src/pin_project/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use proc_macro2::TokenStream;
use quote::quote;
use syn::{
parse::{Parse, ParseStream},
Attribute, Result, Token, Visibility,
parse::{Parse, ParseStream},
};

use super::PIN;
Expand Down
14 changes: 7 additions & 7 deletions pin-project-internal/src/pin_project/derive.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use proc_macro2::{Delimiter, Group, Span, TokenStream};
use quote::{format_ident, quote, quote_spanned, ToTokens as _};
use quote::{ToTokens as _, format_ident, quote, quote_spanned};
use syn::{
parse_quote, punctuated::Punctuated, token, visit_mut::VisitMut as _, Attribute, Error, Field,
Fields, FieldsNamed, FieldsUnnamed, Generics, Ident, Index, Item, Lifetime, LifetimeParam,
Meta, Result, Token, Type, Variant, Visibility, WhereClause,
Attribute, Error, Field, Fields, FieldsNamed, FieldsUnnamed, Generics, Ident, Index, Item,
Lifetime, LifetimeParam, Meta, Result, Token, Type, Variant, Visibility, WhereClause,
parse_quote, punctuated::Punctuated, token, visit_mut::VisitMut as _,
};

use super::{
args::{parse_args, Args, ProjReplace, UnpinImpl},
PIN,
args::{Args, ProjReplace, UnpinImpl, parse_args},
};
use crate::utils::{
determine_lifetime_name, determine_visibility, insert_lifetime_and_bound, ReplaceReceiver,
SliceExt as _, Variants,
ReplaceReceiver, SliceExt as _, Variants, determine_lifetime_name, determine_visibility,
insert_lifetime_and_bound,
};

pub(super) fn parse_derive(input: TokenStream) -> Result<TokenStream> {
Expand Down
20 changes: 6 additions & 14 deletions pin-project-internal/src/pinned_drop.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote, ToTokens as _};
use quote::{ToTokens as _, format_ident, quote};
use syn::{
parse_quote, spanned::Spanned as _, token::Colon, visit_mut::VisitMut as _, Error, FnArg,
GenericArgument, Ident, ImplItem, ItemImpl, Pat, PatIdent, PatType, Path, PathArguments,
Result, ReturnType, Signature, Token, Type, TypePath, TypeReference,
Error, FnArg, GenericArgument, Ident, ImplItem, ItemImpl, Pat, PatIdent, PatType, Path,
PathArguments, Result, ReturnType, Signature, Token, Type, TypePath, TypeReference,
parse_quote, spanned::Spanned as _, token::Colon, visit_mut::VisitMut as _,
};

use crate::utils::{ReplaceReceiver, SliceExt as _};
Expand Down Expand Up @@ -91,11 +91,7 @@ fn validate_impl(item: &ItemImpl) -> Result<()> {
}
ImplItem::Fn(method) => {
validate_sig(&method.sig)?;
if i == 0 {
Ok(())
} else {
bail!(method, "duplicate definitions with name `drop`")
}
if i == 0 { Ok(()) } else { bail!(method, "duplicate definitions with name `drop`") }
}
_ => unreachable!("unexpected ImplItem"),
})
Expand All @@ -106,11 +102,7 @@ fn validate_impl(item: &ItemImpl) -> Result<()> {
/// The correct signature is: `(mut) self: (<path>::)Pin<&mut Self>`
fn validate_sig(sig: &Signature) -> Result<()> {
fn get_ty_path(ty: &Type) -> Option<&Path> {
if let Type::Path(TypePath { qself: None, path }) = ty {
Some(path)
} else {
None
}
if let Type::Path(TypePath { qself: None, path }) = ty { Some(path) } else { None }
}

const INVALID_ARGUMENT: &str = "method `drop` must take an argument `self: Pin<&mut Self>`";
Expand Down
8 changes: 4 additions & 4 deletions pin-project-internal/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
use std::mem;

use proc_macro2::{Group, Spacing, Span, TokenStream, TokenTree};
use quote::{quote, quote_spanned, ToTokens};
use quote::{ToTokens, quote, quote_spanned};
use syn::{
Attribute, ExprPath, ExprStruct, Generics, Ident, Item, Lifetime, LifetimeParam, Macro,
PatStruct, PatTupleStruct, Path, PathArguments, PredicateType, QSelf, Result, Token, Type,
TypeParamBound, TypePath, Variant, Visibility, WherePredicate,
parse::{Parse, ParseBuffer, ParseStream},
parse_quote,
punctuated::Punctuated,
token,
visit_mut::{self, VisitMut},
Attribute, ExprPath, ExprStruct, Generics, Ident, Item, Lifetime, LifetimeParam, Macro,
PatStruct, PatTupleStruct, Path, PathArguments, PredicateType, QSelf, Result, Token, Type,
TypeParamBound, TypePath, Variant, Visibility, WherePredicate,
};

pub(crate) type Variants = Punctuated<Variant, Token![,]>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub use pin_project_internal::pinned_drop;
/// pinned fields be [`Unpin`], imposes an additional requirement:
///
/// ```
/// use pin_project::{pin_project, UnsafeUnpin};
/// use pin_project::{UnsafeUnpin, pin_project};
///
/// #[pin_project(UnsafeUnpin)]
/// struct Struct<K, V> {
Expand Down
4 changes: 2 additions & 2 deletions tests/auxiliary/macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#![allow(clippy::missing_panics_doc)]

use proc_macro::TokenStream;
use quote::{format_ident, quote, ToTokens as _};
use syn::{parse_quote, Field, FieldMutability, Fields, ItemStruct, Token, Visibility};
use quote::{ToTokens as _, format_ident, quote};
use syn::{Field, FieldMutability, Fields, ItemStruct, Token, Visibility, parse_quote};

fn tokens2(tokens: TokenStream) -> proc_macro2::TokenStream {
tokens.into()
Expand Down
2 changes: 1 addition & 1 deletion tests/pin_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
pin::Pin,
};

use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
use pin_project::{UnsafeUnpin, pin_project, pinned_drop};

#[test]
fn projection() {
Expand Down
2 changes: 1 addition & 1 deletion tests/unsafe_unpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod auxiliary;

use std::marker::PhantomPinned;

use pin_project::{pin_project, UnsafeUnpin};
use pin_project::{UnsafeUnpin, pin_project};

#[pin_project(UnsafeUnpin)]
struct Blah<T, U> {
Expand Down

0 comments on commit aa6dbe2

Please sign in to comment.