@@ -226,8 +226,11 @@ pub struct Config {
226
226
///
227
227
/// **Note** for backwards compatibility reasons this also accepts solc_version from the toml
228
228
/// file, see `BackwardsCompatTomlProvider`.
229
+ ///
230
+ /// Avoid using this field directly; call the related `solc` methods instead.
231
+ #[ doc( hidden) ]
229
232
pub solc : Option < SolcReq > ,
230
- /// whether to autodetect the solc compiler version to use
233
+ /// Whether to autodetect the solc compiler version to use.
231
234
pub auto_detect_solc : bool ,
232
235
/// Offline mode, if set, network access (downloading solc) is disallowed.
233
236
///
@@ -801,7 +804,7 @@ impl Config {
801
804
802
805
self . fs_permissions . join_all ( & root) ;
803
806
804
- if let Some ( ref mut model_checker) = self . model_checker {
807
+ if let Some ( model_checker) = & mut self . model_checker {
805
808
model_checker. contracts = std:: mem:: take ( & mut model_checker. contracts )
806
809
. into_iter ( )
807
810
. map ( |( path, contracts) | {
@@ -850,12 +853,9 @@ impl Config {
850
853
}
851
854
}
852
855
853
- /// Returns the normalized [EvmVersion] if a [SolcReq] is set to a valid version or if the solc
854
- /// path is a valid solc binary.
855
- ///
856
- /// Otherwise it returns the configured [EvmVersion].
856
+ /// Returns the normalized [EvmVersion] for the current solc version, or the configured one.
857
857
pub fn get_normalized_evm_version ( & self ) -> EvmVersion {
858
- if let Some ( version) = self . solc . as_ref ( ) . and_then ( |solc| solc . try_version ( ) . ok ( ) ) {
858
+ if let Some ( version) = self . solc_version ( ) {
859
859
if let Some ( evm_version) = self . evm_version . normalize_version_solc ( & version) {
860
860
return evm_version;
861
861
}
@@ -1118,7 +1118,8 @@ impl Config {
1118
1118
Err ( RecvTimeoutError :: Disconnected ) => panic ! ( "sender dropped" ) ,
1119
1119
} ;
1120
1120
}
1121
- if let Some ( ref solc) = self . solc {
1121
+
1122
+ if let Some ( solc) = & self . solc {
1122
1123
let solc = match solc {
1123
1124
SolcReq :: Version ( version) => {
1124
1125
if let Some ( solc) = Solc :: find_svm_installed_version ( version) ? {
@@ -1216,6 +1217,11 @@ impl Config {
1216
1217
}
1217
1218
}
1218
1219
1220
+ /// Returns the solc version, if any.
1221
+ pub fn solc_version ( & self ) -> Option < Version > {
1222
+ self . solc . as_ref ( ) . and_then ( |solc| solc. try_version ( ) . ok ( ) )
1223
+ }
1224
+
1219
1225
/// Returns configured [Vyper] compiler.
1220
1226
pub fn vyper_compiler ( & self ) -> Result < Option < Vyper > , SolcError > {
1221
1227
// Only instantiate Vyper if there are any Vyper files in the project.
0 commit comments