@@ -194,7 +194,7 @@ where
194194fn compile_qasm_to_qir ( source : & str , profile : Profile ) -> Result < String , Vec < Report > > {
195195 let unit = compile ( source) ?;
196196 fail_on_compilation_errors ( & unit) ;
197- let package = unit. package . expect ( "no package found" ) ;
197+ let package = unit. package ;
198198 let qir = generate_qir_from_ast ( package, unit. source_map , profile) . map_err ( |errors| {
199199 errors
200200 . iter ( )
@@ -231,7 +231,7 @@ fn compile_qasm_best_effort(source: &str, profile: Profile) {
231231 let ( mut _unit, _errors) = compile_ast (
232232 & store,
233233 & dependencies,
234- package. expect ( "package must exist" ) ,
234+ package,
235235 sources,
236236 PackageType :: Lib ,
237237 profile. into ( ) ,
@@ -244,7 +244,7 @@ pub(crate) fn gen_qsharp_stmt(stmt: &Stmt) -> String {
244244
245245#[ allow( dead_code) ]
246246pub ( crate ) fn compare_compilation_to_qsharp ( unit : & QasmCompileUnit , expected : & str ) {
247- let package = unit. package . as_ref ( ) . expect ( "package must exist" ) ;
247+ let package = & unit. package ;
248248 let despanned_ast = AstDespanner . despan ( package) ;
249249 let qsharp = gen_qsharp ( & despanned_ast) ;
250250 difference:: assert_diff!( & qsharp, expected, "\n " , 0 ) ;
@@ -306,10 +306,7 @@ pub fn compile_qasm_to_qsharp_file(source: &str) -> miette::Result<String, Vec<R
306306 let errors = unit. errors . into_iter ( ) . map ( Report :: new) . collect ( ) ;
307307 return Err ( errors) ;
308308 }
309- let Some ( package) = unit. package else {
310- panic ! ( "Expected package, got None" ) ;
311- } ;
312- let qsharp = gen_qsharp ( & package) ;
309+ let qsharp = gen_qsharp ( & unit. package ) ;
313310 Ok ( qsharp)
314311}
315312
@@ -326,10 +323,7 @@ pub fn compile_qasm_to_qsharp_operation(source: &str) -> miette::Result<String,
326323 let errors = unit. errors . into_iter ( ) . map ( Report :: new) . collect ( ) ;
327324 return Err ( errors) ;
328325 }
329- let Some ( package) = unit. package else {
330- panic ! ( "Expected package, got None" ) ;
331- } ;
332- let qsharp = gen_qsharp ( & package) ;
326+ let qsharp = gen_qsharp ( & unit. package ) ;
333327 Ok ( qsharp)
334328}
335329
@@ -357,10 +351,7 @@ pub fn qsharp_from_qasm_compilation(unit: QasmCompileUnit) -> miette::Result<Str
357351 let errors = unit. errors . into_iter ( ) . map ( Report :: new) . collect ( ) ;
358352 return Err ( errors) ;
359353 }
360- let Some ( package) = unit. package else {
361- panic ! ( "Expected package, got None" ) ;
362- } ;
363- let qsharp = gen_qsharp ( & package) ;
354+ let qsharp = gen_qsharp ( & unit. package ) ;
364355 Ok ( qsharp)
365356}
366357
@@ -384,10 +375,7 @@ pub fn compile_qasm_stmt_to_qsharp_with_semantics(
384375 let errors = unit. errors . into_iter ( ) . map ( Report :: new) . collect ( ) ;
385376 return Err ( errors) ;
386377 }
387- let Some ( package) = unit. package else {
388- panic ! ( "Expected package, got None" ) ;
389- } ;
390- let qsharp = get_last_statement_as_qsharp ( & package) ;
378+ let qsharp = get_last_statement_as_qsharp ( & unit. package ) ;
391379 Ok ( qsharp)
392380}
393381
@@ -471,8 +459,7 @@ pub(crate) fn compare_qasm_and_qasharp_asts(source: &str) {
471459 Some ( & mut resolver) ,
472460 config,
473461 ) ;
474- let qasm_package = unit. package . as_ref ( ) . expect ( "package must exist" ) ;
475- let despanned_qasm_ast = AstDespanner . despan ( qasm_package) ;
462+ let despanned_qasm_ast = AstDespanner . despan ( & unit. package ) ;
476463
477464 // 2. Generate Q# source from the QASM ast.
478465 let qsharp_src = gen_qsharp ( & despanned_qasm_ast) ;
0 commit comments