1
Fork 0

Lift: take self by value

This commit is contained in:
Bastian Kauschke 2020-10-16 21:59:49 +02:00
parent 1d2726726f
commit 8752a560b9
15 changed files with 138 additions and 151 deletions

View file

@ -3,6 +3,7 @@ use syn::{self, parse_quote};
pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
s.add_bounds(synstructure::AddBounds::Generics);
s.bind_with(|_| synstructure::BindStyle::Move);
let tcx: syn::Lifetime = parse_quote!('tcx);
let newtcx: syn::GenericParam = parse_quote!('__lifted);
@ -43,8 +44,8 @@ pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStre
quote! {
type Lifted = #lifted;
fn lift_to_tcx(&self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
Some(match *self { #body })
fn lift_to_tcx(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
Some(match self { #body })
}
},
)