File tree Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Original file line number Diff line number Diff line change
1
+ name : Clippy
2
+
3
+ on :
4
+ push :
5
+ branches : [ staging, trying, master ]
6
+ pull_request :
7
+ branches : [ master ]
8
+
9
+ defaults :
10
+ run :
11
+ shell : bash
12
+
13
+ env :
14
+ CLIPPY_PARAMS : -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
15
+
16
+ jobs :
17
+ clippy :
18
+ name : Clippy
19
+ runs-on : ubuntu-latest
20
+ strategy :
21
+ matrix :
22
+ cargo_flags :
23
+ - " --no-default-features"
24
+ - " --all-features"
25
+ steps :
26
+ - name : Checkout source code
27
+ uses : actions/checkout@v3
28
+
29
+ - name : Install Rust toolchain
30
+ uses : dtolnay/rust-toolchain@stable
31
+ with :
32
+ toolchain : stable
33
+ components : clippy
34
+
35
+ - name : Run clippy
36
+ run : cargo clippy --all ${{ matrix.cargo_flags }} -- -D warnings
Original file line number Diff line number Diff line change 26
26
//! a target-specific implementation instead, typically provided by a HAL or RTOS crate.
27
27
28
28
#![ no_std]
29
+ #![ allow( clippy:: missing_safety_doc) ]
29
30
30
31
pub mod asm;
31
32
pub mod delay;
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ impl Mcounteren {
30
30
/// Supervisor "hpm\[x\]" Enable (bits 3-31)
31
31
#[ inline]
32
32
pub fn hpm ( & self , index : usize ) -> bool {
33
- assert ! ( 3 <= index && index < 32 ) ;
33
+ assert ! ( ( 3 .. 32 ) . contains ( & index) ) ;
34
34
self . bits . get_bit ( index)
35
35
}
36
36
}
@@ -54,12 +54,12 @@ set_clear_csr!(
54
54
55
55
#[ inline]
56
56
pub unsafe fn set_hpm ( index : usize ) {
57
- assert ! ( 3 <= index && index < 32 ) ;
57
+ assert ! ( ( 3 .. 32 ) . contains ( & index) ) ;
58
58
_set ( 1 << index) ;
59
59
}
60
60
61
61
#[ inline]
62
62
pub unsafe fn clear_hpm ( index : usize ) {
63
- assert ! ( 3 <= index && index < 32 ) ;
63
+ assert ! ( ( 3 .. 32 ) . contains ( & index) ) ;
64
64
_clear ( 1 << index) ;
65
65
}
Original file line number Diff line number Diff line change 8
8
// which would be the best way we implement this using Rust?
9
9
10
10
use bit_field:: BitField ;
11
- use core:: mem:: size_of;
12
11
13
12
/// mstatus register
14
13
#[ derive( Clone , Copy , Debug ) ]
@@ -205,7 +204,7 @@ impl Mstatus {
205
204
/// signals the presence of some dirty state
206
205
#[ inline]
207
206
pub fn sd ( & self ) -> bool {
208
- self . bits . get_bit ( size_of :: < usize > ( ) * 8 - 1 )
207
+ self . bits . get_bit ( usize :: BITS as usize - 1 )
209
208
}
210
209
}
211
210
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ impl Pmpcsr {
72
72
3 => Range :: NAPOT ,
73
73
_ => unreachable ! ( ) ,
74
74
} ,
75
- locked : byte. get_bit ( 7 ) as bool ,
75
+ locked : byte. get_bit ( 7 ) ,
76
76
}
77
77
}
78
78
}
Original file line number Diff line number Diff line change 1
1
//! scause register
2
2
3
3
use bit_field:: BitField ;
4
- use core:: mem:: size_of;
5
4
6
5
/// scause register
7
6
#[ derive( Clone , Copy ) ]
@@ -90,7 +89,7 @@ impl Scause {
90
89
/// Returns the code field
91
90
#[ inline]
92
91
pub fn code ( & self ) -> usize {
93
- let bit = 1 << ( size_of :: < usize > ( ) * 8 - 1 ) ;
92
+ let bit = 1 << ( usize :: BITS as usize - 1 ) ;
94
93
self . bits & !bit
95
94
}
96
95
@@ -107,7 +106,7 @@ impl Scause {
107
106
/// Is trap cause an interrupt.
108
107
#[ inline]
109
108
pub fn is_interrupt ( & self ) -> bool {
110
- self . bits . get_bit ( size_of :: < usize > ( ) * 8 - 1 )
109
+ self . bits . get_bit ( usize :: BITS as usize - 1 )
111
110
}
112
111
113
112
/// Is trap cause an exception.
@@ -139,7 +138,7 @@ pub unsafe fn set(cause: Trap) {
139
138
Interrupt :: UserExternal => 8 ,
140
139
Interrupt :: SupervisorExternal => 9 ,
141
140
Interrupt :: Unknown => panic ! ( "unknown interrupt" ) ,
142
- } | ( 1 << ( size_of :: < usize > ( ) * 8 - 1 ) ) )
141
+ } | ( 1 << ( usize :: BITS as usize - 1 ) ) )
143
142
} // interrupt bit is 1
144
143
Trap :: Exception ( e) => match e {
145
144
Exception :: InstructionMisaligned => 0 ,
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ impl Scounteren {
30
30
/// User "hpm\[x\]" Enable (bits 3-31)
31
31
#[ inline]
32
32
pub fn hpm ( & self , index : usize ) -> bool {
33
- assert ! ( 3 <= index && index < 32 ) ;
33
+ assert ! ( ( 3 .. 32 ) . contains ( & index) ) ;
34
34
self . bits . get_bit ( index)
35
35
}
36
36
}
@@ -54,12 +54,12 @@ set_clear_csr!(
54
54
55
55
#[ inline]
56
56
pub unsafe fn set_hpm ( index : usize ) {
57
- assert ! ( 3 <= index && index < 32 ) ;
57
+ assert ! ( ( 3 .. 32 ) . contains ( & index) ) ;
58
58
_set ( 1 << index) ;
59
59
}
60
60
61
61
#[ inline]
62
62
pub unsafe fn clear_hpm ( index : usize ) {
63
- assert ! ( 3 <= index && index < 32 ) ;
63
+ assert ! ( ( 3 .. 32 ) . contains ( & index) ) ;
64
64
_clear ( 1 << index) ;
65
65
}
Original file line number Diff line number Diff line change 2
2
3
3
pub use super :: mstatus:: FS ;
4
4
use bit_field:: BitField ;
5
- use core:: mem:: size_of;
6
5
7
6
/// Supervisor Status Register
8
7
#[ derive( Clone , Copy , Debug ) ]
@@ -92,7 +91,7 @@ impl Sstatus {
92
91
/// signals the presence of some dirty state
93
92
#[ inline]
94
93
pub fn sd ( & self ) -> bool {
95
- self . bits . get_bit ( size_of :: < usize > ( ) * 8 - 1 )
94
+ self . bits . get_bit ( usize :: BITS as usize - 1 )
96
95
}
97
96
}
98
97
You can’t perform that action at this time.
0 commit comments