File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ main() {
6
6
if [ $TRAVIS_RUST_VERSION = nightly ]; then
7
7
cargo check --target $TARGET --features const-fn
8
8
fi
9
+
10
+ if [ $TARGET = x86_64-unknown-linux-gnu ]; then
11
+ cargo test
12
+ fi
9
13
}
10
14
11
15
main
Original file line number Diff line number Diff line change 2
2
3
3
#![ deny( missing_docs) ]
4
4
#![ deny( warnings) ]
5
- #![ cfg_attr( feature = "const-fn" , feature( const_fn, const_unsafe_cell_new) ) ]
5
+ #![ cfg_attr(
6
+ feature = "const-fn" ,
7
+ feature( const_fn, const_unsafe_cell_new)
8
+ ) ]
6
9
#![ no_std]
7
10
8
11
use core:: cell:: UnsafeCell ;
@@ -90,11 +93,20 @@ impl<T> Mutex<T> {
90
93
91
94
impl < T > Mutex < T > {
92
95
/// Borrows the data for the duration of the critical section
93
- pub fn borrow < ' cs > ( & self , _cs : & ' cs CriticalSection ) -> & ' cs T {
96
+ pub fn borrow < ' cs > ( & ' cs self , _cs : & ' cs CriticalSection ) -> & ' cs T {
94
97
unsafe { & * self . inner . get ( ) }
95
98
}
96
99
}
97
100
101
+ /// ``` compile_fail
102
+ /// fn bad(cs: &bare_metal::CriticalSection) -> &u32 {
103
+ /// let x = bare_metal::Mutex::new(42u32);
104
+ /// x.borrow(cs)
105
+ /// }
106
+ /// ```
107
+ #[ allow( dead_code) ]
108
+ const GH_6 : ( ) = ( ) ;
109
+
98
110
/// Interrupt number
99
111
pub unsafe trait Nr {
100
112
/// Returns the number associated with an interrupt
@@ -104,8 +116,4 @@ pub unsafe trait Nr {
104
116
// NOTE A `Mutex` can be used as a channel so the protected data must be `Send`
105
117
// to prevent sending non-Sendable stuff (e.g. access tokens) across different
106
118
// execution contexts (e.g. interrupts)
107
- unsafe impl < T > Sync for Mutex < T >
108
- where
109
- T : Send ,
110
- {
111
- }
119
+ unsafe impl < T > Sync for Mutex < T > where T : Send { }
You can’t perform that action at this time.
0 commit comments