Skip to content

Commit fa8d2ff

Browse files
committed
Trim down feature again
1 parent c3aa230 commit fa8d2ff

File tree

14 files changed

+100
-440
lines changed

14 files changed

+100
-440
lines changed

crates/rune-macros/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ license = "MIT OR Apache-2.0"
1313
keywords = ["language", "scripting", "scripting-language"]
1414
categories = ["parser-implementations"]
1515

16-
[features]
17-
dynamic_fields = []
18-
1916
[dependencies]
2017
rune-core = { version = "=0.13.1", path = "../rune-core", features = ["std"] }
2118
syn = { version = "2.0.16", features = ["full"] }

crates/rune-macros/src/any.rs

-28
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ where
532532
mut_,
533533
ref_,
534534
vm_try,
535-
dynamic_field_search,
536-
dynamic_field_mode,
537535
..
538536
} = &tokens;
539537

@@ -647,30 +645,6 @@ where
647645
} else {
648646
quote!(#hash::new(#type_hash))
649647
};
650-
#[cfg(feature = "dynamic_fields")]
651-
let meta_fields = if let Some(meta_fields) = attr.meta_fields {
652-
quote! {
653-
#[automatically_derived]
654-
impl #impl_generics #dynamic_field_search for #ident #type_generics #where_clause {
655-
const DYNAMIC_FIELD_MODE: #dynamic_field_mode = #dynamic_field_mode::#meta_fields;
656-
}
657-
}
658-
} else {
659-
quote! {
660-
#[automatically_derived]
661-
impl #impl_generics #dynamic_field_search for #ident #type_generics #where_clause {
662-
const DYNAMIC_FIELD_MODE: #dynamic_field_mode = #dynamic_field_mode::Never;
663-
}
664-
}
665-
};
666-
667-
#[cfg(not(feature = "dynamic_fields"))]
668-
let meta_fields = quote! {
669-
#[automatically_derived]
670-
impl #impl_generics #dynamic_field_search for #ident #type_generics #where_clause {
671-
const DYNAMIC_FIELD_MODE: #dynamic_field_mode = #dynamic_field_mode::Never;
672-
}
673-
};
674648

675649
Some(quote! {
676650
#[automatically_derived]
@@ -680,8 +654,6 @@ where
680654
}
681655
}
682656

683-
#meta_fields
684-
685657
#[automatically_derived]
686658
impl #impl_generics #unsafe_to_ref for #ident #type_generics #where_clause {
687659
type Guard = #raw_into_ref;

crates/rune-macros/src/context.rs

+1-33
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::cell::RefCell;
22

33
use proc_macro2::Span;
44
use proc_macro2::TokenStream;
5-
use quote::{format_ident, quote_spanned};
5+
use quote::quote_spanned;
66
use quote::{quote, ToTokens};
77
use syn::parse::ParseStream;
88
use syn::punctuated::Punctuated;
@@ -86,10 +86,6 @@ pub(crate) struct TypeAttr {
8686
pub(crate) from_value: Option<syn::Path>,
8787
/// Method to use to convert from value.
8888
pub(crate) from_value_params: Option<syn::punctuated::Punctuated<syn::Type, Token![,]>>,
89-
#[cfg(feature = "dynamic_fields")]
90-
/// `#[rune(meta_fields = never|first|last|only)]` to allow meta fields on a type
91-
/// and when to access.
92-
pub(crate) meta_fields: Option<syn::Ident>,
9389
}
9490

