Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion crates/rune/src/grammar/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions crates/rune/src/hir/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ impl Arena {
/// Allocate a new object of the given type.
#[expect(clippy::mut_from_ref)]
pub(crate) fn alloc<T>(&self, object: T) -> Result<&mut T, ArenaAllocError> {
assert!(!mem::needs_drop::<T>());
const {
assert!(!mem::needs_drop::<T>(), "cannot allocate drop element");
}

let mut ptr = self.alloc_raw(Layout::for_value::<T>(&object))?.cast();

Expand All @@ -117,7 +119,9 @@ impl Arena {

/// Allocate an iterator with the given length as a slice.
pub(crate) fn alloc_iter<T>(&self, len: usize) -> Result<AllocIter<'_, T>, ArenaAllocError> {
assert!(!mem::needs_drop::<T>(), "cannot allocate drop element");
const {
assert!(!mem::needs_drop::<T>(), "cannot allocate drop element");
}

let mem = if len == 0 {
None
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions crates/rune/src/hir/lowering2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -35,8 +35,8 @@ pub(crate) fn bare<'hir>(
) -> Result<hir::ItemFn<'hir>> {
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(),
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion crates/rune/src/hir/macros.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -107,3 +107,5 @@ macro_rules! alloc_with {
}
};
}

pub(super) use __alloc_with as alloc_with;
2 changes: 1 addition & 1 deletion crates/rune/src/hir/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use]
mod macros;
use self::macros::alloc_with;

mod arena;
pub(crate) use self::arena::Arena;
Expand Down
Loading