Skip to content
Merged
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
8 changes: 5 additions & 3 deletions .github/workflows/deploy-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ on:

env:
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1

jobs:
quality-check:
uses: ./.github/workflows/rust.yml
permissions:
contents: read
issues: write
uses: ./.github/workflows/rust-stability.yml

publish:
environment: crates.io
Expand All @@ -23,4 +25,4 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run:
cargo publish
cargo +nightly publish
17 changes: 7 additions & 10 deletions .github/workflows/rust-stability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Monthly stability checks

on:
workflow_dispatch:
workflow_call:
pull_request:
schedule:
- cron: '0 3 6 * *'
Expand All @@ -15,7 +16,6 @@ env:
RUSTC_BOOTSTRAP: 1

jobs:


test:
strategy:
Expand All @@ -25,11 +25,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.channel }}
- name: update rust
run: rustup update
Comment thread
MusicalNinjaDad marked this conversation as resolved.
- name: Run tests
run: cargo test --no-fail-fast
run: cargo +${{ matrix.channel }} test --no-fail-fast

lint:
strategy:
Expand All @@ -39,12 +38,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.channel }}
components: "clippy"
- name: update rust
run: rustup update && rustup component add --toolchain ${{ matrix.channel }} clippy
- name: clippy
run: cargo clippy -- --deny warnings
run: cargo +${{ matrix.channel }} clippy -- --deny warnings

report:
if: ${{ always() }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
- uses: actions/checkout@v6
- name: clippy
run: cargo clippy -- --deny warnings
- name: clippy the tests
run: cargo clippy --tests -- --deny warnings

fmt:
needs: skip_check
Expand Down
55 changes: 53 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
extern crate autocfg;
use autocfg::AutoCfg;

fn main() {
let ac = autocfg::new();
ac.emit_path_cfg("std::assert_matches", "stable_assert_matches");
stable_feature(&ac, "assert_matches");
assert_matches_in_module(&ac);
assert_matches_in_root(&ac);
}

fn stable_feature(ac: &AutoCfg, feature: &'static str) {
let cfg = format!("stable_{feature}");
let code = format!(
r#"
#![deny(stable_features)]
#![feature({feature})]
"#
);

autocfg::emit_possibility(&cfg);
if ac.probe_raw(&code).is_err() {
autocfg::emit(&cfg);
}
}

fn assert_matches_in_root(ac: &AutoCfg) {
let cfg = "assert_matches_in_root";
let code = r#"
#![allow(stable_features)]
#![feature(assert_matches)]
use std::assert_matches;

fn main() {
assert_matches!(Some(4), Some(_));
}
"#;
autocfg::emit_possibility(cfg);
if ac.probe_raw(code).is_ok() {
autocfg::emit(cfg);
}
}

fn assert_matches_in_module(ac: &AutoCfg) {
let cfg = "assert_matches_in_module";
let code = r#"
#![allow(stable_features)]
#![feature(assert_matches)]
use std::assert_matches::assert_matches;

fn main() {
assert_matches!(Some(4), Some(_));
}
"#;
autocfg::emit_possibility(cfg);
if ac.probe_raw(code).is_ok() {
autocfg::emit(cfg);
}
}
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,10 @@ impl From<DiagnosticStream> for TokenStream1 {

#[cfg(test)]
mod tests {
#[cfg(not(stable_assert_matches))]
#[cfg(assert_matches_in_module)]
use std::assert_matches::assert_matches;

#[cfg(stable_assert_matches)]
#[cfg(assert_matches_in_root)]
use std::assert_matches;

use super::*;
Expand Down
Loading