diff --git a/.woodpecker/build_egui.yaml b/.woodpecker/build_egui.yaml index 79478ee..3c28a2b 100644 --- a/.woodpecker/build_egui.yaml +++ b/.woodpecker/build_egui.yaml @@ -1,10 +1,14 @@ matrix: - RUST: [stable, nightly] + include: + - CHANNEL: stable + FEATURES: egui,disable_contracts + - CHANNEL: nightly + FEATURES: egui steps: build_egui: image: rust environment: [CARGO_TERM_COLOR=always] commands: - - rustup default $RUST - - cargo build --features "egui" --bin "topola-egui" + - rustup default "$CHANNEL" + - cargo build --features "$FEATURES" --bin "topola-egui" diff --git a/.woodpecker/build_sdl2.yaml b/.woodpecker/build_sdl2.yaml index dfbdd5a..f3f782a 100644 --- a/.woodpecker/build_sdl2.yaml +++ b/.woodpecker/build_sdl2.yaml @@ -1,5 +1,9 @@ matrix: - RUST: [stable, nightly] + include: + - CHANNEL: stable + FEATURES: sdl2,disable_contracts + - CHANNEL: nightly + FEATURES: sdl2 steps: build_sdl2: @@ -8,5 +12,5 @@ steps: commands: - apt-get update - apt-get -y install cmake - - rustup default $RUST - - cargo build --features "sdl2" --bin "topola-sdl2-demo" + - rustup default "$CHANNEL" + - cargo build --features "$FEATURES" --bin "topola-sdl2-demo" diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index 9c4053f..ecfceb7 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -1,11 +1,15 @@ matrix: - RUST: [stable, nightly] + include: + - CHANNEL: stable + FEATURES: disable_contracts + - CHANNEL: nightly + FEATURES: steps: test: image: rust environment: [CARGO_TERM_COLOR=always] commands: - - rustup default $RUST + - rustup default "$CHANNEL" - cargo check - - cargo test + - cargo test --features "$FEATURES" diff --git a/Cargo.toml b/Cargo.toml index a9793bc..83cc0dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ required-features = ["sdl2"] [features] egui = ["dep:eframe", "dep:egui", "dep:rfd", "dep:futures"] sdl2 = ["dep:sdl2", "dep:gl", "dep:pathfinder_canvas", "dep:pathfinder_geometry", "dep:pathfinder_gl", "dep:pathfinder_renderer", "dep:pathfinder_resources"] +disable_contracts = ["contracts/disable_contracts"] [dependencies] thiserror = "1.0.56" diff --git a/src/lib.rs b/src/lib.rs index 78a76fe..fc75618a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(try_blocks)] +#![cfg_attr(not(feature = "disable_contracts"), feature(try_blocks))] pub mod graph; #[macro_use] diff --git a/vendored/contracts/Cargo.toml b/vendored/contracts/Cargo.toml index 18970c0..e23db15 100644 --- a/vendored/contracts/Cargo.toml +++ b/vendored/contracts/Cargo.toml @@ -38,4 +38,3 @@ mirai_assertions = [] syn = { version = "1.0", features = ["extra-traits", "full", "visit", "visit-mut"] } quote = "1.0" proc-macro2 = "1.0" -rustc_version = "0.4" diff --git a/vendored/contracts/src/lib.rs b/vendored/contracts/src/lib.rs index 42d3ebf..a4c0348 100644 --- a/vendored/contracts/src/lib.rs +++ b/vendored/contracts/src/lib.rs @@ -180,8 +180,6 @@ extern crate proc_macro; mod implementation; -use rustc_version::{version, version_meta, Channel, Version}; - use implementation::ContractMode; use proc_macro::TokenStream; @@ -199,7 +197,7 @@ use proc_macro::TokenStream; /// ``` #[proc_macro_attribute] pub fn requires(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -213,7 +211,7 @@ pub fn requires(attr: TokenStream, toks: TokenStream) -> TokenStream { /// [`requires`]: attr.requires.html #[proc_macro_attribute] pub fn debug_requires(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -227,7 +225,7 @@ pub fn debug_requires(attr: TokenStream, toks: TokenStream) -> TokenStream { /// [`requires`]: attr.requires.html #[proc_macro_attribute] pub fn test_requires(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -266,7 +264,7 @@ pub fn test_requires(attr: TokenStream, toks: TokenStream) -> TokenStream { /// ``` #[proc_macro_attribute] pub fn ensures(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -280,7 +278,7 @@ pub fn ensures(attr: TokenStream, toks: TokenStream) -> TokenStream { /// [`ensures`]: attr.ensures.html #[proc_macro_attribute] pub fn debug_ensures(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -294,7 +292,7 @@ pub fn debug_ensures(attr: TokenStream, toks: TokenStream) -> TokenStream { /// [`ensures`]: attr.ensures.html #[proc_macro_attribute] pub fn test_ensures(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -346,7 +344,7 @@ pub fn test_ensures(attr: TokenStream, toks: TokenStream) -> TokenStream { /// ``` #[proc_macro_attribute] pub fn invariant(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -367,7 +365,7 @@ pub fn invariant(attr: TokenStream, toks: TokenStream) -> TokenStream { /// [`invariant`]: attr.invariant.html #[proc_macro_attribute] pub fn debug_invariant(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -382,7 +380,7 @@ pub fn debug_invariant(attr: TokenStream, toks: TokenStream) -> TokenStream { /// [`invariant`]: attr.invariant.html #[proc_macro_attribute] pub fn test_invariant(attr: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; } @@ -427,7 +425,7 @@ pub fn test_invariant(attr: TokenStream, toks: TokenStream) -> TokenStream { /// ``` #[proc_macro_attribute] pub fn contract_trait(attrs: TokenStream, toks: TokenStream) -> TokenStream { - if let Channel::Nightly = version_meta().unwrap().channel { + if cfg!(feature = "disable_contracts") { return toks; }