diff --git a/.github/workflows/get-changed-examples-matrix.yml b/.github/workflows/get-changed-examples-matrix.yml index e8bea644d..cc675192e 100644 --- a/.github/workflows/get-changed-examples-matrix.yml +++ b/.github/workflows/get-changed-examples-matrix.yml @@ -1,5 +1,4 @@ name: Changed Examples Matrix Call - on: workflow_call: inputs: @@ -11,7 +10,6 @@ on: matrix: description: "Matrix" value: ${{ jobs.get-example-changed.outputs.matrix }} - jobs: get-example-changed: name: Get Changed Example Matrix @@ -23,7 +21,6 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Get example project directories that changed id: changed-dirs uses: tj-actions/changed-files@v45 @@ -38,17 +35,17 @@ jobs: !examples/*.md json: true quotepath: false - - name: List example project directories that changed run: echo '${{ steps.changed-dirs.outputs.all_changed_files }}' - - name: Set Matrix id: set-matrix run: | if [ ${{ inputs.example_changed }} == 'true' ]; then # Create matrix with changed directories - echo "matrix={\"directory\":${{ steps.changed-dirs.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT" + directories="${{ steps.changed-dirs.outputs.all_changed_files }}" else + directories="NO_CHANGE" # Create matrix with one item to prevent an empty vector error - echo "matrix={\"directory\":[\"NO_CHANGE\"], \"erased_mode\": [false, true]}" >> "$GITHUB_OUTPUT" fi + + echo "matrix={\"directory\":"$directories", \"erased_mode\": [false, true]}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/run-cargo-make-task.yml b/.github/workflows/run-cargo-make-task.yml index dabd1cdbb..9c54fe47d 100644 --- a/.github/workflows/run-cargo-make-task.yml +++ b/.github/workflows/run-cargo-make-task.yml @@ -7,7 +7,7 @@ on: type: string erased_mode: required: true - type: boolean + type: boolean cargo_make_task: required: true type: string @@ -19,6 +19,8 @@ env: CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse DEBIAN_FRONTEND: noninteractive RUSTFLAGS: ${{ inputs.erased_mode && '--cfg erase_components' || '' }} + LEPTOS_TAILWIND_VERSION: v4.0.14 + LEPTOS_SASS_VERSION: 1.86.0 jobs: test: name: "Run ${{ inputs.cargo_make_task }} (${{ inputs.toolchain }}) (erased_mode: ${{ inputs.erased_mode }})" @@ -30,11 +32,19 @@ jobs: df -h sudo rm -rf /usr/local/.ghcup sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo rm -rf /usr/local/lib/android/sdk/ndk + sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet sudo rm -rf /opt/ghc sudo rm -rf /usr/local/share/boost + sudo rm -rf /usr/local/lib/node_modules sudo apt-get clean + sudo apt-get purge -y '^ghc-.*' '^dotnet-.*' '^llvm-.*' '^mono-.*' '^php.*' '^ruby.*' + sudo apt-get autoremove -y + sudo apt-get clean + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + docker system prune -af + docker image prune -af + docker volume prune -f echo "Disk space after cleanup:" df -h # Setup environment @@ -125,8 +135,26 @@ jobs: sudo apt-get update sudo apt-get install -y libglib2.0-dev libgio2.0-cil-dev libgraphene-1.0-dev libcairo2-dev libpango1.0-dev libgtk-4-dev fi + - name: Enter ${{ inputs.directory }} + run: | + cd ${{ inputs.directory }} + - name: Install Tailwind and Sass dependencies + if: contains(inputs.directory, 'examples') + run: | + tailwindcss_version=$(echo "$LEPTOS_TAILWIND_VERSION" | sed 's/^v//') + sass_version="$LEPTOS_SASS_VERSION" + pnpm add "tailwindcss@$tailwindcss_version" "@tailwindcss/cli@$tailwindcss_version" "sass@$sass_version" + + echo "Tailwind CSS version:" + ./node_modules/.bin/tailwindcss --version + + echo "Sass version:" + ./node_modules/.bin/sass --version # Run Cargo Make Task - name: ${{ inputs.cargo_make_task }} run: | - cd ${{ inputs.directory }} cargo make --profile=github-actions ${{ inputs.cargo_make_task }} + - name: Clean up ${{ inputs.directory }} + run: | + cargo clean || true + rm -rf node_modules || true diff --git a/Cargo.lock b/Cargo.lock index 2e481770d..b8afb0e42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1796,6 +1796,7 @@ dependencies = [ "rand 0.8.5", "reactive_graph", "rustc-hash 2.1.1", + "rustc_version", "send_wrapper", "serde", "serde_json", @@ -1953,6 +1954,7 @@ dependencies = [ "proc-macro2", "quote", "rstml", + "rustc_version", "serde", "server_fn", "server_fn_macro 0.8.0-beta", @@ -1993,6 +1995,7 @@ dependencies = [ "or_poisoned", "percent-encoding", "reactive_graph", + "rustc_version", "send_wrapper", "tachys", "thiserror 2.0.12", @@ -2742,6 +2745,7 @@ dependencies = [ "or_poisoned", "pin-project-lite", "rustc-hash 2.1.1", + "rustc_version", "send_wrapper", "serde", "slotmap", @@ -3295,6 +3299,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", + "rustc_version", "syn 2.0.100", "xxhash-rust", ] @@ -3520,6 +3525,7 @@ dependencies = [ "reactive_graph", "reactive_stores", "rustc-hash 2.1.1", + "rustc_version", "send_wrapper", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index fc745e4c0..24873b482 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,6 +81,7 @@ opt-level = 'z' [workspace.metadata.cargo-all-features] skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]] +max_combination_size = 2 [workspace.lints.rust] unexpected_cfgs = { level = "warn", check-cfg = [ diff --git a/any_spawner/Cargo.toml b/any_spawner/Cargo.toml index fc2510755..212757fdb 100644 --- a/any_spawner/Cargo.toml +++ b/any_spawner/Cargo.toml @@ -34,3 +34,4 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 diff --git a/examples/ssr_modes/src/app.rs b/examples/ssr_modes/src/app.rs index 7b7253386..2b477a1b8 100644 --- a/examples/ssr_modes/src/app.rs +++ b/examples/ssr_modes/src/app.rs @@ -1,5 +1,3 @@ -use std::sync::LazyLock; - use leptos::prelude::*; use leptos_meta::*; use leptos_router::{ @@ -9,6 +7,7 @@ use leptos_router::{ ParamSegment, SsrMode, StaticSegment, }; use serde::{Deserialize, Serialize}; +use std::sync::LazyLock; use thiserror::Error; #[component] @@ -18,14 +17,14 @@ pub fn App() -> impl IntoView { let fallback = || view! { "Page not found." }.into_view(); view! { - - - <Meta name="color-scheme" content="dark light"/> + <Stylesheet id="leptos" href="/pkg/ssr_modes.css" /> + <Title text="Welcome to Leptos" /> + <Meta name="color-scheme" content="dark light" /> <Router> <main> <FlatRoutes fallback> // We’ll load the home page with out-of-order streaming and <Suspense/> - <Route path=StaticSegment("") view=HomePage/> + <Route path=StaticSegment("") view=HomePage /> // We'll load the posts with async rendering, so they can set // the title and metadata *after* loading the data @@ -115,8 +114,8 @@ fn Post() -> impl IntoView { // since we're using async rendering for this page, // this metadata should be included in the actual HTML <head> // when it's first served - <Title text=post.title/> - <Meta name="description" content=post.content/> + <Title text=post.title /> + <Meta name="description" content=post.content /> }), _ => Err(PostError::ServerError), } diff --git a/examples/ssr_modes/style/main.scss b/examples/ssr_modes/style/main.scss index a12f75925..a32638131 100644 --- a/examples/ssr_modes/style/main.scss +++ b/examples/ssr_modes/style/main.scss @@ -1,3 +1,3 @@ body { font-family: sans-serif; -} \ No newline at end of file +} diff --git a/integrations/actix/Cargo.toml b/integrations/actix/Cargo.toml index f125482f0..bbf7752eb 100644 --- a/integrations/actix/Cargo.toml +++ b/integrations/actix/Cargo.toml @@ -39,3 +39,4 @@ tracing = ["dep:tracing"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 diff --git a/integrations/axum/Cargo.toml b/integrations/axum/Cargo.toml index a21385a23..cfb5ce1c1 100644 --- a/integrations/axum/Cargo.toml +++ b/integrations/axum/Cargo.toml @@ -51,3 +51,4 @@ rustdoc-args = ["--generate-link-to-definition"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 diff --git a/leptos/Cargo.toml b/leptos/Cargo.toml index 70ddbf7ba..520c159ec 100644 --- a/leptos/Cargo.toml +++ b/leptos/Cargo.toml @@ -96,6 +96,9 @@ trace-component-props = [ ] delegation = ["tachys/delegation"] +[build-dependencies] +rustc_version = "0.4.1" + # Having an erasure feature rather than normal --cfg erase_components for the proc macro crate is a workaround for this rust issue: # https://github.com/rust-lang/cargo/issues/4423 # TLDR proc macros will ignore RUSTFLAGS when --target is specified on the cargo command. @@ -160,9 +163,13 @@ skip_feature_sets = [ "rustls", ], ] +max_combination_size = 2 [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(leptos_debuginfo)', + 'cfg(rustc_nightly)', +] } diff --git a/leptos/build.rs b/leptos/build.rs new file mode 100644 index 000000000..26023daae --- /dev/null +++ b/leptos/build.rs @@ -0,0 +1,8 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if matches!(version_meta().unwrap().channel, Channel::Nightly) { + println!("cargo:rustc-cfg=rustc_nightly"); + } +} diff --git a/leptos/src/lib.rs b/leptos/src/lib.rs index 11b9da377..3bf45d2fe 100644 --- a/leptos/src/lib.rs +++ b/leptos/src/lib.rs @@ -141,8 +141,8 @@ //! } //! ``` -#![cfg_attr(feature = "nightly", feature(fn_traits))] -#![cfg_attr(feature = "nightly", feature(unboxed_closures))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(fn_traits))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(unboxed_closures))] extern crate self as leptos; diff --git a/leptos_dom/Cargo.toml b/leptos_dom/Cargo.toml index 6a40f8ebb..3fec30dd7 100644 --- a/leptos_dom/Cargo.toml +++ b/leptos_dom/Cargo.toml @@ -37,6 +37,7 @@ rustdoc-args = ["--generate-link-to-definition"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } diff --git a/leptos_dom/examples/hydration-test/Cargo.toml b/leptos_dom/examples/hydration-test/Cargo.toml index 134f222d0..9bb957918 100644 --- a/leptos_dom/examples/hydration-test/Cargo.toml +++ b/leptos_dom/examples/hydration-test/Cargo.toml @@ -19,3 +19,6 @@ futures = "0.3.0" default = ["ssr"] ssr = ["leptos/ssr", "dep:actix-files", "dep:actix-web"] hydrate = ["leptos/hydrate", "dep:wasm-bindgen", "dep:gloo"] + +[package.metadata.cargo-all-features] +max_combination_size = 2 diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index b1e9fadde..748a06295 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -39,6 +39,9 @@ server_fn = { path = "../server_fn", features = ["cbor"] } insta = "1.41" serde = "1.0" +[build-dependencies] +rustc_version = "0.4.1" + [features] csr = [] hydrate = [] @@ -87,6 +90,10 @@ skip_feature_sets = [ "axum", ], ] +max_combination_size = 2 [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rustc_nightly)'] } diff --git a/leptos_macro/build.rs b/leptos_macro/build.rs new file mode 100644 index 000000000..26023daae --- /dev/null +++ b/leptos_macro/build.rs @@ -0,0 +1,8 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if matches!(version_meta().unwrap().channel, Channel::Nightly) { + println!("cargo:rustc-cfg=rustc_nightly"); + } +} diff --git a/leptos_macro/src/lib.rs b/leptos_macro/src/lib.rs index fa9c9eef8..dd95d22b6 100644 --- a/leptos_macro/src/lib.rs +++ b/leptos_macro/src/lib.rs @@ -1,6 +1,6 @@ //! Macros for use with the Leptos framework. -#![cfg_attr(feature = "nightly", feature(proc_macro_span))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(proc_macro_span))] #![forbid(unsafe_code)] // to prevent warnings from popping up when a nightly feature is stabilized #![allow(stable_features)] @@ -359,7 +359,7 @@ fn view_macro_impl(tokens: TokenStream, template: bool) -> TokenStream { fn normalized_call_site(site: proc_macro::Span) -> Option<String> { cfg_if::cfg_if! { - if #[cfg(all(debug_assertions, feature = "nightly"))] { + if #[cfg(all(debug_assertions, feature = "nightly", rustc_nightly))] { Some(leptos_hot_reload::span_to_stable_id( site.source_file().path(), site.start().line() diff --git a/leptos_macro/src/view/component_builder.rs b/leptos_macro/src/view/component_builder.rs index 9bfe7fc8e..dda88f5ae 100644 --- a/leptos_macro/src/view/component_builder.rs +++ b/leptos_macro/src/view/component_builder.rs @@ -327,9 +327,9 @@ fn is_attr_let(key: &NodeName) -> bool { } } -pub fn items_to_clone_to_tokens<'a>( - items_to_clone: &'a [Ident], -) -> impl Iterator<Item = TokenStream> + 'a { +pub fn items_to_clone_to_tokens( + items_to_clone: &[Ident], +) -> impl Iterator<Item = TokenStream> + '_ { items_to_clone.iter().map(|ident| { let ident_ref = quote_spanned!(ident.span()=> &#ident); quote! { let #ident = ::core::clone::Clone::clone(#ident_ref); } diff --git a/leptos_macro/src/view/mod.rs b/leptos_macro/src/view/mod.rs index b828a900d..7de0378c4 100644 --- a/leptos_macro/src/view/mod.rs +++ b/leptos_macro/src/view/mod.rs @@ -611,7 +611,7 @@ fn node_to_tokens( fn text_to_tokens(text: &LitStr) -> TokenStream { // on nightly, can use static string optimization - if cfg!(feature = "nightly") { + if cfg!(all(feature = "nightly", rustc_nightly)) { quote! { ::leptos::tachys::view::static_types::Static::<#text> } @@ -1512,7 +1512,7 @@ fn attribute_value( Some(value) => match &value.value { KVAttributeValue::Expr(expr) => { if let Expr::Lit(lit) = expr { - if cfg!(feature = "nightly") { + if cfg!(all(feature = "nightly", rustc_nightly)) { if let Lit::Str(str) = &lit.lit { return quote! { ::leptos::tachys::view::static_types::Static::<#str> diff --git a/leptos_server/Cargo.toml b/leptos_server/Cargo.toml index fabfb6ad8..644acfccc 100644 --- a/leptos_server/Cargo.toml +++ b/leptos_server/Cargo.toml @@ -43,6 +43,7 @@ tracing = ["dep:tracing"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] diff --git a/meta/Cargo.toml b/meta/Cargo.toml index 49db58fca..1519bec25 100644 --- a/meta/Cargo.toml +++ b/meta/Cargo.toml @@ -33,6 +33,7 @@ rustdoc-args = ["--generate-link-to-definition"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } diff --git a/reactive_graph/Cargo.toml b/reactive_graph/Cargo.toml index 106a7171d..b416285a5 100644 --- a/reactive_graph/Cargo.toml +++ b/reactive_graph/Cargo.toml @@ -32,6 +32,9 @@ tokio = { version = "1.43", features = ["rt-multi-thread", "macros"] } tokio-test = { version = "0.4.4" } any_spawner = { workspace = true, features = ["futures-executor", "tokio"] } +[build-dependencies] +rustc_version = "0.4.1" + [features] nightly = [] serde = ["dep:serde"] @@ -47,6 +50,10 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(leptos_debuginfo)', + 'cfg(rustc_nightly)', +] } diff --git a/reactive_graph/build.rs b/reactive_graph/build.rs new file mode 100644 index 000000000..26023daae --- /dev/null +++ b/reactive_graph/build.rs @@ -0,0 +1,8 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if matches!(version_meta().unwrap().channel, Channel::Nightly) { + println!("cargo:rustc-cfg=rustc_nightly"); + } +} diff --git a/reactive_graph/src/lib.rs b/reactive_graph/src/lib.rs index cf4f2cb74..c9de1fe17 100644 --- a/reactive_graph/src/lib.rs +++ b/reactive_graph/src/lib.rs @@ -68,8 +68,8 @@ //! [Reactively](https://github.com/modderme123/reactively), as described //! [in this article](https://dev.to/modderme123/super-charging-fine-grained-reactive-performance-47ph). -#![cfg_attr(feature = "nightly", feature(unboxed_closures))] -#![cfg_attr(feature = "nightly", feature(fn_traits))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(unboxed_closures))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(fn_traits))] #![deny(missing_docs)] use std::{fmt::Arguments, future::Future}; @@ -92,7 +92,7 @@ pub mod wrappers; use computed::ScopedFuture; -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] mod nightly; /// Reexports frequently-used traits. diff --git a/router/Cargo.toml b/router/Cargo.toml index 7ecdc4a7d..9ad048793 100644 --- a/router/Cargo.toml +++ b/router/Cargo.toml @@ -56,6 +56,9 @@ features = [ "Response", ] +[build-dependencies] +rustc_version = "0.4.1" + [features] tracing = ["dep:tracing"] ssr = ["dep:percent-encoding"] @@ -66,9 +69,11 @@ rustdoc-args = ["--generate-link-to-definition"] [package.metadata.cargo-all-features] denylist = ["tracing"] +max_combination_size = 2 [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = [ 'cfg(leptos_debuginfo)', 'cfg(erase_components)', + 'cfg(rustc_nightly)', ] } diff --git a/router/build.rs b/router/build.rs new file mode 100644 index 000000000..26023daae --- /dev/null +++ b/router/build.rs @@ -0,0 +1,8 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if matches!(version_meta().unwrap().channel, Channel::Nightly) { + println!("cargo:rustc-cfg=rustc_nightly"); + } +} diff --git a/router/src/lib.rs b/router/src/lib.rs index 6c7f59fd0..5160d15aa 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -121,8 +121,8 @@ #![forbid(unsafe_code)] #![deny(missing_docs)] -#![cfg_attr(feature = "nightly", feature(auto_traits))] -#![cfg_attr(feature = "nightly", feature(negative_impls))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(auto_traits))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(negative_impls))] /// Components for route definition and for enhanced links and forms. pub mod components; diff --git a/router/src/params.rs b/router/src/params.rs index 123a1220c..ccf27bbba 100644 --- a/router/src/params.rs +++ b/router/src/params.rs @@ -200,7 +200,7 @@ where } // TODO can we support Option<T> and T in a non-nightly way? -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] mod option_param { use super::{IntoParam, ParamsError}; use std::{str::FromStr, sync::Arc}; diff --git a/server_fn/Cargo.toml b/server_fn/Cargo.toml index 8140fc29e..5bdefd8d7 100644 --- a/server_fn/Cargo.toml +++ b/server_fn/Cargo.toml @@ -231,6 +231,7 @@ skip_feature_sets = [ "rkyv", ], ] +max_combination_size = 2 [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } diff --git a/server_fn/server_fn_macro_default/Cargo.toml b/server_fn/server_fn_macro_default/Cargo.toml index cfa559983..31fffe7b4 100644 --- a/server_fn/server_fn_macro_default/Cargo.toml +++ b/server_fn/server_fn_macro_default/Cargo.toml @@ -19,3 +19,6 @@ nightly = ["server_fn_macro/nightly"] ssr = ["server_fn_macro/ssr"] actix = ["server_fn_macro/actix"] axum = ["server_fn_macro/axum"] + +[package.metadata.cargo-all-features] +max_combination_size = 2 diff --git a/server_fn_macro/Cargo.toml b/server_fn_macro/Cargo.toml index 94a65b2ba..70f3766d1 100644 --- a/server_fn_macro/Cargo.toml +++ b/server_fn_macro/Cargo.toml @@ -16,6 +16,11 @@ xxhash-rust = { version = "0.8.12", features = ["const_xxh64"] } const_format = "0.2.33" convert_case = "0.6.0" + +[build-dependencies] +rustc_version = "0.4.1" + + [features] nightly = [] ssr = [] @@ -26,3 +31,9 @@ reqwest = [] [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] + +[package.metadata.cargo-all-features] +max_combination_size = 2 + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rustc_nightly)'] } diff --git a/server_fn_macro/build.rs b/server_fn_macro/build.rs new file mode 100644 index 000000000..26023daae --- /dev/null +++ b/server_fn_macro/build.rs @@ -0,0 +1,8 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if matches!(version_meta().unwrap().channel, Channel::Nightly) { + println!("cargo:rustc-cfg=rustc_nightly"); + } +} diff --git a/server_fn_macro/src/lib.rs b/server_fn_macro/src/lib.rs index 19ad173f0..7acd40e1d 100644 --- a/server_fn_macro/src/lib.rs +++ b/server_fn_macro/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(feature = "nightly", feature(proc_macro_span))] +#![cfg_attr(all(feature = "nightly", rustc_nightly), feature(proc_macro_span))] #![forbid(unsafe_code)] #![deny(missing_docs)] diff --git a/tachys/Cargo.toml b/tachys/Cargo.toml index 20510c864..d0477b492 100644 --- a/tachys/Cargo.toml +++ b/tachys/Cargo.toml @@ -169,6 +169,9 @@ serde_json = { version = "1", optional = true } tokio-test = "0.4.4" tokio = { version = "1.43", features = ["rt", "macros"] } +[build-dependencies] +rustc_version = "0.4.1" + [features] default = ["testing"] delegation = [] # enables event delegation @@ -200,9 +203,11 @@ skip_feature_sets = [ "delegation", ], ] +max_combination_size = 2 [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = [ 'cfg(leptos_debuginfo)', 'cfg(erase_components)', + 'cfg(rustc_nightly)', ] } diff --git a/tachys/build.rs b/tachys/build.rs new file mode 100644 index 000000000..26023daae --- /dev/null +++ b/tachys/build.rs @@ -0,0 +1,8 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if matches!(version_meta().unwrap().channel, Channel::Nightly) { + println!("cargo:rustc-cfg=rustc_nightly"); + } +} diff --git a/tachys/src/html/attribute/custom.rs b/tachys/src/html/attribute/custom.rs index e34460adc..717006fdf 100644 --- a/tachys/src/html/attribute/custom.rs +++ b/tachys/src/html/attribute/custom.rs @@ -170,7 +170,7 @@ impl CustomAttributeKey for Arc<str> { const KEY: &'static str = ""; } -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] impl<const K: &'static str> CustomAttributeKey for crate::view::static_types::Static<K> { diff --git a/tachys/src/html/attribute/value.rs b/tachys/src/html/attribute/value.rs index 347ef6b47..5c4a40356 100644 --- a/tachys/src/html/attribute/value.rs +++ b/tachys/src/html/attribute/value.rs @@ -202,7 +202,7 @@ impl<'a> AttributeValue for &'a str { } } -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] impl<const V: &'static str> AttributeValue for crate::view::static_types::Static<V> { diff --git a/tachys/src/html/class.rs b/tachys/src/html/class.rs index 7a9afda09..ad47b746f 100644 --- a/tachys/src/html/class.rs +++ b/tachys/src/html/class.rs @@ -571,7 +571,7 @@ impl IntoClass for (&'static str, bool) { } } -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] impl<const V: &'static str> IntoClass for crate::view::static_types::Static<V> { const TEMPLATE: &'static str = V; diff --git a/tachys/src/html/element/mod.rs b/tachys/src/html/element/mod.rs index f34546415..202b91fb1 100644 --- a/tachys/src/html/element/mod.rs +++ b/tachys/src/html/element/mod.rs @@ -745,7 +745,7 @@ where /* #[cfg(all(test, feature = "testing"))] mod tests { - #[cfg(feature = "nightly")] + #[cfg(all(feature = "nightly", rustc_nightly))] use super::RenderHtml; use super::{main, p, HtmlElement}; use crate::{ @@ -782,7 +782,7 @@ mod tests { ); } - #[cfg(feature = "nightly")] + #[cfg(all(feature = "nightly", rustc_nightly))] #[test] fn html_render_allocates_appropriate_buffer() { use crate::view::static_types::Static; diff --git a/tachys/src/html/style.rs b/tachys/src/html/style.rs index 118f3b3e8..20a172d2b 100644 --- a/tachys/src/html/style.rs +++ b/tachys/src/html/style.rs @@ -2,7 +2,7 @@ use super::attribute::{ maybe_next_attr_erasure_macros::next_attr_output_type, Attribute, NextAttribute, }; -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] use crate::view::static_types::Static; use crate::{ html::attribute::maybe_next_attr_erasure_macros::next_attr_combine, @@ -661,7 +661,7 @@ impl_style_value!(String); #[cfg(feature = "oco")] impl_style_value!(oco_ref::Oco<'static, str>); -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] impl<const V: &'static str> IntoStyleValue for Static<V> { type AsyncOutput = Self; type State = Self; @@ -707,7 +707,7 @@ impl<const V: &'static str> IntoStyleValue for Static<V> { } } -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] impl<const V: &'static str> IntoStyleValue for Option<Static<V>> { type AsyncOutput = Self; type State = Self; @@ -764,7 +764,7 @@ impl<const V: &'static str> IntoStyleValue for Option<Static<V>> { } } -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] impl<const V: &'static str> IntoStyle for crate::view::static_types::Static<V> { type AsyncOutput = Self; type State = (); diff --git a/tachys/src/lib.rs b/tachys/src/lib.rs index 21cd9b21c..00aa1e02c 100644 --- a/tachys/src/lib.rs +++ b/tachys/src/lib.rs @@ -6,7 +6,10 @@ // this is specifically used for `unsized_const_params` below // this allows us to use const generic &'static str for static text nodes and attributes #![allow(incomplete_features)] -#![cfg_attr(feature = "nightly", feature(unsized_const_params))] +#![cfg_attr( + all(feature = "nightly", rustc_nightly), + feature(unsized_const_params) +)] #![deny(missing_docs)] /// Commonly-used traits. diff --git a/tachys/src/view/mod.rs b/tachys/src/view/mod.rs index ddd3cf656..8006d2228 100644 --- a/tachys/src/view/mod.rs +++ b/tachys/src/view/mod.rs @@ -22,7 +22,7 @@ pub mod iterators; pub mod keyed; mod primitives; /// Optimized types for static strings known at compile time. -#[cfg(feature = "nightly")] +#[cfg(all(feature = "nightly", rustc_nightly))] pub mod static_types; /// View implementation for string types. pub mod strings;