Repository navigation
rt: migrate compile-fail tests to trybuild. #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dirbaio
wants to merge
1
commit into
rust-embedded:main
Choose a base branch
from
Dirbaio:trybuild
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,19 @@ | ||
| # How to run | ||
|
|
||
| To run the compile tests, use the following command on the root of the project: | ||
| The compile-fail tests use [trybuild](https://docs.rs/trybuild). To run them, use the following | ||
| command on the root of the project: | ||
|
|
||
| ``` | ||
| cargo test --package cortex-m-rt --test compiletest --features device | ||
| cargo test --package cortex-m-rt --test compile_fail --features device | ||
| ``` | ||
|
|
||
| Each `tests/compile-fail/*.rs` file must fail to compile with exactly the diagnostics in the | ||
| `.stderr` file next to it. After adding a test or intentionally changing a diagnostic, regenerate | ||
| the `.stderr` files with: | ||
|
|
||
| ``` | ||
| TRYBUILD=overwrite cargo test --package cortex-m-rt --test compile_fail --features device | ||
| ``` | ||
|
|
||
| and review the result before committing. The expected output is tied to the current stable | ||
| compiler, so new Rust releases may require regenerating it. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
cortex-m-rt/tests/compile-fail/default-handler-bad-signature-1.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `DefaultHandler` must have signature `unsafe fn(i16) [-> !]` | ||
| --> tests/compile-fail/default-handler-bad-signature-1.rs:15:1 | ||
| | | ||
| 15 | unsafe fn DefaultHandler(_irqn: i16, undef: u32) {} | ||
| | ^^^^^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
cortex-m-rt/tests/compile-fail/default-handler-bad-signature-2.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `DefaultHandler` must have signature `unsafe fn(i16) [-> !]` | ||
| --> tests/compile-fail/default-handler-bad-signature-2.rs:15:1 | ||
| | | ||
| 15 | unsafe fn DefaultHandler(_irqn: i16) -> u32 { | ||
| | ^^^^^^ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| error: symbol `DefaultHandler` is already defined | ||
| --> tests/compile-fail/default-handler-twice.rs:20:5 | ||
| | | ||
| 20 | #[exception] | ||
| | ^^^^^^^^^^^^ | ||
| | | ||
| = note: this error originates in the attribute macro `exception` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| error: the name `X` is defined multiple times | ||
| --> tests/compile-fail/duplicate-static.rs:17:16 | ||
| | | ||
| 17 | static mut X: i32 = 0; | ||
| | ^ | ||
|
|
||
| error: the name `X` is defined multiple times | ||
| --> tests/compile-fail/duplicate-static.rs:25:16 | ||
| | | ||
| 25 | static mut X: i32 = 0; | ||
| | ^ | ||
|
|
||
| error: the name `X` is defined multiple times | ||
| --> tests/compile-fail/duplicate-static.rs:31:16 | ||
| | | ||
| 31 | static mut X: i32 = 0; | ||
| | ^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| error: This attribute accepts no arguments | ||
| --> tests/compile-fail/entry-args.rs:9:1 | ||
| | | ||
| 9 | #[entry(foo)] | ||
| | ^^^^^^^^^^^^^ | ||
| | | ||
| = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `#[entry]` function must have signature `[unsafe] fn() -> !` | ||
| --> tests/compile-fail/entry-bad-signature-1.rs:10:1 | ||
| | | ||
| 10 | fn foo() {} | ||
| | ^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `#[entry]` function must have signature `[unsafe] fn() -> !` | ||
| --> tests/compile-fail/entry-bad-signature-2.rs:10:1 | ||
| | | ||
| 10 | fn foo(undef: i32) -> ! {} | ||
| | ^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `#[entry]` function must have signature `[unsafe] fn() -> !` | ||
| --> tests/compile-fail/entry-bad-signature-3.rs:10:1 | ||
| | | ||
| 10 | extern "C" fn foo() -> ! { | ||
| | ^^^^^^ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error[E0425]: cannot find function `foo` in this scope | ||
| --> tests/compile-fail/entry-soundness.rs:25:5 | ||
| | | ||
| 25 | foo(); | ||
| | ^^^ not found in this scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| error: symbol `main` is already defined | ||
| --> tests/compile-fail/entry-twice.rs:14:1 | ||
| | | ||
| 14 | #[entry] | ||
| | ^^^^^^^^ | ||
| | | ||
| = note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| error: This attribute accepts no arguments | ||
| --> tests/compile-fail/exception-args.rs:14:1 | ||
| | | ||
| 14 | #[exception(SysTick)] | ||
| | ^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: this error originates in the attribute macro `exception` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
cortex-m-rt/tests/compile-fail/exception-bad-signature-1.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `#[exception]` handlers other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` | ||
| --> tests/compile-fail/exception-bad-signature-1.rs:15:1 | ||
| | | ||
| 15 | fn SysTick(undef: u32) {} | ||
| | ^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
cortex-m-rt/tests/compile-fail/exception-bad-signature-2.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error: `#[exception]` handlers other than `DefaultHandler` and `HardFault` must have signature `[unsafe] fn() [-> !]` | ||
| --> tests/compile-fail/exception-bad-signature-2.rs:15:1 | ||
| | | ||
| 15 | fn SysTick() -> u32 { | ||
| | ^^ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
cortex-m-rt/tests/compile-fail/exception-nmi-unsafe.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| error: defining a `DefaultHandler` is unsafe and requires an `unsafe fn` (see the cortex-m-rt docs) | ||
| --> tests/compile-fail/exception-nmi-unsafe.rs:15:4 | ||
| | | ||
| 15 | fn DefaultHandler(_irq: i16) {} | ||
| | ^^^^^^^^^^^^^^ | ||
|
|
||
| error: defining a `HardFault` handler is unsafe and requires an `unsafe fn` (see the cortex-m-rt docs) | ||
| --> tests/compile-fail/exception-nmi-unsafe.rs:18:4 | ||
| | | ||
| 18 | fn HardFault() {} | ||
| | ^^^^^^^^^ | ||
|
|
||
| error: defining a `NonMaskableInt` handler is unsafe and requires an `unsafe fn` (see the cortex-m-rt docs) | ||
| --> tests/compile-fail/exception-nmi-unsafe.rs:21:4 | ||
| | | ||
| 21 | fn NonMaskableInt() {} | ||
| | ^^^^^^^^^^^^^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error[E0425]: cannot find function, tuple struct or tuple variant `SysTick` in this scope | ||
| --> tests/compile-fail/exception-soundness.rs:28:5 | ||
| | | ||
| 28 | SysTick(); | ||
| | ^^^^^^^ not found in this scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| error: symbol `SysTick` is already defined | ||
| --> tests/compile-fail/exception-twice.rs:20:5 | ||
| | | ||
| 20 | #[exception] | ||
| | ^^^^^^^^^^^^ | ||
| | | ||
| = note: this error originates in the attribute macro `exception` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| error[E0599]: no variant, associated function, or constant named `SecureFault` found for enum `cortex_m_rt::Exception` in the current scope | ||
| --> tests/compile-fail/exception-v8only.rs:15:4 | ||
| | | ||
| 15 | fn SecureFault() {} | ||
| | ^^^^^^^^^^^ variant, associated function, or constant not found in `cortex_m_rt::Exception` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we pin the version we test with? So "selected" or "pinned" rather than "current"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSRV is pinned, latest stable is not.