-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
268: CI: replace compiletest-rs with trybuild r=japaric a=japaric We use compiletest to run compile-fail tests but compiletest depends on compiler internals so it breaks every now and then and requires nightly. With trybuild we can also run compile-fail tests but it works on stable and it already has reached version 1.0 270: Added struct de-structure-ing example in tips & tricks r=japaric a=korken89 As per last meeting, a bare-bones added that we can improve Co-authored-by: Jorge Aparicio <jorge@japaric.io> Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
- Loading branch information
Showing
14 changed files
with
80 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,47 @@ | ||
//! examples/destructure.rs | ||
|
||
#![deny(unsafe_code)] | ||
#![deny(warnings)] | ||
#![no_main] | ||
#![no_std] | ||
|
||
use cortex_m_semihosting::hprintln; | ||
use lm3s6965::Interrupt; | ||
use panic_semihosting as _; | ||
|
||
#[rtfm::app(device = lm3s6965)] | ||
const APP: () = { | ||
struct Resources { | ||
// Some resources to work with | ||
#[init(0)] | ||
a: u32, | ||
#[init(0)] | ||
b: u32, | ||
#[init(0)] | ||
c: u32, | ||
} | ||
|
||
#[init] | ||
fn init(_: init::Context) { | ||
rtfm::pend(Interrupt::UART0); | ||
rtfm::pend(Interrupt::UART1); | ||
} | ||
|
||
// Direct destructure | ||
#[task(binds = UART0, resources = [a, b, c])] | ||
fn uart0(cx: uart0::Context) { | ||
let a = cx.resources.a; | ||
let b = cx.resources.b; | ||
let c = cx.resources.c; | ||
|
||
hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap(); | ||
} | ||
|
||
// De-structure-ing syntax | ||
#[task(binds = UART1, resources = [a, b, c])] | ||
fn uart1(cx: uart1::Context) { | ||
let uart1::Resources { a, b, c } = cx.resources; | ||
|
||
hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap(); | ||
} | ||
}; |
This file contains 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,19 +1,7 @@ | ||
use std::path::PathBuf; | ||
|
||
use compiletest_rs::{common::Mode, Config}; | ||
use trybuild::TestCases; | ||
|
||
#[test] | ||
fn ui() { | ||
let mut config = Config::default(); | ||
|
||
config.mode = Mode::Ui; | ||
config.src_base = PathBuf::from("ui/single"); | ||
config.target_rustcflags = Some( | ||
"--edition=2018 -L target/debug/deps -Z unstable-options --extern rtfm --extern lm3s6965" | ||
.to_owned(), | ||
); | ||
config.link_deps(); | ||
config.clean_rmeta(); | ||
|
||
compiletest_rs::run_tests(&config); | ||
let t = TestCases::new(); | ||
t.compile_fail("ui/single/*.rs"); | ||
} |
This file contains 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 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 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 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 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 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 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,9 +1,13 @@ | ||
warning: unused import: `rtfm::app` | ||
--> $DIR/task-priority-too-high.rs:3:5 | ||
| | ||
3 | use rtfm::app; | ||
| ^^^^^^^^^ | ||
| | ||
= note: #[warn(unused_imports)] on by default | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/task-priority-too-high.rs:5:1 | ||
| | ||
5 | #[rtfm::app(device = lm3s6965)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |