From d9983969c45a7429a0a35172c20172bc4185e872 Mon Sep 17 00:00:00 2001 From: Ross Porter Date: Fri, 25 Jul 2025 16:41:32 +1200 Subject: [PATCH 1/3] Update test harness trybuild didn't like being run as an msp43-none-elf target, so we have to run the test with --target x86 to overrule the .cargo/config rule, then in the test harness set environment flags back to targetting the msp430, so when trybuild compiles the examples they're successfully built as msp430 binaries. --- .github/workflows/test-macro.yml | 4 ++-- macros/tests/compiletest.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-macro.yml b/.github/workflows/test-macro.yml index f789559..1cfed40 100644 --- a/.github/workflows/test-macro.yml +++ b/.github/workflows/test-macro.yml @@ -16,10 +16,10 @@ jobs: with: profile: minimal toolchain: nightly - override: true + component: rust-src - name: Test macro library uses: actions-rs/cargo@v1 with: command: test - args: -p msp430-rt-macros --features device + args: -Zbuild-std -p msp430-rt-macros --target=x86_64-unknown-linux-gnu --features device diff --git a/macros/tests/compiletest.rs b/macros/tests/compiletest.rs index 870c2f9..43c3f4a 100644 --- a/macros/tests/compiletest.rs +++ b/macros/tests/compiletest.rs @@ -1,5 +1,8 @@ #[test] fn ui() { + std::env::set_var("CARGO_BUILD_TARGET", "msp430-none-elf"); + std::env::set_var("CARGO_UNSTABLE_BUILD_STD", "std"); + let t = trybuild::TestCases::new(); t.compile_fail("tests/ui/*.rs"); } From d503be1510d0a179fa26b1b81762e4cbefc2456d Mon Sep 17 00:00:00 2001 From: Ross Porter Date: Fri, 25 Jul 2025 16:58:28 +1200 Subject: [PATCH 2/3] Bless new error outputs --- .../ui/entry_preinterrupt_mismatch.stderr | 10 +++++++ .../tests/ui/entry_preinterrupt_no_arg.stderr | 6 +---- .../ui/entry_preinterrupt_return_cs.stderr | 5 ++-- .../ui/entry_preinterrupt_return_cs2.stderr | 5 ++-- .../ui/entry_preinterrupt_return_cs3.stderr | 5 ++-- ...entry_preinterrupt_return_cs_cloned.stderr | 5 ++-- ...reinterrupt_return_cs_cloned_static.stderr | 4 +-- ...entry_preinterrupt_return_cs_static.stderr | 4 +-- macros/tests/ui/interrupt_args.stderr | 2 +- macros/tests/ui/interrupt_wrong_import.stderr | 15 ++++++----- macros/tests/ui/recursion.stderr | 26 +++++++++---------- macros/tests/ui/recursion2.stderr | 26 +++++++++---------- 12 files changed, 58 insertions(+), 55 deletions(-) diff --git a/macros/tests/ui/entry_preinterrupt_mismatch.stderr b/macros/tests/ui/entry_preinterrupt_mismatch.stderr index 6329a6e..4362877 100644 --- a/macros/tests/ui/entry_preinterrupt_mismatch.stderr +++ b/macros/tests/ui/entry_preinterrupt_mismatch.stderr @@ -12,4 +12,14 @@ note: function defined here | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +11 | fn main(_i: bool) -> ! { + | -------- = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: unused variable: `cs` + --> tests/ui/entry_preinterrupt_mismatch.rs:6:9 + | +6 | fn init(cs: CriticalSection) -> u32 { + | ^^ help: if this is intentional, prefix it with an underscore: `_cs` + | + = note: `#[warn(unused_variables)]` on by default diff --git a/macros/tests/ui/entry_preinterrupt_no_arg.stderr b/macros/tests/ui/entry_preinterrupt_no_arg.stderr index dd26b39..0d8e68e 100644 --- a/macros/tests/ui/entry_preinterrupt_no_arg.stderr +++ b/macros/tests/ui/entry_preinterrupt_no_arg.stderr @@ -2,14 +2,10 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> tests/ui/entry_preinterrupt_no_arg.rs:7:42 | 7 | #[entry(interrupt_enable(pre_interrupt = init))] - | -----------------------------------------^^^^--- argument of type `CriticalSection<'_>` unexpected + | -----------------------------------------^^^^--- unexpected argument of type `CriticalSection<'_>` | note: function defined here --> tests/ui/entry_preinterrupt_no_arg.rs:5:4 | 5 | fn init() {} | ^^^^ -help: remove the extra argument - | -7 | init() - | diff --git a/macros/tests/ui/entry_preinterrupt_return_cs.stderr b/macros/tests/ui/entry_preinterrupt_return_cs.stderr index 19ea93e..cc74c6b 100644 --- a/macros/tests/ui/entry_preinterrupt_return_cs.stderr +++ b/macros/tests/ui/entry_preinterrupt_return_cs.stderr @@ -1,11 +1,10 @@ -error[E0597]: `cs` does not live long enough +error[E0597]: value does not live long enough --> tests/ui/entry_preinterrupt_return_cs.rs:10:1 | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | - | | `cs` dropped here while still borrowed + | | value dropped here while still borrowed | borrowed value does not live long enough - | borrow later stored here | = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/macros/tests/ui/entry_preinterrupt_return_cs2.stderr b/macros/tests/ui/entry_preinterrupt_return_cs2.stderr index 4d0cecf..ffe9f96 100644 --- a/macros/tests/ui/entry_preinterrupt_return_cs2.stderr +++ b/macros/tests/ui/entry_preinterrupt_return_cs2.stderr @@ -1,11 +1,10 @@ -error[E0597]: `cs` does not live long enough +error[E0597]: value does not live long enough --> tests/ui/entry_preinterrupt_return_cs2.rs:10:1 | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | - | | `cs` dropped here while still borrowed + | | value dropped here while still borrowed | borrowed value does not live long enough - | borrow later stored here | = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/macros/tests/ui/entry_preinterrupt_return_cs3.stderr b/macros/tests/ui/entry_preinterrupt_return_cs3.stderr index 1bb59bd..504f357 100644 --- a/macros/tests/ui/entry_preinterrupt_return_cs3.stderr +++ b/macros/tests/ui/entry_preinterrupt_return_cs3.stderr @@ -1,11 +1,10 @@ -error[E0597]: `cs` does not live long enough +error[E0597]: value does not live long enough --> tests/ui/entry_preinterrupt_return_cs3.rs:10:1 | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | - | | `cs` dropped here while still borrowed + | | value dropped here while still borrowed | borrowed value does not live long enough - | borrow later stored here | = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/macros/tests/ui/entry_preinterrupt_return_cs_cloned.stderr b/macros/tests/ui/entry_preinterrupt_return_cs_cloned.stderr index 62c552f..e7ed7ec 100644 --- a/macros/tests/ui/entry_preinterrupt_return_cs_cloned.stderr +++ b/macros/tests/ui/entry_preinterrupt_return_cs_cloned.stderr @@ -1,11 +1,10 @@ -error[E0597]: `cs` does not live long enough +error[E0597]: value does not live long enough --> tests/ui/entry_preinterrupt_return_cs_cloned.rs:10:1 | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | - | | `cs` dropped here while still borrowed + | | value dropped here while still borrowed | borrowed value does not live long enough - | borrow later stored here | = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/macros/tests/ui/entry_preinterrupt_return_cs_cloned_static.stderr b/macros/tests/ui/entry_preinterrupt_return_cs_cloned_static.stderr index 808fa89..9e9079f 100644 --- a/macros/tests/ui/entry_preinterrupt_return_cs_cloned_static.stderr +++ b/macros/tests/ui/entry_preinterrupt_return_cs_cloned_static.stderr @@ -1,10 +1,10 @@ -error[E0597]: `cs` does not live long enough +error[E0597]: value does not live long enough --> tests/ui/entry_preinterrupt_return_cs_cloned_static.rs:10:1 | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | - | | `cs` dropped here while still borrowed + | | value dropped here while still borrowed | borrowed value does not live long enough | argument requires that `cs` is borrowed for `'static` | diff --git a/macros/tests/ui/entry_preinterrupt_return_cs_static.stderr b/macros/tests/ui/entry_preinterrupt_return_cs_static.stderr index e190bcc..a673d9c 100644 --- a/macros/tests/ui/entry_preinterrupt_return_cs_static.stderr +++ b/macros/tests/ui/entry_preinterrupt_return_cs_static.stderr @@ -1,10 +1,10 @@ -error[E0597]: `cs` does not live long enough +error[E0597]: value does not live long enough --> tests/ui/entry_preinterrupt_return_cs_static.rs:10:1 | 10 | #[entry(interrupt_enable(pre_interrupt = init))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | - | | `cs` dropped here while still borrowed + | | value dropped here while still borrowed | borrowed value does not live long enough | argument requires that `cs` is borrowed for `'static` | diff --git a/macros/tests/ui/interrupt_args.stderr b/macros/tests/ui/interrupt_args.stderr index 9a9e2d0..d8ff03a 100644 --- a/macros/tests/ui/interrupt_args.stderr +++ b/macros/tests/ui/interrupt_args.stderr @@ -1,4 +1,4 @@ -error: this attribute accepts no arguments +error: this attribute accepts only 'wake_cpu' as an argument --> tests/ui/interrupt_args.rs:10:1 | 10 | #[interrupt(arg)] diff --git a/macros/tests/ui/interrupt_wrong_import.stderr b/macros/tests/ui/interrupt_wrong_import.stderr index 8543320..6ede4df 100644 --- a/macros/tests/ui/interrupt_wrong_import.stderr +++ b/macros/tests/ui/interrupt_wrong_import.stderr @@ -1,25 +1,26 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `interrupt` +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> tests/ui/interrupt_wrong_import.rs:11:1 | 11 | #[interrupt] - | ^^^^^^^^^^^^ use of undeclared crate or module `interrupt` + | ^^^^^^^^^^^^ | + = note: see issue #38487 for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target --> tests/ui/interrupt_wrong_import.rs:11:1 | 11 | #[interrupt] | ^^^^^^^^^^^^ | - = note: see issue #38487 for more information - = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `interrupt` --> tests/ui/interrupt_wrong_import.rs:11:1 | 11 | #[interrupt] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `interrupt` | + = help: if you wanted to use a crate named `interrupt`, use `cargo add interrupt` to add it to your `Cargo.toml` = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/macros/tests/ui/recursion.stderr b/macros/tests/ui/recursion.stderr index 4f75575..f8e0ff4 100644 --- a/macros/tests/ui/recursion.stderr +++ b/macros/tests/ui/recursion.stderr @@ -1,16 +1,4 @@ -error[E0425]: cannot find function `main` in this scope - --> tests/ui/recursion.rs:7:5 - | -7 | main(cs) - | ^^^^ not found in this scope - -error[E0425]: cannot find function, tuple struct or tuple variant `DefaultHandler` in this scope - --> tests/ui/recursion.rs:12:5 - | -12 | DefaultHandler(cs) - | ^^^^^^^^^^^^^^ not found in this scope - -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> tests/ui/recursion.rs:10:1 | 10 | #[interrupt] @@ -20,6 +8,12 @@ error[E0658]: msp430-interrupt ABI is experimental and subject to change = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0425]: cannot find function `main` in this scope + --> tests/ui/recursion.rs:7:5 + | +7 | main(cs) + | ^^^^ not found in this scope + error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target --> tests/ui/recursion.rs:10:1 | @@ -27,3 +21,9 @@ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target | ^^^^^^^^^^^^ | = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0425]: cannot find function, tuple struct or tuple variant `DefaultHandler` in this scope + --> tests/ui/recursion.rs:12:5 + | +12 | DefaultHandler(cs) + | ^^^^^^^^^^^^^^ not found in this scope diff --git a/macros/tests/ui/recursion2.stderr b/macros/tests/ui/recursion2.stderr index a8722b0..c24cdba 100644 --- a/macros/tests/ui/recursion2.stderr +++ b/macros/tests/ui/recursion2.stderr @@ -1,16 +1,4 @@ -error[E0425]: cannot find function `main` in this scope - --> tests/ui/recursion2.rs:7:5 - | -7 | main() - | ^^^^ not found in this scope - -error[E0425]: cannot find function, tuple struct or tuple variant `DefaultHandler` in this scope - --> tests/ui/recursion2.rs:12:5 - | -12 | DefaultHandler() - | ^^^^^^^^^^^^^^ not found in this scope - -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> tests/ui/recursion2.rs:10:1 | 10 | #[interrupt] @@ -20,6 +8,12 @@ error[E0658]: msp430-interrupt ABI is experimental and subject to change = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0425]: cannot find function `main` in this scope + --> tests/ui/recursion2.rs:7:5 + | +7 | main() + | ^^^^ not found in this scope + error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target --> tests/ui/recursion2.rs:10:1 | @@ -27,3 +21,9 @@ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target | ^^^^^^^^^^^^ | = note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0425]: cannot find function, tuple struct or tuple variant `DefaultHandler` in this scope + --> tests/ui/recursion2.rs:12:5 + | +12 | DefaultHandler() + | ^^^^^^^^^^^^^^ not found in this scope From b2fb8ffa1a82825b2284733df6d547129d4acce3 Mon Sep 17 00:00:00 2001 From: Ross Porter Date: Sat, 26 Jul 2025 09:49:00 +1200 Subject: [PATCH 3/3] Update runner version --- .github/workflows/test-macro.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-macro.yml b/.github/workflows/test-macro.yml index 1cfed40..274afde 100644 --- a/.github/workflows/test-macro.yml +++ b/.github/workflows/test-macro.yml @@ -5,7 +5,7 @@ name: Run Macro Tests jobs: testing: name: testing - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout sources