diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73eda1e04..c0e605163 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,16 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - run: cargo test --all-targets --all-features + - run: > + cargo test --lib --all-features -- --exact + --skip tests::compiler_docs::harvest_docs + --skip tests::custom_macros::attribute_imports_builtin + --skip tests::custom_macros::conflicting_attribute_function + --skip tests::macros::test_make_function + --skip tests::macros::test_rename + --skip tests::scripts::simple_script + env: + RUNEFLAGS: v2=true test_doc: runs-on: ubuntu-latest @@ -38,6 +48,11 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - run: cargo test --doc --all-features + - run: > + cargo test --doc --all-features -- --exact + --skip macros + env: + RUNEFLAGS: v2=true rustfmt: runs-on: ubuntu-latest @@ -205,3 +220,6 @@ jobs: - run: cargo run --release --bin rune -- check --recursive scripts - run: cargo run --release --bin rune -- check --all-targets - run: cargo run --release --bin rune -- test --all-targets -O test-std=true + - run: cargo run --release --bin rune -- test --all-targets -O test-std=true + env: + RUNEFLAGS: v2=true diff --git a/crates/rune/src/grammar/tree.rs b/crates/rune/src/grammar/tree.rs index 1493ca645..9064c817a 100644 --- a/crates/rune/src/grammar/tree.rs +++ b/crates/rune/src/grammar/tree.rs @@ -346,7 +346,7 @@ impl<'a> Stream<'a> { Span::point(self.node.span().end) } - fn peek_node(&mut self) -> Option<&syntree::Node<'a, Kind, Flavor>> { + fn peek_node(&mut self) -> Option<&InternalNode<'a>> { if self.peek.is_none() { if let Some(node) = self.next_node() { self.peek = Some(node); diff --git a/crates/rune/src/hir/arena.rs b/crates/rune/src/hir/arena.rs index 8c9dbf0c0..ee5a24977 100644 --- a/crates/rune/src/hir/arena.rs +++ b/crates/rune/src/hir/arena.rs @@ -104,7 +104,9 @@ impl Arena { /// Allocate a new object of the given type. #[expect(clippy::mut_from_ref)] pub(crate) fn alloc(&self, object: T) -> Result<&mut T, ArenaAllocError> { - assert!(!mem::needs_drop::()); + const { + assert!(!mem::needs_drop::(), "cannot allocate drop element"); + } let mut ptr = self.alloc_raw(Layout::for_value::(&object))?.cast(); @@ -117,7 +119,9 @@ impl Arena { /// Allocate an iterator with the given length as a slice. pub(crate) fn alloc_iter(&self, len: usize) -> Result, ArenaAllocError> { - assert!(!mem::needs_drop::(), "cannot allocate drop element"); + const { + assert!(!mem::needs_drop::(), "cannot allocate drop element"); + } let mem = if len == 0 { None diff --git a/crates/rune/src/hir/lowering.rs b/crates/rune/src/hir/lowering.rs index 69afee2d7..f7c618b25 100644 --- a/crates/rune/src/hir/lowering.rs +++ b/crates/rune/src/hir/lowering.rs @@ -9,7 +9,7 @@ use crate::ast::{self, NumberSize, Spanned}; use crate::compile::meta; use crate::compile::{self, ErrorKind, WithSpan}; use crate::hash::ParametersBuilder; -use crate::hir; +use crate::hir::{self, alloc_with}; use crate::internal_macros::resolve_context; use crate::parse::Resolve; use crate::query::AsyncBlock; diff --git a/crates/rune/src/hir/lowering2.rs b/crates/rune/src/hir/lowering2.rs index a634c6321..4b3c00546 100644 --- a/crates/rune/src/hir/lowering2.rs +++ b/crates/rune/src/hir/lowering2.rs @@ -13,7 +13,7 @@ use crate::grammar::{ classify, object_key, Ignore, MaybeNode, NodeClass, Remaining, Stream, StreamBuf, Tree, }; use crate::hash::ParametersBuilder; -use crate::hir; +use crate::hir::{self, alloc_with}; use crate::internal_macros::resolve_context; use crate::parse::{NonZeroId, Resolve}; use crate::query::{self, GenericsParameters, Named2, Named2Kind, Used}; @@ -35,8 +35,8 @@ pub(crate) fn bare<'hir>( ) -> Result> { alloc_with!(cx, p); - let body = statements(cx, None, p)?; let args = iter!(args, |name| named_arg(cx, name, p)?); + let body = statements(cx, None, p)?; Ok(hir::ItemFn { span: p.span(), @@ -55,13 +55,15 @@ fn named_arg<'hir>( let name = cx.scopes.define(hir::Name::Str(name), span)?; let names = iter!([name]); - Ok(hir::FnArg::Pat(alloc!(hir::PatBinding { + let pat = alloc!(hir::PatBinding { pat: hir::Pat { span: span.span(), kind: hir::PatKind::Path(alloc!(hir::PatPathKind::Ident(name))), }, names, - }))) + }); + + Ok(hir::FnArg::Pat(pat)) } /// Lower a function item. diff --git a/crates/rune/src/hir/macros.rs b/crates/rune/src/hir/macros.rs index eb7c28cc3..075f0e012 100644 --- a/crates/rune/src/hir/macros.rs +++ b/crates/rune/src/hir/macros.rs @@ -1,6 +1,6 @@ /// Allocator indirection to simplify lifetime management. #[rustfmt::skip] -macro_rules! alloc_with { +macro_rules! __alloc_with { ($cx:expr, $span:expr) => { #[allow(unused)] macro_rules! alloc { @@ -107,3 +107,5 @@ macro_rules! alloc_with { } }; } + +pub(super) use __alloc_with as alloc_with; diff --git a/crates/rune/src/hir/mod.rs b/crates/rune/src/hir/mod.rs index 4261736f1..bb3a60a5e 100644 --- a/crates/rune/src/hir/mod.rs +++ b/crates/rune/src/hir/mod.rs @@ -1,5 +1,5 @@ -#[macro_use] mod macros; +use self::macros::alloc_with; mod arena; pub(crate) use self::arena::Arena;