Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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
55 changes: 54 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
use autocfg::AutoCfg;

extern crate 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