Skip to content

Commit 1a83d13

Browse files
authored
Try #276:
2 parents 25f6613 + 91470c7 commit 1a83d13

21 files changed

+118
-61
lines changed

.github/bors.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
block_labels = ["needs-decision"]
22
delete_merged_branches = true
33
required_approvals = 1
4-
status = ["continuous-integration/travis-ci/push"]
4+
status = [
5+
"ci-linux (stable)",
6+
"ci-linux (1.38.0)",
7+
"rustfmt",
8+
]

.github/workflows/ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: CI
7+
8+
jobs:
9+
ci-linux:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
# All generated code should be running on stable now
14+
rust: [stable]
15+
16+
include:
17+
# Test MSRV
18+
- rust: 1.38.0
19+
20+
# Test nightly but don't fail
21+
- rust: nightly
22+
experimental: true
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: actions-rs/toolchain@v1
26+
with:
27+
profile: minimal
28+
toolchain: ${{ matrix.rust }}
29+
override: true
30+
- name: Run tests
31+
run: cargo test --all
32+
33+
# FIXME: test on macOS and Windows

.github/workflows/clippy.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Clippy check
7+
jobs:
8+
clippy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
profile: minimal
15+
toolchain: stable
16+
override: true
17+
components: clippy
18+
- uses: actions-rs/clippy-check@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rustfmt.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Code formatting check
7+
8+
jobs:
9+
fmt:
10+
name: rustfmt
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: stable
18+
override: true
19+
components: rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check

.travis.yml

-34
This file was deleted.

asm/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! All of these functions should be blanket-`unsafe`. `cortex-m` provides safe wrappers where
77
//! applicable.
88
9-
use core::sync::atomic::{Ordering, compiler_fence};
9+
use core::sync::atomic::{compiler_fence, Ordering};
1010

