From dca47d52338f2b5eb9358f20ba7aaab7fd45d079 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 28 Nov 2021 22:03:02 +0800 Subject: [PATCH] Remove volatile warnings for types and functions exposed unter internals. --- src/api/register.rs | 1 - src/ast.rs | 47 ---------------------------------------- src/engine.rs | 20 ----------------- src/lib.rs | 10 --------- src/module/mod.rs | 4 ---- src/tokenizer.rs | 28 ------------------------ src/types/dynamic.rs | 8 ------- src/types/fn_ptr.rs | 1 + src/types/parse_error.rs | 4 ---- tests/call_fn.rs | 1 - tests/closures.rs | 2 -- tests/native.rs | 1 - 12 files changed, 1 insertion(+), 126 deletions(-) diff --git a/src/api/register.rs b/src/api/register.rs index 679d9e0c..58135f10 100644 --- a/src/api/register.rs +++ b/src/api/register.rs @@ -163,7 +163,6 @@ impl Engine { /// Notice that this will _consume_ the argument, replacing it with `()`. /// /// To access the first mutable parameter, use `args.get_mut(0).unwrap()` - #[deprecated = "this function is volatile and may change"] #[inline(always)] pub fn register_raw_fn( &mut self, diff --git a/src/ast.rs b/src/ast.rs index 8f74ebcd..a5e1891f 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -45,10 +45,6 @@ pub enum FnAccess { /// _(internals)_ A type containing information on a scripted function. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone)] pub struct ScriptFnDef { /// Function body. @@ -288,7 +284,6 @@ impl AST { /// _(internals)_ Get the statements. /// Exported under the `internals` feature only. #[cfg(feature = "internals")] - #[deprecated = "this method is volatile and may change"] #[inline(always)] #[must_use] pub fn statements(&self) -> &[Stmt] { @@ -315,7 +310,6 @@ impl AST { /// /// Not available under `no_function` or `no_module`. #[cfg(feature = "internals")] - #[deprecated = "this method is volatile and may change"] #[cfg(not(feature = "no_module"))] #[cfg(not(feature = "no_function"))] #[inline(always)] @@ -335,7 +329,6 @@ impl AST { /// /// Not available under `no_function`. #[cfg(feature = "internals")] - #[deprecated = "this method is volatile and may change"] #[inline(always)] #[must_use] pub fn lib(&self) -> &Module { @@ -908,10 +901,6 @@ impl AsRef for AST { /// _(internals)_ An identifier containing a name and a [position][Position]. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Clone, Eq, PartialEq, Hash)] pub struct Ident { /// Identifier name. @@ -943,10 +932,6 @@ impl Ident { /// _(internals)_ An [`AST`] node, consisting of either an [`Expr`] or a [`Stmt`]. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Hash)] pub enum ASTNode<'a> { /// A statement ([`Stmt`]). @@ -979,10 +964,6 @@ impl ASTNode<'_> { /// _(internals)_ A scoped block of statements. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Clone, Hash, Default)] pub struct StmtBlock(StaticVec, Position); @@ -1212,10 +1193,6 @@ pub mod AST_OPTION_FLAGS { /// _(internals)_ A statement. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Hash)] pub enum Stmt { /// No-op. @@ -1662,10 +1639,6 @@ impl Stmt { /// _(internals)_ A custom syntax expression. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Hash)] pub struct CustomExpr { /// List of keywords. @@ -1692,10 +1665,6 @@ impl CustomExpr { /// _(internals)_ A binary expression. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Hash)] pub struct BinaryExpr { /// LHS expression. @@ -1706,10 +1675,6 @@ pub struct BinaryExpr { /// _(internals)_ An op-assignment operator. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub struct OpAssignment<'a> { /// Hash of the op-assignment call. @@ -1767,10 +1732,6 @@ impl OpAssignment<'_> { /// then used to search for a native function. In other words, a complete native function call /// hash always contains the called function's name plus the types of the arguments. This is due /// to possible function overloading for different parameter types. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Clone, Copy, Eq, PartialEq, Hash, Default)] pub struct FnCallHashes { /// Pre-calculated hash for a script-defined function ([`None`] if native functions only). @@ -1841,10 +1802,6 @@ impl FnCallHashes { /// _(internals)_ A function call. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Default, Hash)] pub struct FnCallExpr { /// Namespace of the function, if any. @@ -2008,10 +1965,6 @@ impl FloatWrapper { /// _(internals)_ An expression sub-tree. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Clone, Hash)] pub enum Expr { /// Dynamic constant. diff --git a/src/engine.rs b/src/engine.rs index 74e252f2..0de9549c 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -42,10 +42,6 @@ pub type Precedence = NonZeroU8; /// _(internals)_ A stack of imported [modules][Module] plus mutable runtime global states. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. // // # Implementation Notes // @@ -742,10 +738,6 @@ impl> From for Target<'_> { /// _(internals)_ An entry in a function resolution cache. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone)] pub struct FnResolutionCacheEntry { /// Function. @@ -756,18 +748,10 @@ pub struct FnResolutionCacheEntry { /// _(internals)_ A function resolution cache. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. pub type FnResolutionCache = BTreeMap>>; /// _(internals)_ A type that holds all the current states of the [`Engine`]. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone)] pub struct EvalState { /// Normally, access to variables are parsed with a relative offset into the [`Scope`] to avoid a lookup. @@ -830,10 +814,6 @@ impl EvalState { /// _(internals)_ A type containing all the limits imposed by the [`Engine`]. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[cfg(not(feature = "unchecked"))] #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct Limits { diff --git a/src/lib.rs b/src/lib.rs index 55f86a59..61183600 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,7 +133,6 @@ pub(crate) type Identifier = SmartString; /// An identifier in Rhai. [`SmartString`](https://crates.io/crates/smartstring) is used because most /// identifiers are ASCII and short, fewer than 23 characters, so they can be stored inline. #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub type Identifier = SmartString; /// Alias to [`Rc`][std::rc::Rc] or [`Arc`][std::sync::Arc] depending on the `sync` feature flag. @@ -188,26 +187,21 @@ pub use optimizer::OptimizationLevel; // Expose internal data structures. #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub use types::dynamic::{AccessMode, DynamicReadLock, DynamicWriteLock, Variant}; #[cfg(feature = "internals")] -#[deprecated = "this function is volatile and may change"] pub use tokenizer::{get_next_token, parse_string_literal}; #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub use tokenizer::{ InputStream, MultiInputsStream, Token, TokenIterator, TokenizeState, TokenizerControl, TokenizerControlBlock, }; #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub use parser::{IdentifierBuilder, ParseState}; #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub use ast::{ ASTNode, BinaryExpr, CustomExpr, Expr, FnCallExpr, FnCallHashes, Ident, OpAssignment, OptionFlags, ScriptFnDef, Stmt, StmtBlock, AST_OPTION_FLAGS::*, @@ -215,20 +209,16 @@ pub use ast::{ #[cfg(feature = "internals")] #[cfg(not(feature = "no_float"))] -#[deprecated = "this type is volatile and may change"] pub use ast::FloatWrapper; #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub use engine::{EvalState, FnResolutionCache, FnResolutionCacheEntry, Imports}; #[cfg(feature = "internals")] #[cfg(not(feature = "unchecked"))] -#[deprecated = "this type is volatile and may change"] pub use engine::Limits; #[cfg(feature = "internals")] -#[deprecated = "this type is volatile and may change"] pub use module::NamespaceRef; /// Alias to [`smallvec::SmallVec<[T; 3]>`](https://crates.io/crates/smallvec), which is a diff --git a/src/module/mod.rs b/src/module/mod.rs index 5479d087..1b11150e 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1676,10 +1676,6 @@ impl Module { /// /// A [`StaticVec`] is used because most namespace-qualified access contains only one level, /// and it is wasteful to always allocate a [`Vec`] with one element. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Clone, Eq, PartialEq, Default, Hash)] pub struct NamespaceRef { index: Option, diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 968b66e5..46d75684 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -29,10 +29,6 @@ use rust_decimal::Decimal; use crate::engine::KEYWORD_IS_DEF_FN; /// _(internals)_ A type containing commands to control the tokenizer. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Eq, PartialEq, Hash, Copy)] pub struct TokenizerControlBlock { /// Is the current tokenizer position within an interpolated text string? @@ -301,10 +297,6 @@ impl AddAssign for Position { /// _(internals)_ A Rhai language token. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, PartialEq, Clone, Hash)] pub enum Token { /// An `INT` constant. @@ -1002,10 +994,6 @@ impl From for String { /// _(internals)_ State of the tokenizer. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Clone, Eq, PartialEq, Default)] pub struct TokenizeState { /// Maximum length of a string. @@ -1022,10 +1010,6 @@ pub struct TokenizeState { /// _(internals)_ Trait that encapsulates a peekable character input stream. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This trait is volatile and may change. pub trait InputStream { /// Un-get a character back into the `InputStream`. /// The next [`get_next`][InputStream::get_next] or [`peek_next`][InputStream::peek_next] @@ -1068,10 +1052,6 @@ pub trait InputStream { /// /// Any time a [`StringConstant`][`Token::StringConstant`] is returned with /// `state.is_within_text_terminated_by` set to `Some(_)` is one of the above conditions. -/// -/// # Volatile API -/// -/// This function is volatile and may change. pub fn parse_string_literal( stream: &mut impl InputStream, state: &mut TokenizeState, @@ -1328,10 +1308,6 @@ fn scan_block_comment( /// _(internals)_ Get the next token from the `stream`. /// Exported under the `internals` feature only. -/// -/// # Volatile API -/// -/// This function is volatile and may change. #[inline] #[must_use] pub fn get_next_token( @@ -2139,10 +2115,6 @@ impl InputStream for MultiInputsStream<'_> { /// _(internals)_ An iterator on a [`Token`] stream. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. pub struct TokenIterator<'a> { /// Reference to the scripting `Engine`. pub engine: &'a Engine, diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index a2b5b970..e0c56a87 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -234,10 +234,6 @@ pub enum Union { /// /// This type provides transparent interoperability between normal [`Dynamic`] and shared /// [`Dynamic`] values. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug)] pub struct DynamicReadLock<'d, T: Clone>(DynamicReadLockInner<'d, T>); @@ -275,10 +271,6 @@ impl<'d, T: Any + Clone> Deref for DynamicReadLock<'d, T> { /// /// This type provides transparent interoperability between normal [`Dynamic`] and shared /// [`Dynamic`] values. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug)] pub struct DynamicWriteLock<'d, T: Clone>(DynamicWriteLockInner<'d, T>); diff --git a/src/types/fn_ptr.rs b/src/types/fn_ptr.rs index 3f4bfe4a..3b26e1d0 100644 --- a/src/types/fn_ptr.rs +++ b/src/types/fn_ptr.rs @@ -141,6 +141,7 @@ impl FnPtr { args.parse(&mut arg_values); let lib = [ast.as_ref()]; + #[allow(deprecated)] let ctx = NativeCallContext::new(engine, self.fn_name(), &lib); let result = self.call_dynamic(&ctx, None, arg_values)?; diff --git a/src/types/parse_error.rs b/src/types/parse_error.rs index 66b740b6..da537cdb 100644 --- a/src/types/parse_error.rs +++ b/src/types/parse_error.rs @@ -11,10 +11,6 @@ use std::prelude::v1::*; /// _(internals)_ Error encountered when tokenizing the script text. /// Exported under the `internals` feature only. -/// -/// # Volatile Data Structure -/// -/// This type is volatile and may change. #[derive(Debug, Eq, PartialEq, Clone, Hash)] #[non_exhaustive] pub enum LexError { diff --git a/tests/call_fn.rs b/tests/call_fn.rs index 82d134c1..4a2d776f 100644 --- a/tests/call_fn.rs +++ b/tests/call_fn.rs @@ -132,7 +132,6 @@ fn test_call_fn_private() -> Result<(), Box> { fn test_fn_ptr_raw() -> Result<(), Box> { let mut engine = Engine::new(); - #[allow(deprecated)] engine .register_fn("mul", |x: &mut INT, y: INT| *x *= y) .register_raw_fn( diff --git a/tests/closures.rs b/tests/closures.rs index a53eeb77..e87606db 100644 --- a/tests/closures.rs +++ b/tests/closures.rs @@ -12,7 +12,6 @@ use rhai::Map; fn test_fn_ptr_curry_call() -> Result<(), Box> { let mut engine = Engine::new(); - #[allow(deprecated)] engine.register_raw_fn( "call_with_arg", &[TypeId::of::(), TypeId::of::()], @@ -150,7 +149,6 @@ fn test_closures() -> Result<(), Box> { 42 ); - #[allow(deprecated)] engine.register_raw_fn( "custom_call", &[TypeId::of::(), TypeId::of::()], diff --git a/tests/native.rs b/tests/native.rs index 28b00680..22d005a1 100644 --- a/tests/native.rs +++ b/tests/native.rs @@ -30,7 +30,6 @@ fn test_native_context_fn_name() -> Result<(), Box> { let mut engine = Engine::new(); - #[allow(deprecated)] engine .register_raw_fn( "add_double",