Skip to content

Commit 0d8e081

Browse files
committed
Update to latest nightly
Fix some clippy warnings For some reason `mem::transmute` is now a stable const fn? Declaring the feature makes the compiler error-out.
1 parent 5433878 commit 0d8e081

File tree

5 files changed

+64
-71
lines changed

5 files changed

+64
-71
lines changed

libs/derive/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "zerogc-derive"
33
description = "Procedural derive for zerogc's garbage collection"
4-
version = "0.1.0"
4+
version = "0.1.1"
55
authors = ["Techcable <[email protected]>"]
66
repository = "https://github.com/DuckLogic/zerogc"
77
readme = "../../README.md"
@@ -15,4 +15,4 @@ proc-macro = true
1515
# Proc macros
1616
syn = "1"
1717
quote = "1"
18-
proc-macro2 = "1"
18+
proc-macro2 = "1"

libs/derive/src/lib.rs

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -171,73 +171,70 @@ fn impl_extras(target: &DeriveInput) -> Result<TokenStream, Error> {
171171
Data::Struct(ref data) => {
172172
for field in &data.fields {
173173
let attrs = GcFieldAttrs::find(&field.attrs)?;
174-
match attrs.mutable {
175-
Some(mutable_opts) => {
176-
let original_name = match field.ident {
177-
Some(ref name) => name,
178-
None => {
179-
return Err(Error::new(
180-
field.span(),
181-
"zerogc can only mutate named fields"
182-
))
183-
}
184-
};
185-
// Generate a mutator
186-
let mutator_name = Ident::new(
187-
&format!("set_{}", original_name),
188-
field.ident.span(),
189-
);
190-
let mutator_vis = if mutable_opts.public {
191-
quote!(pub)
192-
} else {
193-
quote!()
194-
};
195-
let value_ref_type = match field.ty {
196-
Type::Path(ref cell_path) if cell_path.path.segments.last()
197-
.map_or(false, |seg| seg.ident == "GcCell") => {
198-
let last_segment = cell_path.path.segments.last().unwrap();
199-
let mut inner_type = None;
200-
if let PathArguments::AngleBracketed(ref bracketed) = last_segment.arguments {
201-
for arg in &bracketed.args {
202-
match arg {
203-
GenericArgument::Type(t) if inner_type.is_none() => {
204-
inner_type = Some(t.clone()); // Initialize
205-
},
206-
_ => {
207-
inner_type = None; // Unexpected arg
208-
break
209-
}
174+
if let Some(mutable_opts) = attrs.mutable {
175+
let original_name = match field.ident {
176+
Some(ref name) => name,
177+
None => {
178+
return Err(Error::new(
179+
field.span(),
180+
"zerogc can only mutate named fields"
181+
))
182+
}
183+
};
184+
// Generate a mutator
185+
let mutator_name = Ident::new(
186+
&format!("set_{}", original_name),
187+
field.ident.span(),
188+
);
189+
let mutator_vis = if mutable_opts.public {
190+
quote!(pub)
191+
} else {
192+
quote!()
193+
};
194+
let value_ref_type = match field.ty {
195+
Type::Path(ref cell_path) if cell_path.path.segments.last()
196+
.map_or(false, |seg| seg.ident == "GcCell") => {
197+
let last_segment = cell_path.path.segments.last().unwrap();
198+
let mut inner_type = None;
199+
if let PathArguments::AngleBracketed(ref bracketed) = last_segment.arguments {
200+
for arg in &bracketed.args {
201+
match arg {
202+
GenericArgument::Type(t) if inner_type.is_none() => {
203+
inner_type = Some(t.clone()); // Initialize
204+
},
205+
_ => {
206+
inner_type = None; // Unexpected arg
207+
break
210208
}
211209
}
212210
}
213-
inner_type.ok_or_else(|| Error::new(
214-
field.ty.span(),
215-
"GcCell should have one (and only one) type param"
216-
))?
217-
},
218-
_ => return Err(Error::new(
211+
}
212+
inner_type.ok_or_else(|| Error::new(
219213
field.ty.span(),
220-
"A mutable field must be wrapped in a `GcCell`"
221-
))
222-
};
223-
// NOTE: Specially quoted since we want to blame the field for errors
224-
let field_as_ptr = quote_spanned!(field.span() => GcCell::as_ptr(&(*self.value()).#original_name));
225-
let barrier = quote_spanned!(field.span() => ::zerogc::GcDirectBarrier::write_barrier(&value, &self, offset));
226-
extra_items.push(quote! {
227-
#[inline] // TODO: Implement `GcDirectBarrier` ourselves
228-
#mutator_vis fn #mutator_name<OwningRef>(self: OwningRef, value: #value_ref_type)
229-
where OwningRef: ::zerogc::GcRef<'gc, Self>,
230-
#value_ref_type: ::zerogc::GcDirectBarrier<'gc, OwningRef> {
231-
unsafe {
232-
let target_ptr = #field_as_ptr;
233-
let offset = target_ptr as usize - self.as_raw_ptr() as usize;
234-
#barrier;
235-
target_ptr.write(value);
236-
}
214+
"GcCell should have one (and only one) type param"
215+
))?
216+
},
217+
_ => return Err(Error::new(
218+
field.ty.span(),
219+
"A mutable field must be wrapped in a `GcCell`"
220+
))
221+
};
222+
// NOTE: Specially quoted since we want to blame the field for errors
223+
let field_as_ptr = quote_spanned!(field.span() => GcCell::as_ptr(&(*self.value()).#original_name));
224+
let barrier = quote_spanned!(field.span() => ::zerogc::GcDirectBarrier::write_barrier(&value, &self, offset));
225+
extra_items.push(quote! {
226+
#[inline] // TODO: Implement `GcDirectBarrier` ourselves
227+
#mutator_vis fn #mutator_name<OwningRef>(self: OwningRef, value: #value_ref_type)
228+
where OwningRef: ::zerogc::GcRef<'gc, Self>,
229+
#value_ref_type: ::zerogc::GcDirectBarrier<'gc, OwningRef> {
230+
unsafe {
231+
let target_ptr = #field_as_ptr;
232+
let offset = target_ptr as usize - self.as_raw_ptr() as usize;
233+
#barrier;
234+
target_ptr.write(value);
237235
}
238-
})
239-
}
240-
None => {}
236+
}
237+
})
241238
}
242239
}
243240
},

libs/simple/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "zerogc-simple"
33
description = "Lightweight mark/sweep collector for zerogc."
4-
version = "0.1.0"
4+
version = "0.1.1"
55
authors = ["Techcable <[email protected]>"]
66
repository = "https://github.com/DuckLogic/zerogc"
77
readme = "../../README.md"
@@ -43,4 +43,4 @@ implicit-grey-stack = []
4343
zerogc-derive = { path = "../derive" }
4444
# Used for binary_trees parallel examle
4545
rayon = "1.3"
46-
slog-term = "2.6"
46+
slog-term = "2.6"

libs/simple/src/context.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ enum ContextState {
5050
}
5151
impl ContextState {
5252
fn is_frozen(&self) -> bool {
53-
match *self {
54-
ContextState::Frozen => true,
55-
_ => false
56-
}
53+
matches!(*self, ContextState::Frozen)
5754
}
5855
}
5956

libs/simple/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
const_alloc_layout, // Used for StaticType
88
const_fn, // We statically create type info
99
const_panic, // Const panic should be stable
10-
const_transmute, // This can already be acheived with unions...
1110
untagged_unions, // Why isn't this stable?
1211
new_uninit, // Until Rust has const generics, this is how we init arrays..
1312
specialization, // Effectively required by GcRef :(

0 commit comments

Comments
 (0)