Use 2018-style absolute paths in examples

This commit is contained in:
David Tolnay 2019-04-29 14:16:40 -07:00
parent 18c081f5ac
commit 20985b9231
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 13 additions and 13 deletions

View File

@ -31,12 +31,12 @@ struct Demo<'a, T: ?Sized> {
The trait impl generated by the custom derive here would look like:
```rust
impl<'a, T: ?Sized + ::heapsize::HeapSize> ::heapsize::HeapSize for Demo<'a, T> {
impl<'a, T: ?Sized + heapsize::HeapSize> heapsize::HeapSize for Demo<'a, T> {
fn heap_size_of_children(&self) -> usize {
0 + ::heapsize::HeapSize::heap_size_of_children(&self.a)
+ ::heapsize::HeapSize::heap_size_of_children(&self.b)
+ ::heapsize::HeapSize::heap_size_of_children(&self.c)
+ ::heapsize::HeapSize::heap_size_of_children(&self.d)
0 + heapsize::HeapSize::heap_size_of_children(&self.a)
+ heapsize::HeapSize::heap_size_of_children(&self.b)
+ heapsize::HeapSize::heap_size_of_children(&self.c)
+ heapsize::HeapSize::heap_size_of_children(&self.d)
}
}
```

View File

@ -22,7 +22,7 @@ pub fn derive_heap_size(input: proc_macro::TokenStream) -> proc_macro::TokenStre
let expanded = quote! {
// The generated impl.
impl #impl_generics ::heapsize::HeapSize for #name #ty_generics #where_clause {
impl #impl_generics heapsize::HeapSize for #name #ty_generics #where_clause {
fn heap_size_of_children(&self) -> usize {
#sum
}
@ -37,7 +37,7 @@ pub fn derive_heap_size(input: proc_macro::TokenStream) -> proc_macro::TokenStre
fn add_trait_bounds(mut generics: Generics) -> Generics {
for param in &mut generics.params {
if let GenericParam::Type(ref mut type_param) = *param {
type_param.bounds.push(parse_quote!(::heapsize::HeapSize));
type_param.bounds.push(parse_quote!(heapsize::HeapSize));
}
}
generics
@ -64,7 +64,7 @@ fn heap_size_sum(data: &Data) -> TokenStream {
let recurse = fields.named.iter().map(|f| {
let name = &f.ident;
quote_spanned! {f.span()=>
::heapsize::HeapSize::heap_size_of_children(&self.#name)
heapsize::HeapSize::heap_size_of_children(&self.#name)
}
});
quote! {
@ -78,7 +78,7 @@ fn heap_size_sum(data: &Data) -> TokenStream {
let recurse = fields.unnamed.iter().enumerate().map(|(i, f)| {
let index = Index::from(i);
quote_spanned! {f.span()=>
::heapsize::HeapSize::heap_size_of_children(&self.#index)
heapsize::HeapSize::heap_size_of_children(&self.#index)
}
});
quote! {

View File

@ -98,7 +98,7 @@ pub fn lazy_static(input: TokenStream) -> TokenStream {
// 10 | static ref PTR: *const () = &();
// | ^^^^^^^^^ `*const ()` cannot be shared between threads safely
let assert_sync = quote_spanned! {ty.span()=>
struct _AssertSync where #ty: ::std::marker::Sync;
struct _AssertSync where #ty: std::marker::Sync;
};
// Check for Sized. Not vital to check here, but the error message is less
@ -111,7 +111,7 @@ 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()=>
struct _AssertSized where #ty: ::std::marker::Sized;
struct _AssertSized where #ty: std::marker::Sized;
};
let init_ptr = quote_spanned! {init.span()=>
@ -121,14 +121,14 @@ pub fn lazy_static(input: TokenStream) -> TokenStream {
let expanded = quote! {
#visibility struct #name;
impl ::std::ops::Deref for #name {
impl std::ops::Deref for #name {
type Target = #ty;
fn deref(&self) -> &#ty {
#assert_sync
#assert_sized
static ONCE: ::std::sync::Once = ::std::sync::ONCE_INIT;
static ONCE: std::sync::Once = std::sync::ONCE_INIT;
static mut VALUE: *mut #ty = 0 as *mut #ty;
unsafe {