Skip to content

Commit 47e5cef

Browse files
cjlongoriafacebook-github-bot
authored andcommitted
rustfix on more dependencies
Summary: applying more 2021->2024 edition migration changes Reviewed By: dtolnay Differential Revision: D73444477 fbshipit-source-id: 280f98103510c6c74f98ed52f5bddf6d8e474a78
1 parent e48a863 commit 47e5cef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1035
-822
lines changed

gazebo/dupe_derive/src/clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn derive_clone_(input: proc_macro::TokenStream) -> proc_macro::TokenStream
1919

2020
let name = &input.ident;
2121
let body = duplicate_impl(&input.data, &quote! { ::std::clone::Clone::clone });
22-
let gen = quote! {
22+
let r#gen = quote! {
2323
// Clippy wants us to use Copy if we can - we prefer to be agnostic.
2424
// Add unknown_lints temporarily.
2525
#[allow(unknown_lints)]
@@ -30,5 +30,5 @@ pub fn derive_clone_(input: proc_macro::TokenStream) -> proc_macro::TokenStream
3030
}
3131
}
3232
};
33-
gen.into()
33+
r#gen.into()
3434
}

gazebo/dupe_derive/src/copy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub fn derive_copy_(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
1616
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
1717

1818
let name = &input.ident;
19-
let gen = quote! {
19+
let r#gen = quote! {
2020
impl #impl_generics ::std::marker::Copy for #name #ty_generics #where_clause {
2121
}
2222
};
23-
gen.into()
23+
r#gen.into()
2424
}

gazebo/dupe_derive/src/dupe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn derive_dupe_explicit(
5757
name.span(),
5858
);
5959

60-
let gen = quote! {
60+
let r#gen = quote! {
6161
impl #impl_generics dupe::Dupe for #name #ty_generics #where_clause {
6262
}
6363

@@ -68,7 +68,7 @@ fn derive_dupe_explicit(
6868
}
6969
};
7070

71-
gen.into()
71+
r#gen.into()
7272
}
7373

