1- use std:: {
2- collections:: BTreeMap ,
3- path:: { Path , PathBuf } ,
4- } ;
5-
1+ use super :: { remove_whitespaces, INLINE_CONFIG_PREFIX , INLINE_CONFIG_PREFIX_SELECTED_PROFILE } ;
62use ethers_solc:: {
73 artifacts:: { ast:: NodeType , Node } ,
8- ArtifactId , ArtifactOutput , Artifacts , ConfigurableArtifacts , ProjectCompileOutput ,
4+ ProjectCompileOutput ,
95} ;
106use serde_json:: Value ;
11-
12- use super :: { remove_whitespaces, INLINE_CONFIG_PREFIX , INLINE_CONFIG_PREFIX_SELECTED_PROFILE } ;
7+ use std:: { collections:: BTreeMap , path:: Path } ;
138
149/// Convenient struct to hold in-line per-test configurations
1510pub struct NatSpec {
@@ -32,9 +27,7 @@ impl NatSpec {
3227 pub fn parse ( output : & ProjectCompileOutput , root : & Path ) -> Vec < Self > {
3328 let mut natspecs: Vec < Self > = vec ! [ ] ;
3429
35- let artifacts = artifacts :: < _ , ConfigurableArtifacts > ( output. cached_artifacts ( ) )
36- . chain ( artifacts :: < _ , ConfigurableArtifacts > ( output. compiled_artifacts ( ) ) ) ;
37- for ( id, artifact) in artifacts {
30+ for ( id, artifact) in output. artifact_ids ( ) {
3831 let Some ( ast) = & artifact. ast else { continue } ;
3932 let path = id. source . as_path ( ) ;
4033 let path = path. strip_prefix ( root) . unwrap_or ( path) ;
@@ -89,31 +82,6 @@ fn contract_root_node<'a>(nodes: &'a [Node], contract_id: &'a str) -> Option<&'a
8982 None
9083}
9184
92- // borrowed version of `Artifacts::into_artifacts`
93- fn artifacts < ' a , T , O : ArtifactOutput < Artifact = T > > (
94- a : & ' a Artifacts < T > ,
95- ) -> impl Iterator < Item = ( ArtifactId , & ' a T ) > + ' a {
96- a. 0 . iter ( ) . flat_map ( |( file, contract_artifacts) | {
97- contract_artifacts. iter ( ) . flat_map ( move |( _contract_name, artifacts) | {
98- let source = PathBuf :: from ( file. clone ( ) ) ;
99- artifacts. iter ( ) . filter_map ( move |artifact| {
100- O :: contract_name ( & artifact. file ) . map ( |name| {
101- (
102- ArtifactId {
103- path : PathBuf :: from ( & artifact. file ) ,
104- name,
105- source : source. clone ( ) ,
106- version : artifact. version . clone ( ) ,
107- }
108- . with_slashed_paths ( ) ,
109- & artifact. artifact ,
110- )
111- } )
112- } )
113- } )
114- } )
115- }
116-
11785/// Implements a DFS over a compiler output node and its children.
11886/// If a natspec is found it is added to `natspecs`
11987fn apply ( natspecs : & mut Vec < NatSpec > , contract : & str , node : & Node ) {
0 commit comments