Remove volatile warnings for types and functions exposed unter internals.

This commit is contained in:
Stephen Chung 2021-11-28 22:03:02 +08:00
parent c5317d7706
commit dca47d5233
12 changed files with 1 additions and 126 deletions

View File

@ -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<N, T>(
&mut self,

View File

@ -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<Module> 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<Stmt>, 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<FLOAT> {
/// _(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.

View File

@ -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<T: Into<Dynamic>> From<T> 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<u64, Option<Box<FnResolutionCacheEntry>>>;
/// _(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 {

View File

@ -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

View File

@ -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<NonZeroUsize>,

View File

@ -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<Token> 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,

View File

@ -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>);

View File

@ -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)?;

View File

@ -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 {

View File

@ -132,7 +132,6 @@ fn test_call_fn_private() -> Result<(), Box<EvalAltResult>> {
fn test_fn_ptr_raw() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();
#[allow(deprecated)]
engine
.register_fn("mul", |x: &mut INT, y: INT| *x *= y)
.register_raw_fn(

View File

@ -12,7 +12,6 @@ use rhai::Map;
fn test_fn_ptr_curry_call() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();
#[allow(deprecated)]
engine.register_raw_fn(
"call_with_arg",
&[TypeId::of::<FnPtr>(), TypeId::of::<INT>()],
@ -150,7 +149,6 @@ fn test_closures() -> Result<(), Box<EvalAltResult>> {
42
);
#[allow(deprecated)]
engine.register_raw_fn(
"custom_call",
&[TypeId::of::<INT>(), TypeId::of::<FnPtr>()],

View File

@ -30,7 +30,6 @@ fn test_native_context_fn_name() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();
#[allow(deprecated)]
engine
.register_raw_fn(
"add_double",