1111
#[inline(always)]
1212
pub unsafe fn __bkpt() {
@@ -187,7 +187,7 @@ pub unsafe fn __syscall(mut nr: u32, arg: u32) -> u32 {
187187
pub use self::v7m::*;
188188
#[cfg(any(armv7m, armv8m_main))]
189189
mod v7m {
190-
use core::sync::atomic::{Ordering, compiler_fence};
190+
use core::sync::atomic::{compiler_fence, Ordering};
191191

192192
#[inline(always)]
193193
pub unsafe fn __basepri_max(val: u8) {

bin/thumbv6m-none-eabi-lto.a

0 Bytes
Binary file not shown.

bin/thumbv7em-none-eabi-lto.a

4 Bytes
Binary file not shown.

bin/thumbv7em-none-eabihf-lto.a

-4 Bytes
Binary file not shown.

bin/thumbv7m-none-eabi-lto.a

-4 Bytes
Binary file not shown.

bin/thumbv8m.base-none-eabi-lto.a

0 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabi-lto.a

4 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabihf-lto.a

-4 Bytes
Binary file not shown.

cortex-m-semihosting/src/hio.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Host I/O
22
3-
use core::{fmt, slice};
43
use crate::nr;
4+
use core::{fmt, slice};
55

66
/// A byte stream to the host (e.g., host's stdout or stderr).
77
#[derive(Clone, Copy)]
@@ -38,8 +38,7 @@ pub fn hstdout() -> Result<HostStream, ()> {
3838

3939
fn open(name: &str, mode: usize) -> Result<HostStream, ()> {
4040
let name = name.as_bytes();
41-
match unsafe { syscall!(OPEN, name.as_ptr(), mode, name.len() - 1) } as
42-
isize {
41+
match unsafe { syscall!(OPEN, name.as_ptr(), mode, name.len() - 1) } as isize {
4342
-1 => Err(()),
4443
fd => Ok(HostStream { fd: fd as usize }),
4544
}
@@ -53,9 +52,7 @@ fn write_all(fd: usize, mut buffer: &[u8]) -> Result<(), ()> {
5352
// `n` bytes were not written
5453
n if n <= buffer.len() => {
5554
let offset = (buffer.len() - n) as isize;
56-
buffer = unsafe {
57-
slice::from_raw_parts(buffer.as_ptr().offset(offset), n)
58-
}
55+
buffer = unsafe { slice::from_raw_parts(buffer.as_ptr().offset(offset), n) }
5956
}
6057
#[cfg(feature = "jlink-quirks")]
6158
// Error (-1) - should be an error but JLink can return -1, -2, -3,...

cortex-m-semihosting/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ pub unsafe fn syscall1(_nr: usize, _arg: usize) -> usize {
218218
}
219219

220220
#[cfg(all(thumb, feature = "no-semihosting"))]
221-
() => {
222-
0
223-
}
221+
() => 0,
224222

225223
#[cfg(not(thumb))]
226224
() => unimplemented!(),

cortex-m-semihosting/src/macros.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ macro_rules! syscall {
1111
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize])
1212
};
1313
($nr:ident, $a1:expr, $a2:expr, $a3:expr) => {
14-
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize,
15-
$a3 as usize])
14+
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize, $a3 as usize])
1615
};
1716
($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {
18-
$crate::syscall($crate::nr::$nr, &[$a1 as usize, $a2 as usize,
19-
$a3 as usize, $a4 as usize])
17+
$crate::syscall(
18+
$crate::nr::$nr,
19+
&[$a1 as usize, $a2 as usize, $a3 as usize, $a4 as usize],
20+
)
2021
};
2122
}
2223

src/delay.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ impl Delay {
1717
pub fn new(mut syst: SYST, ahb_frequency: u32) -> Self {
1818
syst.set_clock_source(SystClkSource::Core);
1919

20-
Delay { syst, ahb_frequency }
20+
Delay {
21+
syst,
22+
ahb_frequency,
23+
}
2124
}
2225

2326
/// Releases the system timer (SysTick) resource.

src/interrupt.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ pub unsafe trait InterruptNumber: Copy {
2525

2626
/// Implement InterruptNumber for the old bare_metal::Nr trait.
2727
/// This implementation is for backwards compatibility only and will be removed in cortex-m 0.8.
28-
#[deprecated(since="0.7.0", note="Please update your PAC to one using the latest svd2rust")]
28+
#[deprecated(
29+
since = "0.7.0",
30+
note = "Please update your PAC to one using the latest svd2rust"
31+
)]
2932
unsafe impl<T: Nr + Copy> InterruptNumber for T {
33+
#[inline]
3034
fn number(self) -> u16 {
3135
self.nr() as u16
3236
}

src/itm.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ pub fn write_all(port: &mut Stim, buffer: &[u8]) {
140140
/// ```
141141
#[allow(clippy::missing_inline_in_public_items)]
142142
pub fn write_aligned(port: &mut Stim, buffer: &Aligned<[u8]>) {
143-
unsafe {
144-
write_aligned_impl(port, &buffer.0)
145-
}
143+
unsafe { write_aligned_impl(port, &buffer.0) }
146144
}
147145

148146
/// Writes `fmt::Arguments` to the ITM `port`

src/peripheral/dcb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use volatile_register::{RW, WO};
44

5-
use core::ptr;
65
use crate::peripheral::DCB;
6+
use core::ptr;
77

88
const DCB_DEMCR_TRCENA: u32 = 1 << 24;
99

src/peripheral/scb.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ impl SCB {
339339
// NOTE(unsafe): The asm routine manages exclusive access to the SCB
340340
// registers and applies the proper barriers; it is technically safe on
341341
// its own, and is only `unsafe` here because it's `extern "C"`.
342-
unsafe { __enable_icache(); }
342+
unsafe {
343+
__enable_icache();
344+
}
343345
}
344346

345347
/// Disables I-cache if currently enabled.
@@ -412,7 +414,9 @@ impl SCB {
412414
// NOTE(unsafe): The asm routine manages exclusive access to the SCB
413415
// registers and applies the proper barriers; it is technically safe on
414416
// its own, and is only `unsafe` here because it's `extern "C"`.
415-
unsafe { __enable_dcache(); }
417+
unsafe {
418+
__enable_dcache();
419+
}
416420
}
417421

418422
/// Disables D-cache if currently enabled.
@@ -960,7 +964,7 @@ impl SCB {
960964

961965
// NOTE(unsafe): Index is bounded to [4,15] by SystemHandler design.
962966
// TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
963-
let priority_ref = unsafe {(*Self::ptr()).shpr.get_unchecked(usize::from(index - 4))};
967+
let priority_ref = unsafe { (*Self::ptr()).shpr.get_unchecked(usize::from(index - 4)) };
964968

965969
priority_ref.read()
966970
}
@@ -971,7 +975,11 @@ impl SCB {
971975

972976
// NOTE(unsafe): Index is bounded to [11,15] by SystemHandler design.
973977
// TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
974-
let priority_ref = unsafe {(*Self::ptr()).shpr.get_unchecked(usize::from((index - 8) / 4))};
978+
let priority_ref = unsafe {
979+
(*Self::ptr())
980+
.shpr
981+
.get_unchecked(usize::from((index - 8) / 4))
982+
};
975983

976984
let shpr = priority_ref.read();
977985
let prio = (shpr >> (8 * (index % 4))) & 0x0000_00ff;
@@ -1008,7 +1016,9 @@ impl SCB {
10081016
{
10091017
// NOTE(unsafe): Index is bounded to [11,15] by SystemHandler design.
10101018
// TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
1011-
let priority_ref = (*Self::ptr()).shpr.get_unchecked(usize::from((index - 8) / 4));
1019+
let priority_ref = (*Self::ptr())
1020+
.shpr
1021+
.get_unchecked(usize::from((index - 8) / 4));
10121022

10131023
priority_ref.modify(|value| {
10141024
let shift = 8 * (index % 4);

0 commit comments

Comments
 (0)