From 9f5c3277443ef779ea28dbe93e281654f063212e Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Mon, 5 Aug 2024 10:52:03 +0200 Subject: [PATCH] chore: Unfudge release build --- .github/workflows/ci.yml | 3 + crates/rune/src/compile/v1/needs.rs | 23 +------ crates/rune/src/shared/mod.rs | 98 +++++++++++++++-------------- 3 files changed, 55 insertions(+), 69 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc8e0c9e2..17eb2a543 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,11 +117,14 @@ jobs: fail-fast: false matrix: feature: [capture-io, "cli,doc", "cli,fmt", cli, workspace, languageserver, byte-code] + env: + RUSTFLAGS: -D warnings steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - run: cargo build -p rune --no-default-features --features ${{matrix.feature}} + - run: cargo check --release -p rune --no-default-features --features ${{matrix.feature}} wasm: runs-on: ubuntu-latest diff --git a/crates/rune/src/compile/v1/needs.rs b/crates/rune/src/compile/v1/needs.rs index 5be0bf19f..3f6181a28 100644 --- a/crates/rune/src/compile/v1/needs.rs +++ b/crates/rune/src/compile/v1/needs.rs @@ -4,13 +4,10 @@ use core::mem::replace; use crate::ast::Spanned; use crate::compile; use crate::runtime::{Inst, InstAddress, Output}; -use crate::shared::rune_diagnose; +use crate::shared::{rune_diagnose, Backtrace}; use super::{Ctxt, DisplayNamed, ScopeId, Scopes}; -#[cfg(debug_assertions)] -use crate::shared::Backtrace; - /// Trait used to abstract interactions over different needs. pub(super) trait Needs<'a, 'hir> { /// Access the span for the needs. @@ -171,7 +168,6 @@ pub(super) struct Address<'a, 'hir> { kind: AddressKind, /// A diagnostical name for the address. name: Option<&'static str>, - #[cfg(debug_assertions)] backtrace: Backtrace, } @@ -190,7 +186,6 @@ impl<'a, 'hir> Address<'a, 'hir> { address: addr, kind: AddressKind::Local, name: None, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), } } @@ -209,7 +204,6 @@ impl<'a, 'hir> Address<'a, 'hir> { address: addr, kind: AddressKind::Assigned, name: None, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), } } @@ -228,7 +222,6 @@ impl<'a, 'hir> Address<'a, 'hir> { address: addr, kind: AddressKind::Dangling, name: None, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), } } @@ -349,11 +342,7 @@ impl Drop for Address<'_, '_> { return; } - #[cfg(debug_assertions)] rune_diagnose!("{self} was not freed:\nallocated at:\n{}", self.backtrace); - - #[cfg(not(debug_assertions))] - rune_diagnose!("{self} was not freed"); } } @@ -401,7 +390,6 @@ impl fmt::Debug for AnyKind<'_, '_> { pub(super) struct Any<'a, 'hir> { span: &'hir dyn Spanned, kind: AnyKind<'a, 'hir>, - #[cfg(debug_assertions)] backtrace: Backtrace, } @@ -412,7 +400,6 @@ impl<'a, 'hir> Any<'a, 'hir> { Self { span, kind: AnyKind::Ignore { name: None }, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), } } @@ -427,7 +414,6 @@ impl<'a, 'hir> Any<'a, 'hir> { scope, name: None, }, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), } } @@ -444,7 +430,6 @@ impl<'a, 'hir> Any<'a, 'hir> { kind: AnyKind::Address { address: Address::assigned(span, scopes, addr), }, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), } } @@ -481,7 +466,6 @@ impl<'a, 'hir> Any<'a, 'hir> { address: from, kind: AddressKind::Assigned, name: *name, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), }, }; @@ -510,7 +494,6 @@ impl<'a, 'hir> Any<'a, 'hir> { address: scopes.alloc_in(self.span, scope)?, kind: AddressKind::Scope(scope), name, - #[cfg(debug_assertions)] backtrace: Backtrace::capture(), }; @@ -628,10 +611,6 @@ impl Drop for Any<'_, '_> { return; } - #[cfg(debug_assertions)] rune_diagnose!("{self} was not freed:\nallocated at:\n{}", self.backtrace); - - #[cfg(not(debug_assertions))] - rune_diagnose!("{self} was not freed"); } } diff --git a/crates/rune/src/shared/mod.rs b/crates/rune/src/shared/mod.rs index 7f2ef1f0a..00f2fe8ae 100644 --- a/crates/rune/src/shared/mod.rs +++ b/crates/rune/src/shared/mod.rs @@ -10,52 +10,6 @@ pub(crate) use self::consts::Consts; pub(crate) use self::fixed_vec::{CapacityError, FixedVec}; pub(crate) use self::gen::Gen; -#[cfg(all(debug_assertions, not(feature = "std")))] -mod r#impl { - use core::fmt; - - macro_rules! _rune_diagnose { - ($($tt:tt)*) => { - tracing::trace!($($tt)*); - }; - } - - macro_rules! _rune_trace { - ($at:expr, $tok:expr) => {{ - _ = $at; - _ = $tok; - }}; - } - - pub(crate) struct Backtrace; - - impl Backtrace { - #[inline] - pub(crate) fn capture() -> Self { - Self - } - } - - impl fmt::Display for Backtrace { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "backtrace not available (missing feature `std`)") - } - } - - /// A macro for logging or panicking based on the current assertions model. - /// - /// The assertion model can be changed from logging to panicking by setting - /// the `RUNE_ASSERT=panic` environment. - #[doc(inline)] - pub(crate) use _rune_diagnose as rune_diagnose; - - /// A macro for tracing a specific call site. - /// - /// Tracing is enabled if `RUNE_ASSERT=trace` is set. - #[doc(inline)] - pub(crate) use _rune_trace as rune_trace; -} - /// Test whether current assertions model should panic. #[cfg(all(debug_assertions, feature = "std"))] mod r#impl { @@ -213,5 +167,55 @@ mod r#impl { pub(crate) use _rune_trace as rune_trace; } -#[cfg(debug_assertions)] +#[cfg(not(all(debug_assertions, feature = "std")))] +mod r#impl { + use core::fmt; + + macro_rules! _rune_diagnose { + ($($tt:tt)*) => { + tracing::trace!($($tt)*); + }; + } + + macro_rules! _rune_trace { + ($at:expr, $tok:expr) => {{ + _ = $at; + _ = $tok; + }}; + } + + pub(crate) struct Backtrace; + + impl Backtrace { + #[inline(always)] + pub(crate) fn capture() -> Self { + Self + } + } + + impl fmt::Display for Backtrace { + #[inline(always)] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "backtrace not available, missing cfg(all(debug_assertions, feature = \"std\"))" + ) + } + } + + /// A macro for logging or panicking based on the current assertions model. + /// + /// The assertion model can be changed from logging to panicking by setting + /// the `RUNE_ASSERT=panic` environment. + #[doc(inline)] + pub(crate) use _rune_diagnose as rune_diagnose; + + /// A macro for tracing a specific call site. + /// + /// Tracing is enabled if `RUNE_ASSERT=trace` is set. + #[doc(inline)] + #[cfg(feature = "fmt")] + pub(crate) use _rune_trace as rune_trace; +} + pub(crate) use self::r#impl::*;