Skip to content

Commit e162825

Browse files
committed
Cargo fmt
1 parent e7d4805 commit e162825

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

components/salsa-macro-rules/src/return_mode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ macro_rules! return_mode_expression {
1818
) => {
1919
::core::clone::Clone::clone($field_ref_expr)
2020
};
21-
21+
2222
(
2323
(ref, $maybe_backdate:ident, $maybe_default:ident),
2424
$field_ty:ty,
@@ -34,15 +34,15 @@ macro_rules! return_mode_expression {
3434
) => {
3535
::core::ops::Deref::deref($field_ref_expr)
3636
};
37-
37+
3838
(
3939
(as_ref, $maybe_backdate:ident, $maybe_default:ident),
4040
$field_ty:ty,
4141
$field_ref_expr:expr,
4242
) => {
4343
::salsa::SalsaAsRef::as_ref($field_ref_expr)
4444
};
45-
45+
4646
(
4747
(as_deref, $maybe_backdate:ident, $maybe_default:ident),
4848
$field_ty:ty,

components/salsa-macros/src/salsa_struct.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,14 @@ impl<'s> SalsaField<'s> {
389389
}
390390

391391
// Validate return mode
392-
if !ALLOWED_RETURN_MODES.iter().any(|mode| mode == &result.returns.to_string()) {
393-
return Err(syn::Error::new(result.returns.span(), format!("Invalid return mode. Allowed modes are: {ALLOWED_RETURN_MODES:?}")));
392+
if !ALLOWED_RETURN_MODES
393+
.iter()
394+
.any(|mode| mode == &result.returns.to_string())
395+
{
396+
return Err(syn::Error::new(
397+
result.returns.span(),
398+
format!("Invalid return mode. Allowed modes are: {ALLOWED_RETURN_MODES:?}"),
399+
));
394400
}
395401

396402
Ok(result)

components/salsa-macros/src/tracked_fn.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ impl Macro {
155155
.unwrap_or(Ident::new("clone", Span::call_site()));
156156

157157
// Validate return mode
158-
if !ALLOWED_RETURN_MODES.iter().any(|mode| mode == &return_mode.to_string()) {
159-
return Err(syn::Error::new(return_mode.span(), format!("Invalid return mode. Allowed modes are: {ALLOWED_RETURN_MODES:?}")));
158+
if !ALLOWED_RETURN_MODES
159+
.iter()
160+
.any(|mode| mode == &return_mode.to_string())
161+
{
162+
return Err(syn::Error::new(
163+
return_mode.span(),
164+
format!("Invalid return mode. Allowed modes are: {ALLOWED_RETURN_MODES:?}"),
165+
));
160166
}
161167

162168
// The path expression is responsible for emitting the primary span in the diagnostic we

src/return_mode.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@ use std::ops::Deref;
55
/// Used to determine the return type and value for tracked fields and functions annotated with `returns(as_ref)`.
66
pub trait SalsaAsRef {
77
// The type returned by tracked fields and functions annotated with `returns(as_ref)`.
8-
type AsRef<'a> where Self: 'a;
8+
type AsRef<'a>
9+
where
10+
Self: 'a;
911

1012
// The value returned by tracked fields and functions annotated with `returns(as_ref)`.
1113
fn as_ref(&self) -> Self::AsRef<'_>;
1214
}
1315

1416
impl<T> SalsaAsRef for Option<T> {
15-
type AsRef<'a> = Option<&'a T> where Self: 'a;
17+
type AsRef<'a>
18+
= Option<&'a T>
19+
where
20+
Self: 'a;
1621

1722
fn as_ref(&self) -> Self::AsRef<'_> {
1823
self.as_ref()
1924
}
2025
}
2126

2227
impl<T, E> SalsaAsRef for Result<T, E> {
23-
type AsRef<'a> = Result<&'a T, &'a E> where Self: 'a;
28+
type AsRef<'a>
29+
= Result<&'a T, &'a E>
30+
where
31+
Self: 'a;
2432

2533
fn as_ref(&self) -> Self::AsRef<'_> {
2634
self.as_ref()
@@ -30,22 +38,30 @@ impl<T, E> SalsaAsRef for Result<T, E> {
3038
/// Used to determine the return type and value for tracked fields and functions annotated with `returns(as_deref)`.
3139
pub trait SalsaAsDeref {
3240
// The type returned by tracked fields and functions annotated with `returns(as_deref)`.
33-
type AsDeref<'a> where Self: 'a;
41+
type AsDeref<'a>
42+
where
43+
Self: 'a;
3444

3545
// The value returned by tracked fields and functions annotated with `returns(as_deref)`.
3646
fn as_deref(&self) -> Self::AsDeref<'_>;
3747
}
3848

3949
impl<T: Deref> SalsaAsDeref for Option<T> {
40-
type AsDeref<'a> = Option<&'a T::Target> where Self: 'a;
50+
type AsDeref<'a>
51+
= Option<&'a T::Target>
52+
where
53+
Self: 'a;
4154

4255
fn as_deref(&self) -> Self::AsDeref<'_> {
4356
self.as_deref()
4457
}
4558
}
4659

4760
impl<T: Deref, E> SalsaAsDeref for Result<T, E> {
48-
type AsDeref<'a> = Result<&'a T::Target, &'a E> where Self: 'a;
61+
type AsDeref<'a>
62+
= Result<&'a T::Target, &'a E>
63+
where
64+
Self: 'a;
4965

5066
fn as_deref(&self) -> Self::AsDeref<'_> {
5167
self.as_deref()

tests/return_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,4 @@ fn as_deref_test() {
169169
"#]]
170170
.assert_debug_eq(&x);
171171
})
172-
}
172+
}

0 commit comments

Comments
 (0)