Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code_gen semver. #831

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- master
- fix
pull_request: {}

env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Rhai Release Notes
==================

Version 1.17.1
==============

This is a bug-fix release that bumps `rhai_codegen` version to `2.0.0` to satisfy semver rules.


Version 1.17.0
==============

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "codegen"]

[package]
name = "rhai"
version = "1.17.0"
version = "1.17.1"
rust-version = "1.66.0"
edition = "2018"
resolver = "2"
Expand All @@ -25,7 +25,7 @@ num-traits = { version = "0.2.0", default-features = false }
once_cell = { version = "1.7.0", default-features = false, features = ["race"] }
bitflags = { version = "2.0.0", default-features = false }
smartstring = { version = "1.0.0", default-features = false }
rhai_codegen = { version = "1.17.0", path = "codegen" }
rhai_codegen = { version = "2.0.0", path = "codegen" }

no-std-compat = { git = "https://gitlab.com/jD91mZM2/no-std-compat", version = "0.4.1", default-features = false, features = ["alloc"], optional = true }
libm = { version = "0.2.0", default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rhai_codegen"
version = "1.17.0"
version = "2.0.0"
edition = "2018"
resolver = "2"
authors = ["jhwgh1968", "Stephen Chung"]
Expand Down
5 changes: 2 additions & 3 deletions src/ast/ast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Module defining the AST (abstract syntax tree).

use super::{ASTFlags, Expr, FnAccess, Stmt};
use crate::{Dynamic, FnNamespace, ImmutableString, Position};
use crate::{Dynamic, FnNamespace, ImmutableString, Position, ThinVec};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{
Expand All @@ -11,7 +11,6 @@ use std::{
ops::{Add, AddAssign},
ptr,
};
use thin_vec::ThinVec;

/// Compiled AST (abstract syntax tree) of a Rhai script.
///
Expand Down Expand Up @@ -989,7 +988,7 @@ pub struct EncapsulatedEnviron {
pub lib: crate::SharedModule,
/// Imported [modules][crate::Module].
#[cfg(not(feature = "no_module"))]
pub imports: thin_vec::ThinVec<(ImmutableString, crate::SharedModule)>,
pub imports: crate::ThinVec<(ImmutableString, crate::SharedModule)>,
/// Globally-defined constants.
#[cfg(not(feature = "no_module"))]
#[cfg(not(feature = "no_function"))]
Expand Down
3 changes: 1 addition & 2 deletions src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::tokenizer::Token;
use crate::types::dynamic::Union;
use crate::{
calc_fn_hash, Dynamic, FnArgsVec, FnPtr, Identifier, ImmutableString, Position, SmartString,
StaticVec, INT,
StaticVec, ThinVec, INT,
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
Expand All @@ -19,7 +19,6 @@ use std::{
mem,
num::{NonZeroU8, NonZeroUsize},
};
use thin_vec::ThinVec;

/// _(internals)_ A binary expression.
/// Exported under the `internals` feature only.
Expand Down
5 changes: 3 additions & 2 deletions src/eval/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

use super::{Caches, EvalContext, GlobalRuntimeState};
use crate::ast::{ASTNode, Expr, Stmt};
use crate::{Dynamic, Engine, EvalAltResult, ImmutableString, Position, RhaiResultOf, Scope};
use crate::{
Dynamic, Engine, EvalAltResult, ImmutableString, Position, RhaiResultOf, Scope, ThinVec,
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{fmt, iter::repeat, mem};
use thin_vec::ThinVec;

/// Callback function to initialize the debugger.
#[cfg(not(feature = "sync"))]
Expand Down
12 changes: 6 additions & 6 deletions src/eval/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ pub type SharedGlobalConstants =
pub struct GlobalRuntimeState {
/// Names of imported [modules][crate::Module].
#[cfg(not(feature = "no_module"))]
imports: thin_vec::ThinVec<ImmutableString>,
imports: crate::ThinVec<ImmutableString>,
/// Stack of imported [modules][crate::Module].
#[cfg(not(feature = "no_module"))]
modules: thin_vec::ThinVec<crate::SharedModule>,
modules: crate::ThinVec<crate::SharedModule>,

/// The current stack of loaded [modules][crate::Module] containing script-defined functions.
#[cfg(not(feature = "no_function"))]
pub lib: thin_vec::ThinVec<crate::SharedModule>,
pub lib: crate::ThinVec<crate::SharedModule>,
/// Source of the current context.
///
/// No source if the string is empty.
Expand Down Expand Up @@ -82,11 +82,11 @@ impl GlobalRuntimeState {
pub fn new(engine: &Engine) -> Self {
Self {
#[cfg(not(feature = "no_module"))]
imports: thin_vec::ThinVec::new(),
imports: crate::ThinVec::new(),
#[cfg(not(feature = "no_module"))]
modules: thin_vec::ThinVec::new(),
modules: crate::ThinVec::new(),
#[cfg(not(feature = "no_function"))]
lib: thin_vec::ThinVec::new(),
lib: crate::ThinVec::new(),
source: None,
num_operations: 0,
#[cfg(not(feature = "no_module"))]
Expand Down
58 changes: 26 additions & 32 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,37 +385,7 @@ pub use api::definitions::Definitions;
/// Number of items to keep inline for [`StaticVec`].
const STATIC_VEC_INLINE_SIZE: usize = 3;

/// Alias to [`smallvec::SmallVec<[T; 3]>`](https://crates.io/crates/smallvec), which is a
/// specialized [`Vec`] backed by a small, inline, fixed-size array when there are ≤ 3 items stored.
///
/// # History
///
/// And Saint Attila raised the `SmallVec` up on high, saying, "O Lord, bless this Thy `SmallVec`
/// that, with it, Thou mayest blow Thine allocation costs to tiny bits in Thy mercy."
///
/// And the Lord did grin, and the people did feast upon the lambs and sloths and carp and anchovies
/// and orangutans and breakfast cereals and fruit bats and large chu...
///
/// And the Lord spake, saying, "First shalt thou depend on the [`smallvec`](https://crates.io/crates/smallvec) crate.
/// Then, shalt thou keep three inline. No more. No less. Three shalt be the number thou shalt keep inline,
/// and the number to keep inline shalt be three. Four shalt thou not keep inline, nor either keep inline
/// thou two, excepting that thou then proceed to three. Five is right out. Once the number three,
/// being the third number, be reached, then, lobbest thou thy `SmallVec` towards thy heap, who,
/// being slow and cache-naughty in My sight, shall snuff it."
///
/// # Why Three
///
/// `StaticVec` is used frequently to keep small lists of items in inline (non-heap) storage in
/// order to improve cache friendliness and reduce indirections.
///
/// The number 3, other than being the holy number, is carefully chosen for a balance between
/// storage space and reduce allocations. That is because most function calls (and most functions,
/// for that matter) contain fewer than 4 arguments, the exception being closures that capture a
/// large number of external variables.
///
/// In addition, most script blocks either contain many statements, or just one or two lines;
/// most scripts load fewer than 4 external modules; most module paths contain fewer than 4 levels
/// (e.g. `std::collections::map::HashMap` is 4 levels and it is just about as long as they get).
/// Alias to [`smallvec::SmallVec<[T; 3]>`](https://crates.io/crates/smallvec).
#[cfg(not(feature = "internals"))]
type StaticVec<T> = smallvec::SmallVec<[T; STATIC_VEC_INLINE_SIZE]>;

Expand Down Expand Up @@ -454,11 +424,34 @@ type StaticVec<T> = smallvec::SmallVec<[T; STATIC_VEC_INLINE_SIZE]>;
#[cfg(feature = "internals")]
pub type StaticVec<T> = smallvec::SmallVec<[T; STATIC_VEC_INLINE_SIZE]>;

/// A smaller [`Vec`] alternative.
#[cfg(not(feature = "internals"))]
type ThinVec<T> = thin_vec::ThinVec<T>;

/// _(internals)_ A smaller [`Vec`] alternative. Exported under the `internals` feature only.
///
/// The standard [`Vec`] type uses three machine words (i.e. 24 bytes on 64-bit).
///
/// [`ThinVec`](https://crates.io/crates/thin-vec) only uses one machine word, storing other
/// information inline together with the data.
///
/// This is primarily used in places where a few bytes affect the size of the type
/// -- e.g. in `enum`'s.
#[cfg(feature = "internals")]
pub type ThinVec<T> = thin_vec::ThinVec<T>;

/// Number of items to keep inline for [`FnArgsVec`].
#[cfg(not(feature = "no_closure"))]
const FN_ARGS_VEC_INLINE_SIZE: usize = 5;

/// Inline arguments storage for function calls.
#[cfg(not(feature = "no_closure"))]
#[cfg(not(feature = "internals"))]
type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;

/// _(internals)_ Inline arguments storage for function calls.
///
/// Not available under `no_closure`.
///
/// # Notes
///
Expand All @@ -471,7 +464,8 @@ const FN_ARGS_VEC_INLINE_SIZE: usize = 5;
///
/// Under `no_closure`, this type aliases to [`StaticVec`][crate::StaticVec] instead.
#[cfg(not(feature = "no_closure"))]
type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;
#[cfg(feature = "internals")]
pub type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;

/// Inline arguments storage for function calls.
/// This type aliases to [`StaticVec`][crate::StaticVec].
Expand Down
2 changes: 1 addition & 1 deletion src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ impl Module {
let mut module = Self::new();

// Extra modules left become sub-modules
let mut imports = thin_vec::ThinVec::new();
let mut imports = crate::ThinVec::new();

if result.is_ok() {
global
Expand Down
3 changes: 1 addition & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use crate::{
calc_fn_hash, Dynamic, Engine, EvalAltResult, EvalContext, ExclusiveRange, FnArgsVec,
ImmutableString, InclusiveRange, LexError, OptimizationLevel, ParseError, Position, Scope,
Shared, SmartString, StaticVec, VarDefInfo, AST, PERR,
Shared, SmartString, StaticVec, ThinVec, VarDefInfo, AST, PERR,
};
use bitflags::bitflags;
#[cfg(feature = "no_std")]
Expand All @@ -31,7 +31,6 @@
hash::{Hash, Hasher},
num::{NonZeroU8, NonZeroUsize},
};
use thin_vec::ThinVec;

pub type ParseResult<T> = Result<T, ParseError>;

Expand Down Expand Up @@ -3813,7 +3812,7 @@
settings: ParseSettings,
_parent: &mut ParseState,
) -> ParseResult<(Expr, Shared<ScriptFuncDef>)> {
use core::iter::FromIterator;

Check warning on line 3815 in src/parser.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_closure,serde,metadata,internals,debugging, s...

unused import: `core::iter::FromIterator`

let settings = settings.level_up()?;
let mut params_list = StaticVec::<ImmutableString>::new_const();
Expand Down
3 changes: 1 addition & 2 deletions src/serde/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use crate::api::formatting::format_param_type_for_display;
use crate::func::RhaiFunc;
use crate::module::{calc_native_fn_hash, FuncMetadata, ModuleFlags};
use crate::types::custom_types::CustomTypeInfo;
use crate::{calc_fn_hash, Engine, FnAccess, SmartString, AST};
use crate::{calc_fn_hash, Engine, FnAccess, SmartString, ThinVec, AST};
use serde::{Deserialize, Serialize};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{borrow::Cow, cmp::Ordering, collections::BTreeMap};
use thin_vec::ThinVec;

#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
3 changes: 1 addition & 2 deletions src/types/fn_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::tokenizer::{is_reserved_keyword_or_symbol, is_valid_function_name, To
use crate::types::dynamic::Variant;
use crate::{
Dynamic, Engine, FnArgsVec, FuncArgs, ImmutableString, NativeCallContext, Position, RhaiError,
RhaiResult, RhaiResultOf, Shared, StaticVec, AST, ERR, PERR,
RhaiResult, RhaiResultOf, Shared, StaticVec, ThinVec, AST, ERR, PERR,
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
Expand All @@ -16,7 +16,6 @@ use std::{
fmt, mem,
ops::{Index, IndexMut},
};
use thin_vec::ThinVec;

/// A general function pointer, which may carry additional (i.e. curried) argument values
/// to be passed onto a function during a call.
Expand Down
3 changes: 1 addition & 2 deletions src/types/scope.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! Module that defines the [`Scope`] type representing a function call-stack scope.

use super::dynamic::{AccessMode, Variant};
use crate::{Dynamic, Identifier, ImmutableString, StaticVec};
use crate::{Dynamic, Identifier, ImmutableString, StaticVec, ThinVec};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{
fmt, iter,
iter::{Extend, FromIterator},
marker::PhantomData,
};
use thin_vec::ThinVec;

/// Minimum number of entries in the [`Scope`] to avoid reallocations.
pub const MIN_SCOPE_ENTRIES: usize = 8;
Expand Down
Loading