9591
/// Parsed variant attributes.
@@ -478,30 +474,6 @@ impl Context {
478474
syn::bracketed!(content in meta.input);
479475
attr.from_value_params =
480476
Some(syn::punctuated::Punctuated::parse_terminated(&content)?);
481-
} else if meta.path == META_FIELDS {
482-
#[cfg(not(feature = "dynamic_fields"))]
483-
return Err(syn::Error::new_spanned(
484-
&meta.path,
485-
"Dynamic fields feature flag \"dynamic_fields\" is not enabled",
486-
));
487-
#[cfg(feature = "dynamic_fields")]
488-
{
489-
meta.input.parse::<Token![=]>()?;
490-
let ty: syn::Ident = meta.input.parse()?;
491-
let value = match ty.to_string().as_str() {
492-
"never" => Some(format_ident!("Never")),
493-
"first" => Some(format_ident!("First")),
494-
"last" => Some(format_ident!("Last")),
495-
"only" => Some(format_ident!("Only")),
496-
_ => {
497-
return Err(syn::Error::new_spanned(
498-
&meta.path,
499-
"Expected `never`, `only`, `first` or `last`",
500-
))
501-
}
502-
};
503-
attr.meta_fields = value;
504-
}
505477
} else {
506478
return Err(syn::Error::new_spanned(
507479
&meta.path,
@@ -632,8 +604,6 @@ impl Context {
632604
from_value: path(m, ["runtime", "FromValue"]),
633605
full_type_of: path(m, ["runtime", "FullTypeOf"]),
634606
hash: path(m, ["Hash"]),
635-
dynamic_field_search: path(m, ["DynamicFieldSearch"]),
636-
dynamic_field_mode: path(m, ["DynamicFieldMode"]),
637607
id: path(m, ["parse", "Id"]),
638608
install_with: path(m, ["__private", "InstallWith"]),
639609
into_iterator: path(&core, ["iter", "IntoIterator"]),
@@ -726,8 +696,6 @@ pub(crate) struct Tokens {
726696
pub(crate) from_value: syn::Path,
727697
pub(crate) full_type_of: syn::Path,
728698
pub(crate) hash: syn::Path,
729-
pub(crate) dynamic_field_search: syn::Path,
730-
pub(crate) dynamic_field_mode: syn::Path,
731699
pub(crate) id: syn::Path,
732700
pub(crate) install_with: syn::Path,
733701
pub(crate) into_iterator: syn::Path,

crates/rune-macros/src/internals.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub const STATIC_TYPE: Symbol = Symbol("static_type");
2626
pub const FROM_VALUE: Symbol = Symbol("from_value");
2727
pub const FROM_VALUE_PARAMS: Symbol = Symbol("from_value_params");
2828

29-
pub const META_FIELDS: Symbol = Symbol("meta_fields");
3029
pub const GET: Symbol = Symbol("get");
3130
pub const SET: Symbol = Symbol("set");
3231
pub const COPY: Symbol = Symbol("copy");

crates/rune/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ categories = ["parser-implementations"]
1717
default = ["emit", "std"]
1818
emit = ["std", "codespan-reporting"]
1919
bench = []
20-
workspace = ["std", "toml", "semver", "relative-path", "serde-hashkey", "linked-hash-map", "dynamic_fields"]
20+
workspace = ["std", "toml", "semver", "relative-path", "serde-hashkey", "linked-hash-map"]
2121
doc = ["std", "rust-embed", "handlebars", "pulldown-cmark", "syntect", "sha2", "base64", "rune-core/doc", "relative-path"]
2222
cli = ["std", "emit", "doc", "bincode", "atty", "tracing-subscriber", "clap", "webbrowser", "capture-io", "disable-io", "languageserver", "fmt", "similar", "rand"]
2323
languageserver = ["std", "lsp", "ropey", "percent-encoding", "url", "serde_json", "tokio", "workspace", "doc", "fmt"]
@@ -27,7 +27,7 @@ disable-io = ["alloc"]
2727
fmt = ["alloc"]
2828
std = ["alloc", "num/std", "serde/std", "rune-core/std", "rune-alloc/std", "musli/std", "musli-storage/std", "once_cell/std", "anyhow/std"]
2929
alloc = ["anyhow", "rune-alloc/alloc", "rune-core/alloc", "once_cell/alloc", "serde/alloc"]
30-
dynamic_fields = ["rune-macros/dynamic_fields"]
30+
dynamic_fields = []
3131

3232
[dependencies]
3333
rune-macros = { version = "=0.13.1", path = "../rune-macros" }

crates/rune/src/any.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub use rune_macros::Any;
5555

5656
use crate::compile::Named;
5757
use crate::hash::Hash;
58-
use crate::DynamicFieldSearch;
5958

6059
/// A trait which can be stored inside of an [AnyObj](crate::runtime::AnyObj).
6160
///
@@ -74,7 +73,7 @@ use crate::DynamicFieldSearch;
7473
/// }
7574
/// ```
7675
77-
pub trait Any: Named + DynamicFieldSearch + any::Any {
76+
pub trait Any: Named + any::Any {
7877
/// The type hash of the type.
7978
///
8079
/// TODO: make const field when `TypeId::of` is const.

crates/rune/src/compile.rs

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ mod unit_builder;
5050
pub(crate) mod v1;
5151

5252
mod compile;
53-
pub(crate) mod dynamic_fields;
5453
mod location;
5554
pub mod meta;
5655
mod named;

crates/rune/src/compile/dynamic_fields.rs

-23
This file was deleted.

crates/rune/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,7 @@ pub use rune_macros::module;
478478
pub use self::any::Any;
479479
pub use self::build::{prepare, Build, BuildError};
480480
#[doc(inline)]
481-
pub use self::compile::{
482-
dynamic_fields::{DynamicFieldMode, DynamicFieldSearch},
483-
Context, ContextError, Options,
484-
};
481+
pub use self::compile::{Context, ContextError, Options};
485482
#[doc(inline)]
486483
pub use self::diagnostics::Diagnostics;
487484
pub use self::hash::{Hash, ToTypeHash};

crates/rune/src/runtime/any_obj.rs

-20
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use crate::alloc::{self, Box};
1111
use crate::any::Any;
1212
use crate::hash::Hash;
1313
use crate::runtime::{AnyTypeInfo, FullTypeOf, MaybeTypeOf, RawStr, TypeInfo};
14-
#[cfg(feature = "dynamic_fields")]
15-
use crate::{DynamicFieldMode, DynamicFieldSearch};
1614

1715
/// Errors raised during casting operations.
1816
#[derive(Debug)]
@@ -84,8 +82,6 @@ impl AnyObj {
8482
debug: debug_impl::<T>,
8583
type_name: type_name_impl::<T>,
8684
type_hash: type_hash_impl::<T>,
87-
#[cfg(feature = "dynamic_fields")]
88-
field_mode: T::DYNAMIC_FIELD_MODE,
8985
},
9086
data,
9187
})
@@ -144,8 +140,6 @@ impl AnyObj {
144140
debug: debug_ref_impl::<T>,
145141
type_name: type_name_impl::<T>,
146142
type_hash: type_hash_impl::<T>,
147-
#[cfg(feature = "dynamic_fields")]
148-
field_mode: T::DYNAMIC_FIELD_MODE,
149143
},
150144
data,
151145
}
@@ -196,8 +190,6 @@ impl AnyObj {
196190
debug: debug_ref_impl::<T::Target>,
197191
type_name: type_name_impl::<T::Target>,
198192
type_hash: type_hash_impl::<T::Target>,
199-
#[cfg(feature = "dynamic_fields")]
200-
field_mode: T::Target::DYNAMIC_FIELD_MODE,
201193
},
202194
data,
203195
})
@@ -262,8 +254,6 @@ impl AnyObj {
262254
debug: debug_mut_impl::<T>,
263255
type_name: type_name_impl::<T>,
264256
type_hash: type_hash_impl::<T>,
265-
#[cfg(feature = "dynamic_fields")]
266-
field_mode: T::DYNAMIC_FIELD_MODE,
267257
},
268258
data,
269259
}
@@ -314,8 +304,6 @@ impl AnyObj {
314304
debug: debug_mut_impl::<T::Target>,
315305
type_name: type_name_impl::<T::Target>,
316306
type_hash: type_hash_impl::<T::Target>,
317-
#[cfg(feature = "dynamic_fields")]
318-
field_mode: T::Target::DYNAMIC_FIELD_MODE,
319307
},
320308
data,
321309
})
@@ -514,12 +502,6 @@ impl AnyObj {
514502
(self.vtable.type_hash)(),
515503
))
516504
}
517-
518-
#[cfg(feature = "dynamic_fields")]
519-
/// Access the dynamic field mode for the type.
520-
pub fn field_mode(&self) -> DynamicFieldMode {
521-
self.vtable.field_mode
522-
}
523505
}
524506