7474
fn check_each_field_dupe<'a>(tys: impl IntoIterator<Item = &'a Type>) -> TokenStream {

gazebo/gazebo/src/cast.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ pub fn ptr_to_usize<T: ?Sized>(x: &T) -> usize {
2929
/// of type `T`.
3030
#[inline(always)]
3131
pub unsafe fn usize_to_ptr<'a, T>(x: usize) -> &'a T {
32-
&*(x as *const T)
32+
unsafe { &*(x as *const T) }
3333
}
3434

3535
/// Undefined behaviour if the argument does not satisfy the alignment of type `To`.
3636
#[inline(always)]
3737
pub unsafe fn ptr<From, To>(x: &From) -> &To {
38-
&*(x as *const From as *const To)
38+
unsafe { &*(x as *const From as *const To) }
3939
}
4040

4141
/// Undefined behaviour if the argument does not satisfy the alignment of type `To`.
4242
#[inline(always)]
4343
pub unsafe fn ptr_mut<From, To>(x: &mut From) -> &mut To {
44-
&mut *(x as *mut From as *mut To)
44+
unsafe { &mut *(x as *mut From as *mut To) }
4545
}
4646

4747
#[inline(always)]
4848
pub unsafe fn ptr_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
49-
&*(x as *const T)
49+
unsafe { &*(x as *const T) }
5050
}
5151

5252
/// Like normal [`transmute`](std::mem::transmute), but without the compile-time
@@ -59,18 +59,20 @@ pub unsafe fn ptr_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
5959
/// e.g. `Vec<T>`, that `transmute` cannot be applied to.
6060
#[inline]
6161
pub unsafe fn transmute_unchecked<A, B>(x: A) -> B {
62-
assert_eq!(mem::size_of::<A>(), mem::size_of::<B>());
63-
debug_assert_eq!(0, (&x as *const A).align_offset(mem::align_of::<B>()));
64-
let b = ptr::read(&x as *const A as *const B);
65-
mem::forget(x);
66-
b
62+
unsafe {
63+
assert_eq!(mem::size_of::<A>(), mem::size_of::<B>());
64+
debug_assert_eq!(0, (&x as *const A).align_offset(mem::align_of::<B>()));
65+
let b = ptr::read(&x as *const A as *const B);
66+
mem::forget(x);
67+
b
68+
}
6769
}
6870

6971
#[macro_export]
7072
/// `transmute!(from-type, to-type, value)` will do a [`transmute`](std::mem::transmute),
7173
/// but the original and result types must be specified.
7274
macro_rules! transmute {
73-
($from:ty, $to:ty, $e:expr) => {
75+
($from:ty, $to:ty, $e:expr_2021) => {
7476
std::mem::transmute::<$from, $to>($e)
7577
};
7678
}
@@ -85,7 +87,7 @@ mod tests {
8587
fn test_transmute() {
8688
#[allow(clippy::useless_transmute)]
8789
unsafe fn downcast_string<'a>(x: &'a str) -> &'static str {
88-
transmute!(&'a str, &'static str, x)
90+
unsafe { transmute!(&'a str, &'static str, x) }
8991
}
9092
assert_eq!(unsafe { downcast_string("test") }, "test");
9193
}

gazebo/gazebo/src/cmp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
/// ```
3636
#[macro_export]
3737
macro_rules! cmp_chain {
38-
($e:expr) => {
38+
($e:expr_2021) => {
3939
$e
4040
};
41-
($e:expr, $($x:expr),+ $(,)?) => {
41+
($e:expr_2021, $($x:expr_2021),+ $(,)?) => {
4242
match $e {
4343
std::cmp::Ordering::Equal => {
4444
cmp_chain!($($x),+)
@@ -73,10 +73,10 @@ macro_rules! cmp_chain {
7373
/// ```
7474
#[macro_export]
7575
macro_rules! eq_chain {
76-
($e:expr) => {
76+
($e:expr_2021) => {
7777
$e
7878
};
79-
($e:expr, $($x:expr),+ $(,)?) => {
79+
($e:expr_2021, $($x:expr_2021),+ $(,)?) => {
8080
if $e {
8181
eq_chain!($($x),+)
8282
} else {

gazebo/gazebo_derive/src/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ pub fn derive_default_(input: DeriveInput) -> proc_macro::TokenStream {
2121

2222
let name = &input.ident;
2323
let body = default_impl(&input.data);
24-
let gen = quote! {
24+
let r#gen = quote! {
2525
impl #impl_generics ::std::default::Default for #name #ty_generics #where_clause {
2626
fn default() -> Self {
2727
#body
2828
}
2929
}
3030
};
31-
gen.into()
31+
r#gen.into()
3232
}
3333

3434
fn default_struct(data: &DataStruct) -> TokenStream {

gazebo/gazebo_derive/src/variant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(crate) fn derive_variant_names(input: DeriveInput) -> syn::Result<proc_macro
3939
let name = &input.ident;
4040
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
4141

42-
let gen = quote! {
42+
let r#gen = quote! {
4343
impl #impl_generics gazebo::variants::VariantName for #name #ty_generics #where_clause {
4444
fn variant_name(&self) -> &'static str {
4545
match self {
@@ -55,7 +55,7 @@ pub(crate) fn derive_variant_names(input: DeriveInput) -> syn::Result<proc_macro
5555
}
5656
};
5757

58-
Ok(gen.into())
58+
Ok(r#gen.into())
5959
} else {
6060
Err(syn::Error::new(
6161
input.span(),
@@ -137,13 +137,13 @@ pub(crate) fn derive_unpack_variants(input: DeriveInput) -> syn::Result<proc_mac
137137
let name = &input.ident;
138138
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
139139

140-
let gen = quote! {
140+
let r#gen = quote! {
141141
impl #impl_generics #name #ty_generics #where_clause {
142142
#(#variant_fns)*
143143
}
144144
};
145145

146-
Ok(gen.into())
146+
Ok(r#gen.into())
147147
} else {
148148
Err(syn::Error::new(
149149
input.span(),

starlark/src/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ pub(crate) fn ptr_to_usize<T: ?Sized>(x: &T) -> usize {
2626
pub(crate) unsafe fn usize_to_ptr<'a, T>(x: usize) -> &'a T {
2727
debug_assert!(x != 0, "Zero is not a valid pointer");
2828
debug_assert!(x % std::mem::align_of::<T>() == 0, "Pointer is not aligned");
29-
&*(x as *const T)
29+
unsafe { &*(x as *const T) }
3030
}
3131

3232
#[inline(always)]
3333
pub(crate) unsafe fn ptr_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
34-
&*(x as *const T)
34+
unsafe { &*(x as *const T) }
3535
}
3636

3737
/// `transmute!(from-type, to-type, value)` will do a [`transmute`](std::mem::transmute),

starlark/src/docs/multipage.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,9 @@ impl<'a> MultipageRender<'a> {
142142

143143
let render_linked_ty_starlark_value = move |ty: &TyStarlarkValue| {
144144
let type_name = ty.to_string();
145-
if let Some(type_path) =
146-
ty_to_path_map.get(&Ty::basic(TyBasic::StarlarkValue(ty.dupe())))
147-
{
148-
linked_ty_mapper(type_path, &type_name)
149-
} else {
150-
type_name.to_owned()
145+
match ty_to_path_map.get(&Ty::basic(TyBasic::StarlarkValue(ty.dupe()))) {
146+
Some(type_path) => linked_ty_mapper(type_path, &type_name),
147+
_ => type_name.to_owned(),
151148
}
152149
};
153150

starlark/src/environment/globals.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,13 @@ impl GlobalsStatic {
374374
}
375375
}
376376

377-
pub(crate) fn common_documentation<'a>(
377+
pub(crate) fn common_documentation<'a, T: IntoIterator<Item = (&'a str, FrozenValue)>>(
378378
docstring: &Option<String>,
379-
members: impl IntoIterator<Item = (&'a str, FrozenValue)>,
380-
) -> (Option<DocString>, impl Iterator<Item = (String, DocItem)>) {
379+
members: T,
380+
) -> (
381+
Option<DocString>,
382+
impl Iterator<Item = (String, DocItem)> + use<T>,
383+
) {
381384
let main_docs = docstring
382385
.as_ref()
383386
.and_then(|ds| DocString::from_docstring(DocStringKind::Rust, ds));

0 commit comments

Comments
 (0)