File tree 1 file changed +11
-4
lines changed
crates/noirc_frontend/src/graph
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -149,11 +149,18 @@ impl CrateGraph {
149
149
}
150
150
151
151
pub fn add_crate ( & mut self , file_id : FileId ) -> CrateId {
152
- // Should this also be asserted that it only has exactly one match?
153
- let mut roots_with_file_id =
154
- self . arena . iter ( ) . filter ( |( _, crate_data) | crate_data. root_file_id == file_id) ;
152
+ let mut crates_with_file_id = self
153
+ . arena
154
+ . iter ( )
155
+ . filter ( |( _, crate_data) | crate_data. root_file_id == file_id)
156
+ . peekable ( ) ;
157
+
158
+ let matching_id = crates_with_file_id. next ( ) ;
159
+ if crates_with_file_id. peek ( ) . is_some ( ) {
160
+ panic ! ( "ICE: Found multiple crates with the same FileId" ) ;
161
+ }
155
162
156
- match roots_with_file_id . next ( ) {
163
+ match matching_id {
157
164
Some ( ( crate_id @ CrateId :: Crate ( _) , _) ) => * crate_id,
158
165
Some ( ( CrateId :: Root ( _) , _) ) => {
159
166
panic ! ( "ICE: Tried to re-add the root crate as a regular crate" )
You can’t perform that action at this time.
0 commit comments