Skip to content

Commit 28c0f96

Browse files
authored
Merge pull request #831 from schungx/fix
Fix code_gen semver.
2 parents f97fbcb + 375e312 commit 28c0f96

File tree

14 files changed

+53
-57
lines changed

14 files changed

+53
-57
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- master
8+
- fix
89
pull_request: {}
910

1011
env:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Rhai Release Notes
22
==================
33

4+
Version 1.17.1
5+
==============
6+
7+
This is a bug-fix release that bumps `rhai_codegen` version to `2.0.0` to satisfy semver rules.
8+
9+
410
Version 1.17.0
511
==============
612

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = [".", "codegen"]
33

44
[package]
55
name = "rhai"
6-
version = "1.17.0"
6+
version = "1.17.1"
77
rust-version = "1.66.0"
88
edition = "2018"
99
resolver = "2"
@@ -25,7 +25,7 @@ num-traits = { version = "0.2.0", default-features = false }
2525
once_cell = { version = "1.7.0", default-features = false, features = ["race"] }
2626
bitflags = { version = "2.0.0", default-features = false }
2727
smartstring = { version = "1.0.0", default-features = false }
28-
rhai_codegen = { version = "1.17.0", path = "codegen" }
28+
rhai_codegen = { version = "2.0.0", path = "codegen" }
2929

3030
no-std-compat = { git = "https://gitlab.com/jD91mZM2/no-std-compat", version = "0.4.1", default-features = false, features = ["alloc"], optional = true }
3131
libm = { version = "0.2.0", default-features = false, optional = true }

codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rhai_codegen"
3-
version = "1.17.0"
3+
version = "2.0.0"
44
edition = "2018"
55
resolver = "2"
66
authors = ["jhwgh1968", "Stephen Chung"]

