Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/builtin/derive_macro.rs')
-rw-r--r--crates/hir-expand/src/builtin/derive_macro.rs47
1 files changed, 25 insertions, 22 deletions
diff --git a/crates/hir-expand/src/builtin/derive_macro.rs b/crates/hir-expand/src/builtin/derive_macro.rs
index ff50ccef0f..b6181e8ce8 100644
--- a/crates/hir-expand/src/builtin/derive_macro.rs
+++ b/crates/hir-expand/src/builtin/derive_macro.rs
@@ -1,7 +1,7 @@
//! Builtin derives.
use intern::sym;
-use itertools::{izip, Itertools};
+use itertools::{Itertools, izip};
use parser::SyntaxKind;
use rustc_hash::FxHashSet;
use span::{Edition, MacroCallId, Span, SyntaxContext};
@@ -10,17 +10,18 @@ use syntax_bridge::DocCommentDesugarMode;
use tracing::debug;
use crate::{
+ ExpandError, ExpandResult,
builtin::quote::{dollar_crate, quote},
db::ExpandDatabase,
hygiene::span_with_def_site_ctxt,
name::{self, AsName, Name},
span_map::ExpansionSpanMap,
- tt, ExpandError, ExpandResult,
+ tt,
};
use syntax::{
ast::{
- self, edit_in_place::GenericParamsOwnerEdit, make, AstNode, FieldList, HasAttrs,
- HasGenericArgs, HasGenericParams, HasModuleItem, HasName, HasTypeBounds,
+ self, AstNode, FieldList, HasAttrs, HasGenericArgs, HasGenericParams, HasModuleItem,
+ HasName, HasTypeBounds, edit_in_place::GenericParamsOwnerEdit, make,
},
ted,
};
@@ -117,7 +118,7 @@ impl VariantShape {
quote! {span => #it : #mapped , }
});
quote! {span =>
- #path { ##fields }
+ #path { # #fields }
}
}
&VariantShape::Tuple(n) => {
@@ -128,7 +129,7 @@ impl VariantShape {
}
});
quote! {span =>
- #path ( ##fields )
+ #path ( # #fields )
}
}
VariantShape::Unit => path,
@@ -464,7 +465,7 @@ fn expand_simple_derive(
return ExpandResult::new(
tt::TopSubtree::empty(tt::DelimSpan { open: invoc_span, close: invoc_span }),
e,
- )
+ );
}
};
ExpandResult::ok(expand_simple_derive_with_parsed(
@@ -523,7 +524,7 @@ fn expand_simple_derive_with_parsed(
let name = info.name;
quote! {invoc_span =>
- impl < ##params #extra_impl_params > #trait_path for #name < ##args > where ##where_block { #trait_body }
+ impl < # #params #extra_impl_params > #trait_path for #name < # #args > where # #where_block { #trait_body }
}
}
@@ -572,7 +573,7 @@ fn clone_expand(
quote! {span =>
fn clone(&self) -> Self {
match self {
- ##arms
+ # #arms
}
}
}
@@ -650,7 +651,7 @@ fn debug_expand(
}
});
quote! {span =>
- f.debug_struct(#name) ##for_fields .finish()
+ f.debug_struct(#name) # #for_fields .finish()
}
}
VariantShape::Tuple(n) => {
@@ -660,7 +661,7 @@ fn debug_expand(
}
});
quote! {span =>
- f.debug_tuple(#name) ##for_fields .finish()
+ f.debug_tuple(#name) # #for_fields .finish()
}
}
VariantShape::Unit => quote! {span =>
@@ -703,7 +704,7 @@ fn debug_expand(
quote! {span =>
fn fmt(&self, f: &mut #krate::fmt::Formatter) -> #krate::fmt::Result {
match self {
- ##arms
+ # #arms
}
}
}
@@ -736,7 +737,7 @@ fn hash_expand(
let it =
names.iter().map(|it| quote! {span => #it . hash(ra_expand_state); });
quote! {span => {
- ##it
+ # #it
} }
};
let fat_arrow = fat_arrow(span);
@@ -754,7 +755,7 @@ fn hash_expand(
fn hash<H: #krate::hash::Hasher>(&self, ra_expand_state: &mut H) {
#check_discriminant
match self {
- ##arms
+ # #arms
}
}
}
@@ -803,7 +804,7 @@ fn partial_eq_expand(
let t2 = tt::Ident::new(&format!("{}_other", first.sym), first.span);
quote!(span =>#t1 .eq( #t2 ))
};
- quote!(span =>#first ##rest)
+ quote!(span =>#first # #rest)
}
};
quote! {span => ( #pat1 , #pat2 ) #fat_arrow #body , }
@@ -814,7 +815,7 @@ fn partial_eq_expand(
quote! {span =>
fn eq(&self, other: &Self) -> bool {
match (self, other) {
- ##arms
+ # #arms
_unused #fat_arrow false
}
}
@@ -891,7 +892,7 @@ fn ord_expand(
let fat_arrow = fat_arrow(span);
let mut body = quote! {span =>
match (self, other) {
- ##arms
+ # #arms
_unused #fat_arrow #krate::cmp::Ordering::Equal
}
};
@@ -961,7 +962,7 @@ fn partial_ord_expand(
right,
quote! {span =>
match (self, other) {
- ##arms
+ # #arms
_unused #fat_arrow #krate::option::Option::Some(#krate::cmp::Ordering::Equal)
}
},
@@ -1072,7 +1073,7 @@ fn coerce_pointee_expand(
"exactly one generic type parameter must be marked \
as `#[pointee]` to derive `CoercePointee` traits",
),
- )
+ );
}
(Some(_), Some(_)) => {
return ExpandResult::new(
@@ -1082,7 +1083,7 @@ fn coerce_pointee_expand(
"only one type parameter can be marked as `#[pointee]` \
when deriving `CoercePointee` traits",
),
- )
+ );
}
}
};
@@ -1120,7 +1121,9 @@ fn coerce_pointee_expand(
tt::TopSubtree::empty(tt::DelimSpan::from_single(span)),
ExpandError::other(
span,
- format!("`derive(CoercePointee)` requires `{pointee_param_name}` to be marked `?Sized`"),
+ format!(
+ "`derive(CoercePointee)` requires `{pointee_param_name}` to be marked `?Sized`"
+ ),
),
);
}
@@ -1335,7 +1338,7 @@ fn coerce_pointee_expand(
let info = match parse_adt_from_syntax(&adt, &span_map, span) {
Ok(it) => it,
Err(err) => {
- return ExpandResult::new(tt::TopSubtree::empty(tt::DelimSpan::from_single(span)), err)
+ return ExpandResult::new(tt::TopSubtree::empty(tt::DelimSpan::from_single(span)), err);
}
};