525507
impl MaybeTypeOf for AnyObj {
@@ -582,8 +564,6 @@ pub struct AnyObjVtable {
582564
type_name: TypeNameFn,
583565
/// Get the type hash of the stored type.
584566
type_hash: TypeHashFn,
585-
#[cfg(feature = "dynamic_fields")]
586-
field_mode: DynamicFieldMode,
587567
}
588568

589569
unsafe fn drop_impl<T>(this: *mut ()) {

crates/rune/src/runtime/value.rs

-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use ::serde::{Deserialize, Serialize};
1111
use crate::alloc::fmt::TryWrite;
1212
use crate::alloc::prelude::*;
1313
use crate::alloc::{self, String};
14-
#[cfg(feature = "dynamic_fields")]
15-
use crate::compile::dynamic_fields::DynamicFieldMode;
1614
use crate::compile::ItemBuf;
1715
use crate::runtime::vm::CallResult;
1816
use crate::runtime::{
@@ -1213,17 +1211,6 @@ impl Value {
12131211
})
12141212
}
12151213

1216-
#[cfg(feature = "dynamic_fields")]
1217-
/// Function returns the method in which to search for fields within
1218-
/// the value.
1219-
pub(crate) fn field_mode(&self) -> Result<DynamicFieldMode, VmError> {
1220-
if let Value::Any(v) = self {
1221-
Ok(v.borrow_ref()?.field_mode())
1222-
} else {
1223-
Ok(DynamicFieldMode::Never)
1224-
}
1225-
}
1226-
12271214
/// Perform a partial equality test between two values.
12281215
///
12291216
/// This is the basis for the eq operation (`partial_eq` / '==').

0 commit comments

Comments
 (0)