src/ast/ast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Module defining the AST (abstract syntax tree).
22
33
use super::{ASTFlags, Expr, FnAccess, Stmt};
4-
use crate::{Dynamic, FnNamespace, ImmutableString, Position};
4+
use crate::{Dynamic, FnNamespace, ImmutableString, Position, ThinVec};
55
#[cfg(feature = "no_std")]
66
use std::prelude::v1::*;
77
use std::{
@@ -11,7 +11,6 @@ use std::{
1111
ops::{Add, AddAssign},
1212
ptr,
1313
};
14-
use thin_vec::ThinVec;
1514

1615
/// Compiled AST (abstract syntax tree) of a Rhai script.
1716
///
@@ -989,7 +988,7 @@ pub struct EncapsulatedEnviron {
989988
pub lib: crate::SharedModule,
990989
/// Imported [modules][crate::Module].
991990
#[cfg(not(feature = "no_module"))]
992-
pub imports: thin_vec::ThinVec<(ImmutableString, crate::SharedModule)>,
991+
pub imports: crate::ThinVec<(ImmutableString, crate::SharedModule)>,
993992
/// Globally-defined constants.
994993
#[cfg(not(feature = "no_module"))]
995994
#[cfg(not(feature = "no_function"))]

src/ast/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::tokenizer::Token;
66
use crate::types::dynamic::Union;
77
use crate::{
88
calc_fn_hash, Dynamic, FnArgsVec, FnPtr, Identifier, ImmutableString, Position, SmartString,
9-
StaticVec, INT,
9+
StaticVec, ThinVec, INT,
1010
};
1111
#[cfg(feature = "no_std")]
1212
use std::prelude::v1::*;
@@ -19,7 +19,6 @@ use std::{
1919
mem,
2020
num::{NonZeroU8, NonZeroUsize},
2121
};
22-
use thin_vec::ThinVec;
2322

2423
/// _(internals)_ A binary expression.
2524
/// Exported under the `internals` feature only.

src/eval/debugger.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
use super::{Caches, EvalContext, GlobalRuntimeState};
55
use crate::ast::{ASTNode, Expr, Stmt};
6-
use crate::{Dynamic, Engine, EvalAltResult, ImmutableString, Position, RhaiResultOf, Scope};
6+
use crate::{
7+
Dynamic, Engine, EvalAltResult, ImmutableString, Position, RhaiResultOf, Scope, ThinVec,
8+
};
79
#[cfg(feature = "no_std")]
810
use std::prelude::v1::*;
911
use std::{fmt, iter::repeat, mem};
10-
use thin_vec::ThinVec;
1112

1213
/// Callback function to initialize the debugger.
1314
#[cfg(not(feature = "sync"))]

src/eval/global_state.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ pub type SharedGlobalConstants =
2525
pub struct GlobalRuntimeState {
2626
/// Names of imported [modules][crate::Module].
2727
#[cfg(not(feature = "no_module"))]
28-
imports: thin_vec::ThinVec<ImmutableString>,
28+
imports: crate::ThinVec<ImmutableString>,
2929
/// Stack of imported [modules][crate::Module].
3030
#[cfg(not(feature = "no_module"))]
31-
modules: thin_vec::ThinVec<crate::SharedModule>,
31+
modules: crate::ThinVec<crate::SharedModule>,
3232

3333
/// The current stack of loaded [modules][crate::Module] containing script-defined functions.
3434
#[cfg(not(feature = "no_function"))]
35-
pub lib: thin_vec::ThinVec<crate::SharedModule>,
35+
pub lib: crate::ThinVec<crate::SharedModule>,
3636
/// Source of the current context.
3737
///
3838
/// No source if the string is empty.
@@ -82,11 +82,11 @@ impl GlobalRuntimeState {
8282
pub fn new(engine: &Engine) -> Self {
8383
Self {
8484
#[cfg(not(feature = "no_module"))]
85-
imports: thin_vec::ThinVec::new(),
85+
imports: crate::ThinVec::new(),
8686
#[cfg(not(feature = "no_module"))]
87-
modules: thin_vec::ThinVec::new(),
87+
modules: crate::ThinVec::new(),
8888
#[cfg(not(feature = "no_function"))]
89-
lib: thin_vec::ThinVec::new(),
89+
lib: crate::ThinVec::new(),
9090
source: None,
9191
num_operations: 0,
9292
#[cfg(not(feature = "no_module"))]

src/lib.rs

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -385,37 +385,7 @@ pub use api::definitions::Definitions;
385385
/// Number of items to keep inline for [`StaticVec`].
386386
const STATIC_VEC_INLINE_SIZE: usize = 3;
387387

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

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

427+
/// A smaller [`Vec`] alternative.
428+
#[cfg(not(feature = "internals"))]
429+
type ThinVec<T> = thin_vec::ThinVec<T>;
430+
431+
/// _(internals)_ A smaller [`Vec`] alternative. Exported under the `internals` feature only.
432+
///
433+
/// The standard [`Vec`] type uses three machine words (i.e. 24 bytes on 64-bit).
434+
///
435+
/// [`ThinVec`](https://crates.io/crates/thin-vec) only uses one machine word, storing other
436+
/// information inline together with the data.
437+
///
438+
/// This is primarily used in places where a few bytes affect the size of the type
439+
/// -- e.g. in `enum`'s.
440+
#[cfg(feature = "internals")]
441+
pub type ThinVec<T> = thin_vec::ThinVec<T>;
442+
457443
/// Number of items to keep inline for [`FnArgsVec`].
458444
#[cfg(not(feature = "no_closure"))]
459445
const FN_ARGS_VEC_INLINE_SIZE: usize = 5;
460446

461447
/// Inline arguments storage for function calls.
448+
#[cfg(not(feature = "no_closure"))]
449+
#[cfg(not(feature = "internals"))]
450+
type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;
451+
452+
/// _(internals)_ Inline arguments storage for function calls.
453+
///
454+
/// Not available under `no_closure`.
462455
///
463456
/// # Notes
464457
///
@@ -471,7 +464,8 @@ const FN_ARGS_VEC_INLINE_SIZE: usize = 5;
471464
///
472465
/// Under `no_closure`, this type aliases to [`StaticVec`][crate::StaticVec] instead.
473466
#[cfg(not(feature = "no_closure"))]
474-
type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;
467+
#[cfg(feature = "internals")]
468+
pub type FnArgsVec<T> = smallvec::SmallVec<[T; FN_ARGS_VEC_INLINE_SIZE]>;
475469

476470
/// Inline arguments storage for function calls.
477471
/// This type aliases to [`StaticVec`][crate::StaticVec].

src/module/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ impl Module {
22372237
let mut module = Self::new();
22382238

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

22422242
if result.is_ok() {
22432243
global

0 commit comments

Comments
 (0)