@@ -10,66 +10,66 @@ use crate::config::Options;
1010use crate :: options:: CFGuard ;
1111
1212#[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Encodable , BlobDecodable ) ]
13- pub enum EnforcedMitigationLevel {
13+ pub enum EnforcableMitigationLevel {
1414 // Enabled(false) should be the bottom of the Ord hierarchy
1515 Enabled ( bool ) ,
1616 StackProtector ( StackProtector ) ,
1717}
1818
19- impl EnforcedMitigationLevel {
19+ impl EnforcableMitigationLevel {
2020 pub fn level_str ( & self ) -> & ' static str {
2121 match self {
22- EnforcedMitigationLevel :: StackProtector ( StackProtector :: All ) => "=all" ,
23- EnforcedMitigationLevel :: StackProtector ( StackProtector :: Basic ) => "=basic" ,
24- EnforcedMitigationLevel :: StackProtector ( StackProtector :: Strong ) => "=strong" ,
22+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: All ) => "=all" ,
23+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: Basic ) => "=basic" ,
24+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: Strong ) => "=strong" ,
2525 // currently `=disabled` should not appear
26- EnforcedMitigationLevel :: Enabled ( false ) => "=disabled" ,
27- EnforcedMitigationLevel :: StackProtector ( StackProtector :: None )
28- | EnforcedMitigationLevel :: Enabled ( true ) => "" ,
26+ EnforcableMitigationLevel :: Enabled ( false ) => "=disabled" ,
27+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: None )
28+ | EnforcableMitigationLevel :: Enabled ( true ) => "" ,
2929 }
3030 }
3131}
3232
33- impl std:: fmt:: Display for EnforcedMitigationLevel {
33+ impl std:: fmt:: Display for EnforcableMitigationLevel {
3434 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3535 match self {
36- EnforcedMitigationLevel :: StackProtector ( StackProtector :: All ) => {
36+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: All ) => {
3737 write ! ( f, "all" )
3838 }
39- EnforcedMitigationLevel :: StackProtector ( StackProtector :: Basic ) => {
39+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: Basic ) => {
4040 write ! ( f, "basic" )
4141 }
42- EnforcedMitigationLevel :: StackProtector ( StackProtector :: Strong ) => {
42+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: Strong ) => {
4343 write ! ( f, "strong" )
4444 }
45- EnforcedMitigationLevel :: Enabled ( true ) => {
45+ EnforcableMitigationLevel :: Enabled ( true ) => {
4646 write ! ( f, "enabled" )
4747 }
48- EnforcedMitigationLevel :: StackProtector ( StackProtector :: None )
49- | EnforcedMitigationLevel :: Enabled ( false ) => {
48+ EnforcableMitigationLevel :: StackProtector ( StackProtector :: None )
49+ | EnforcableMitigationLevel :: Enabled ( false ) => {
5050 write ! ( f, "disabled" )
5151 }
5252 }
5353 }
5454}
5555
56- impl From < bool > for EnforcedMitigationLevel {
56+ impl From < bool > for EnforcableMitigationLevel {
5757 fn from ( value : bool ) -> Self {
58- EnforcedMitigationLevel :: Enabled ( value)
58+ EnforcableMitigationLevel :: Enabled ( value)
5959 }
6060}
6161
62- impl From < StackProtector > for EnforcedMitigationLevel {
62+ impl From < StackProtector > for EnforcableMitigationLevel {
6363 fn from ( value : StackProtector ) -> Self {
64- EnforcedMitigationLevel :: StackProtector ( value)
64+ EnforcableMitigationLevel :: StackProtector ( value)
6565 }
6666}
6767
68- pub struct EnforcedMitigationKindParseError ;
68+ pub struct EnforcableMitigationKindParseError ;
6969
7070#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord , Encodable , BlobDecodable ) ]
7171pub struct MitigationEnablement {
72- pub kind : EnforcedMitigationKind ,
72+ pub kind : EnforcableMitigationKind ,
7373 pub enabled : bool ,
7474}
7575
@@ -82,58 +82,58 @@ macro_rules! intersperse {
8282macro_rules! enforced_mitigations {
8383 ( [ $self: ident] enum $kind: ident { $( ( $name: ident, $text: expr, $since: ident, $code: expr) ) ,* } ) => {
8484 #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord , Encodable , BlobDecodable ) ]
85- pub enum EnforcedMitigationKind {
85+ pub enum EnforcableMitigationKind {
8686 $( $name) ,*
8787 }
8888
89- impl std:: fmt:: Display for EnforcedMitigationKind {
89+ impl std:: fmt:: Display for EnforcableMitigationKind {
9090 fn fmt( & self , f: & mut std:: fmt:: Formatter <' _>) -> std:: fmt:: Result {
9191 match self {
92- $( EnforcedMitigationKind :: $name => write!( f, $text) ) ,*
92+ $( EnforcableMitigationKind :: $name => write!( f, $text) ) ,*
9393 }
9494 }
9595 }
9696
97- impl EnforcedMitigationKind {
97+ impl EnforcableMitigationKind {
9898 pub ( crate ) const KINDS : & ' static str = concat!( "comma-separated list of mitigation kinds (available: " ,
9999 intersperse!( ", " , ( $( concat!( "`" , $text, "`" ) ) ,* ) ) , ")" ) ;
100100 }
101101
102- impl FromStr for EnforcedMitigationKind {
103- type Err = EnforcedMitigationKindParseError ;
102+ impl FromStr for EnforcableMitigationKind {
103+ type Err = EnforcableMitigationKindParseError ;
104104
105- fn from_str( v: & str ) -> Result <EnforcedMitigationKind , EnforcedMitigationKindParseError > {
105+ fn from_str( v: & str ) -> Result <EnforcableMitigationKind , EnforcableMitigationKindParseError > {
106106 match v {
107- $( $text => Ok ( EnforcedMitigationKind :: $name) ) ,*
107+ $( $text => Ok ( EnforcableMitigationKind :: $name) ) ,*
108108 ,
109- _ => Err ( EnforcedMitigationKindParseError ) ,
109+ _ => Err ( EnforcableMitigationKindParseError ) ,
110110 }
111111 }
112112 }
113113
114114 #[ allow( unused) ]
115- impl EnforcedMitigationKind {
115+ impl EnforcableMitigationKind {
116116 pub fn enforced_since( & self ) -> Edition {
117117 match self {
118118 // Should change the enforced-since edition of StackProtector to 2015
119119 // (all editions) when `-C stack-protector` is stabilized.
120- $( EnforcedMitigationKind :: $name => Edition :: $since) ,*
120+ $( EnforcableMitigationKind :: $name => Edition :: $since) ,*
121121 }
122122 }
123123 }
124124
125125 impl Options {
126- pub fn all_enforced_mitigations( & self ) -> impl Iterator <Item = EnforcedMitigationKind > {
127- [ $( EnforcedMitigationKind :: $name) ,* ] . into_iter( )
126+ pub fn all_enforced_mitigations( & self ) -> impl Iterator <Item = EnforcableMitigationKind > {
127+ [ $( EnforcableMitigationKind :: $name) ,* ] . into_iter( )
128128 }
129129 }
130130
131131 impl Session {
132- pub fn gather_enabled_enforced_mitigations ( & $self) -> Vec <EnforcedMitigation > {
132+ pub fn gather_enabled_enforcable_mitigations ( & $self) -> Vec <EnforcableMitigation > {
133133 let mut mitigations = [
134134 $(
135- EnforcedMitigation {
136- kind: EnforcedMitigationKind :: $name,
135+ EnforcableMitigation {
136+ kind: EnforcableMitigationKind :: $name,
137137 level: From :: from( $code) ,
138138 }
139139 ) ,*
@@ -147,25 +147,25 @@ macro_rules! enforced_mitigations {
147147
148148enforced_mitigations ! {
149149 [ self ]
150- enum EnforcedMitigationKind {
150+ enum EnforcableMitigationKind {
151151 ( StackProtector , "stack-protector" , EditionFuture , self . stack_protector( ) ) ,
152152 ( ControlFlowGuard , "control-flow-guard" , EditionFuture , self . opts. cg. control_flow_guard == CFGuard :: Checks )
153153 }
154154}
155155
156156/// Enforced mitigations, see [RFC 3855](https://github.com/rust-lang/rfcs/pull/3855)
157157#[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Encodable , BlobDecodable ) ]
158- pub struct EnforcedMitigation {
159- pub kind : EnforcedMitigationKind ,
160- pub level : EnforcedMitigationLevel ,
158+ pub struct EnforcableMitigation {
159+ pub kind : EnforcableMitigationKind ,
160+ pub level : EnforcableMitigationLevel ,
161161}
162162
163163impl Options {
164164 // Return the list of mitigations that are allowed to be partial
165165 pub fn allowed_partial_mitigations (
166166 & self ,
167167 edition : Edition ,
168- ) -> impl Iterator < Item = EnforcedMitigationKind > {
168+ ) -> impl Iterator < Item = EnforcableMitigationKind > {
169169 let mut result: BTreeSet < _ > = self
170170 . all_enforced_mitigations ( )
171171 . filter ( |mitigation| mitigation. enforced_since ( ) > edition)
0 commit comments