Skip to content

Commit

Permalink
Update quote_spanned syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 6, 2018
1 parent a20c94b commit 9f231e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions examples/heapsize2/heapsize_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ fn heap_size_sum(data: &Data, var: &Tokens) -> Tokens {
// readme of the parent directory.
let recurse = fields.named.iter().map(|f| {
let name = f.ident;
let access = quote_spanned!(call_site, #var.#name);
let access = quote_spanned!(call_site=> #var.#name);
let span = f.span().resolved_at(def_site);
quote_spanned! {span,
quote_spanned! {span=>
HeapSize::heap_size_of_children(&#access)
}
});
Expand All @@ -98,9 +98,9 @@ fn heap_size_sum(data: &Data, var: &Tokens) -> Tokens {
// 0 + HeapSize::heap_size(&self.0) + HeapSize::heap_size(&self.1)
let recurse = fields.unnamed.iter().enumerate().map(|(i, f)| {
let index = Index { index: i as u32, span: call_site };
let access = quote_spanned!(call_site, #var.#index);
let access = quote_spanned!(call_site=> #var.#index);
let span = f.span().resolved_at(def_site);
quote_spanned! {span,
quote_spanned! {span=>
HeapSize::heap_size_of_children(&#access)
}
});
Expand Down
6 changes: 3 additions & 3 deletions examples/lazy-static/lazy-static/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn lazy_static(input: TokenStream) -> TokenStream {
// 10 | static ref PTR: *const () = &();
// | ^^^^^^^^^ `*const ()` cannot be shared between threads safely
let ty_span = ty.span().resolved_at(def_site);
let assert_sync = quote_spanned! {ty_span,
let assert_sync = quote_spanned! {ty_span=>
struct _AssertSync where #ty: Sync;
};

Expand All @@ -109,12 +109,12 @@ pub fn lazy_static(input: TokenStream) -> TokenStream {
// |
// 10 | static ref A: str = "";
// | ^^^ `str` does not have a constant size known at compile-time
let assert_sized = quote_spanned! {ty_span,
let assert_sized = quote_spanned! {ty_span=>
struct _AssertSized where #ty: Sized;
};

let init_span = init.span().resolved_at(def_site);
let init_ptr = quote_spanned! {init_span,
let init_ptr = quote_spanned! {init_span=>
Box::into_raw(Box::new(#init))
};

Expand Down

0 comments on commit 9f231e6

Please sign in to comment.