@@ -833,9 +833,12 @@ fn quoted_as_module(
833
833
parse ( interpreter. elaborator , argument, Parser :: parse_path_no_turbofish_or_error, "a path" )
834
834
. ok ( ) ;
835
835
let option_value = path. and_then ( |path| {
836
- let module = interpreter
837
- . elaborate_in_function ( interpreter. current_function , |elaborator| {
838
- elaborator. resolve_module_by_path ( path)
836
+ let module =
837
+ interpreter. elaborate_in_function ( interpreter. current_function , |elaborator| {
838
+ let reason = ElaborateReason :: EvaluatingComptimeCall ( "Quoted::as_module" , location) ;
839
+ elaborator. with_elaborate_reason ( reason, |elaborator| {
840
+ elaborator. resolve_module_by_path ( path)
841
+ } )
839
842
} ) ;
840
843
module. map ( Value :: ModuleDefinition )
841
844
} ) ;
@@ -858,7 +861,11 @@ fn quoted_as_trait_constraint(
858
861
) ?;
859
862
let bound = interpreter
860
863
. elaborate_in_function ( interpreter. current_function , |elaborator| {
861
- elaborator. resolve_trait_bound ( & trait_bound)
864
+ let reason =
865
+ ElaborateReason :: EvaluatingComptimeCall ( "Quoted::as_trait_constraint" , location) ;
866
+ elaborator. with_elaborate_reason ( reason, |elaborator| {
867
+ elaborator. resolve_trait_bound ( & trait_bound)
868
+ } )
862
869
} )
863
870
. ok_or ( InterpreterError :: FailedToResolveTraitBound { trait_bound, location } ) ?;
864
871
@@ -873,8 +880,10 @@ fn quoted_as_type(
873
880
) -> IResult < Value > {
874
881
let argument = check_one_argument ( arguments, location) ?;
875
882
let typ = parse ( interpreter. elaborator , argument, Parser :: parse_type_or_error, "a type" ) ?;
876
- let typ = interpreter
877
- . elaborate_in_function ( interpreter. current_function , |elab| elab. resolve_type ( typ) ) ;
883
+ let typ = interpreter. elaborate_in_function ( interpreter. current_function , |elaborator| {
884
+ let reason = ElaborateReason :: EvaluatingComptimeCall ( "Quoted::as_type" , location) ;
885
+ elaborator. with_elaborate_reason ( reason, |elaborator| elaborator. resolve_type ( typ) )
886
+ } ) ;
878
887
Ok ( Value :: Type ( typ) )
879
888
}
880
889
@@ -2292,32 +2301,37 @@ fn expr_resolve(
2292
2301
interpreter. current_function
2293
2302
} ;
2294
2303
2295
- interpreter. elaborate_in_function ( function_to_resolve_in, |elaborator| match expr_value {
2296
- ExprValue :: Expression ( expression_kind) => {
2297
- let expr = Expression { kind : expression_kind, location : self_argument_location } ;
2298
- let ( expr_id, _) = elaborator. elaborate_expression ( expr) ;
2299
- Ok ( Value :: TypedExpr ( TypedExpr :: ExprId ( expr_id) ) )
2300
- }
2301
- ExprValue :: Statement ( statement_kind) => {
2302
- let statement = Statement { kind : statement_kind, location : self_argument_location } ;
2303
- let ( stmt_id, _) = elaborator. elaborate_statement ( statement) ;
2304
- Ok ( Value :: TypedExpr ( TypedExpr :: StmtId ( stmt_id) ) )
2305
- }
2306
- ExprValue :: LValue ( lvalue) => {
2307
- let expr = lvalue. as_expression ( ) ;
2308
- let ( expr_id, _) = elaborator. elaborate_expression ( expr) ;
2309
- Ok ( Value :: TypedExpr ( TypedExpr :: ExprId ( expr_id) ) )
2310
- }
2311
- ExprValue :: Pattern ( pattern) => {
2312
- if let Some ( expression) = pattern. try_as_expression ( elaborator. interner ) {
2313
- let ( expr_id, _) = elaborator. elaborate_expression ( expression) ;
2304
+ interpreter. elaborate_in_function ( function_to_resolve_in, |elaborator| {
2305
+ let reason = ElaborateReason :: EvaluatingComptimeCall ( "Expr::resolve" , location) ;
2306
+ elaborator. with_elaborate_reason ( reason, |elaborator| match expr_value {
2307
+ ExprValue :: Expression ( expression_kind) => {
2308
+ let expr = Expression { kind : expression_kind, location : self_argument_location } ;
2309
+ let ( expr_id, _) = elaborator. elaborate_expression ( expr) ;
2314
2310
Ok ( Value :: TypedExpr ( TypedExpr :: ExprId ( expr_id) ) )
2315
- } else {
2316
- let expression = Value :: pattern ( pattern) . display ( elaborator. interner ) . to_string ( ) ;
2317
- let location = self_argument_location;
2318
- Err ( InterpreterError :: CannotResolveExpression { location, expression } )
2319
2311
}
2320
- }
2312
+ ExprValue :: Statement ( statement_kind) => {
2313
+ let statement =
2314
+ Statement { kind : statement_kind, location : self_argument_location } ;
2315
+ let ( stmt_id, _) = elaborator. elaborate_statement ( statement) ;
2316
+ Ok ( Value :: TypedExpr ( TypedExpr :: StmtId ( stmt_id) ) )
2317
+ }
2318
+ ExprValue :: LValue ( lvalue) => {
2319
+ let expr = lvalue. as_expression ( ) ;
2320
+ let ( expr_id, _) = elaborator. elaborate_expression ( expr) ;
2321
+ Ok ( Value :: TypedExpr ( TypedExpr :: ExprId ( expr_id) ) )
2322
+ }
2323
+ ExprValue :: Pattern ( pattern) => {
2324
+ if let Some ( expression) = pattern. try_as_expression ( elaborator. interner ) {
2325
+ let ( expr_id, _) = elaborator. elaborate_expression ( expression) ;
2326
+ Ok ( Value :: TypedExpr ( TypedExpr :: ExprId ( expr_id) ) )
2327
+ } else {
2328
+ let expression =
2329
+ Value :: pattern ( pattern) . display ( elaborator. interner ) . to_string ( ) ;
2330
+ let location = self_argument_location;
2331
+ Err ( InterpreterError :: CannotResolveExpression { location, expression } )
2332
+ }
2333
+ }
2334
+ } )
2321
2335
} )
2322
2336
}
2323
2337
@@ -2427,7 +2441,11 @@ fn function_def_as_typed_expr(
2427
2441
let expr_id = interpreter. elaborator . interner . push_expr ( hir_expr) ;
2428
2442
interpreter. elaborator . interner . push_expr_location ( expr_id, location) ;
2429
2443
let typ = interpreter. elaborate_in_function ( interpreter. current_function , |elaborator| {
2430
- elaborator. type_check_variable ( hir_ident, expr_id, generics)
2444
+ let reason =
2445
+ ElaborateReason :: EvaluatingComptimeCall ( "FunctionDefinition::as_typed_expr" , location) ;
2446
+ elaborator. with_elaborate_reason ( reason, |elaborator| {
2447
+ elaborator. type_check_variable ( hir_ident, expr_id, generics)
2448
+ } )
2431
2449
} ) ;
2432
2450
interpreter. elaborator . interner . push_expr_type ( expr_id, typ) ;
2433
2451
Ok ( Value :: TypedExpr ( TypedExpr :: ExprId ( expr_id) ) )
@@ -2635,13 +2653,19 @@ fn function_def_set_parameters(
2635
2653
) ?;
2636
2654
2637
2655
let hir_pattern = interpreter. elaborate_in_function ( Some ( func_id) , |elaborator| {
2638
- elaborator. elaborate_pattern_and_store_ids (
2639
- parameter_pattern,
2640
- parameter_type. clone ( ) ,
2641
- DefinitionKind :: Local ( None ) ,
2642
- & mut parameter_idents,
2643
- true , // warn_if_unused
2644
- )
2656
+ let reason = ElaborateReason :: EvaluatingComptimeCall (
2657
+ "FunctionDefinition::set_parameters" ,
2658
+ location,
2659
+ ) ;
2660
+ elaborator. with_elaborate_reason ( reason, |elaborator| {
2661
+ elaborator. elaborate_pattern_and_store_ids (
2662
+ parameter_pattern,
2663
+ parameter_type. clone ( ) ,
2664
+ DefinitionKind :: Local ( None ) ,
2665
+ & mut parameter_idents,
2666
+ true , // warn_if_unused
2667
+ )
2668
+ } )
2645
2669
} ) ;
2646
2670
2647
2671
parameters. push ( ( hir_pattern, parameter_type. clone ( ) , Visibility :: Private ) ) ;
@@ -2750,20 +2774,18 @@ fn module_add_item(
2750
2774
let top_level_statements = parse ( interpreter. elaborator , item, parser, "a top-level item" ) ?;
2751
2775
2752
2776
interpreter. elaborate_in_module ( module_id, |elaborator| {
2753
- let previous_errors = elaborator
2754
- . push_elaborate_reason_and_take_errors ( ElaborateReason :: AddingItemToModule , location) ;
2755
-
2756
- let mut generated_items = CollectedItems :: default ( ) ;
2777
+ let reason = ElaborateReason :: EvaluatingComptimeCall ( "Module::add_item" , location) ;
2778
+ elaborator. with_elaborate_reason ( reason, |elaborator| {
2779
+ let mut generated_items = CollectedItems :: default ( ) ;
2757
2780
2758
- for top_level_statement in top_level_statements {
2759
- elaborator. add_item ( top_level_statement, & mut generated_items, location) ;
2760
- }
2761
-
2762
- if !generated_items. is_empty ( ) {
2763
- elaborator. elaborate_items ( generated_items) ;
2764
- }
2781
+ for top_level_statement in top_level_statements {
2782
+ elaborator. add_item ( top_level_statement, & mut generated_items, location) ;
2783
+ }
2765
2784
2766
- elaborator. pop_elaborate_reason ( previous_errors) ;
2785
+ if !generated_items. is_empty ( ) {
2786
+ elaborator. elaborate_items ( generated_items) ;
2787
+ }
2788
+ } ) ;
2767
2789
} ) ;
2768
2790
2769
2791
Ok ( Value :: Unit )
0 commit comments