Skip to content

Commit 5450bf3

Browse files
authored
Fix paths in SystemData macro (#232)
* fix paths in SystemData macro * remove leading :: * revert unintended changes * add missed path * fix examples and tests without default features
1 parent 12d482d commit 5450bf3

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

examples/async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate shred;
22

3-
use shred::{DispatcherBuilder, Read, ResourceId, System, SystemData, World, Write};
3+
use shred::{DispatcherBuilder, Read, System, SystemData, World, Write};
44

55
#[derive(Debug, Default)]
66
struct ResA;

examples/derive_bundle.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use shred::{Read, ResourceId, SystemData, World, Write};
1+
#[cfg(not(feature = "shred-derive"))]
2+
use shred::ResourceId;
3+
use shred::{Read, SystemData, World, Write};
24

35
#[derive(Debug, Default)]
46
struct ResA;

examples/generic_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate shred_derive;
66

77
use std::fmt::Debug;
88

9-
use shred::{Read, Resource, ResourceId, SystemData, World, Write};
9+
use shred::{Read, Resource, SystemData, Write};
1010

1111
trait Hrtb<'a> {}
1212

examples/seq_dispatch.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use shred::{DispatcherBuilder, Read, ResourceId, System, SystemData, World, Write};
1+
#[cfg(not(feature = "shred-derive"))]
2+
use shred::ResourceId;
3+
use shred::{DispatcherBuilder, Read, System, SystemData, World, Write};
24

35
#[derive(Debug, Default)]
46
struct ResA;

shred-derive/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,35 @@ fn impl_system_data(ast: &DeriveInput) -> proc_macro2::TokenStream {
5858

5959
quote! {
6060
impl #impl_generics
61-
SystemData< #impl_fetch_lt >
61+
shred::SystemData< #impl_fetch_lt >
6262
for #name #ty_generics #where_clause
6363
{
64-
fn setup(world: &mut World) {
64+
fn setup(world: &mut shred::World) {
6565
#(
66-
<#tys as SystemData> :: setup(world);
66+
<#tys as shred::SystemData> :: setup(world);
6767
)*
6868
}
6969

70-
fn fetch(world: & #impl_fetch_lt World) -> Self {
70+
fn fetch(world: & #impl_fetch_lt shred::World) -> Self {
7171
#fetch_return
7272
}
7373

74-
fn reads() -> Vec<ResourceId> {
74+
fn reads() -> Vec<shred::ResourceId> {
7575
let mut r = Vec::new();
7676

7777
#( {
78-
let mut reads = <#tys as SystemData> :: reads();
78+
let mut reads = <#tys as shred::SystemData> :: reads();
7979
r.append(&mut reads);
8080
} )*
8181

8282
r
8383
}
8484

85-
fn writes() -> Vec<ResourceId> {
85+
fn writes() -> Vec<shred::ResourceId> {
8686
let mut r = Vec::new();
8787

8888
#( {
89-
let mut writes = <#tys as SystemData> :: writes();
89+
let mut writes = <#tys as shred::SystemData> :: writes();
9090
r.append(&mut writes);
9191
} )*
9292

@@ -107,7 +107,7 @@ fn gen_identifiers(fields: &Punctuated<Field, Comma>) -> Vec<Ident> {
107107
/// Adds a `SystemData<'lt>` bound on each of the system data types.
108108
fn constrain_system_data_types(clause: &mut WhereClause, fetch_lt: &Lifetime, tys: &[Type]) {
109109
for ty in tys.iter() {
110-
let where_predicate: WherePredicate = parse_quote!(#ty : SystemData< #fetch_lt >);
110+
let where_predicate: WherePredicate = parse_quote!(#ty : shred::SystemData< #fetch_lt >);
111111
clause.predicates.push(where_predicate);
112112
}
113113
}
@@ -138,13 +138,13 @@ fn gen_from_body(ast: &Data, name: &Ident) -> (proc_macro2::TokenStream, Vec<Typ
138138

139139
quote! {
140140
#name {
141-
#( #identifiers: SystemData::fetch(world) ),*
141+
#( #identifiers: shred::SystemData::fetch(world) ),*
142142
}
143143
}
144144
}
145145
DataType::Tuple => {
146146
let count = tys.len();
147-
let fetch = vec![quote! { SystemData::fetch(world) }; count];
147+
let fetch = vec![quote! { shred::SystemData::fetch(world) }; count];
148148

149149
quote! {
150150
#name ( #( #fetch ),* )

tests/dispatch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use shred::{
2-
Dispatcher, DispatcherBuilder, Read, ResourceId, RunningTime, System, SystemData, World, Write,
3-
};
1+
#[cfg(not(feature = "shred-derive"))]
2+
use shred::ResourceId;
3+
use shred::{Dispatcher, DispatcherBuilder, Read, RunningTime, System, SystemData, World, Write};
44

55
fn sleep_short() {
66
use std::{thread::sleep, time::Duration};

0 commit comments

Comments
 (0)