@@ -506,20 +506,22 @@ impl Module {
506
506
507
507
DefDiagnosticKind :: UnconfiguredCode { ast, cfg, opts } => {
508
508
let item = ast. to_node ( db. upcast ( ) ) ;
509
- sink. push ( InactiveCode {
510
- file : ast. file_id ,
511
- node : AstPtr :: new ( & item) . into ( ) ,
512
- cfg : cfg. clone ( ) ,
513
- opts : opts. clone ( ) ,
514
- } ) ;
509
+ acc. push (
510
+ InactiveCode {
511
+ node : ast. with_value ( AstPtr :: new ( & item) . into ( ) ) ,
512
+ cfg : cfg. clone ( ) ,
513
+ opts : opts. clone ( ) ,
514
+ }
515
+ . into ( ) ,
516
+ ) ;
515
517
}
516
518
517
519
DefDiagnosticKind :: UnresolvedProcMacro { ast } => {
518
520
let mut precise_location = None ;
519
- let ( file , ast , name) = match ast {
521
+ let ( node , name) = match ast {
520
522
MacroCallKind :: FnLike { ast_id, .. } => {
521
523
let node = ast_id. to_node ( db. upcast ( ) ) ;
522
- ( ast_id. file_id , SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) , None )
524
+ ( ast_id. with_value ( SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) ) , None )
523
525
}
524
526
MacroCallKind :: Derive { ast_id, derive_name, .. } => {
525
527
let node = ast_id. to_node ( db. upcast ( ) ) ;
@@ -552,8 +554,7 @@ impl Module {
552
554
}
553
555
554
556
(
555
- ast_id. file_id ,
556
- SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) ,
557
+ ast_id. with_value ( SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) ) ,
557
558
Some ( derive_name. clone ( ) ) ,
558
559
)
559
560
}
@@ -564,18 +565,14 @@ impl Module {
564
565
|| panic ! ( "cannot find attribute #{}" , invoc_attr_index) ,
565
566
) ;
566
567
(
567
- ast_id. file_id ,
568
- SyntaxNodePtr :: from ( AstPtr :: new ( & attr) ) ,
568
+ ast_id. with_value ( SyntaxNodePtr :: from ( AstPtr :: new ( & attr) ) ) ,
569
569
Some ( attr_name. clone ( ) ) ,
570
570
)
571
571
}
572
572
} ;
573
- sink. push ( UnresolvedProcMacro {
574
- file,
575
- node : ast,
576
- precise_location,
577
- macro_name : name,
578
- } ) ;
573
+ acc. push (
574
+ UnresolvedProcMacro { node, precise_location, macro_name : name } . into ( ) ,
575
+ ) ;
579
576
}
580
577
581
578
DefDiagnosticKind :: UnresolvedMacroCall { ast, path } => {
@@ -590,19 +587,19 @@ impl Module {
590
587
}
591
588
592
589
DefDiagnosticKind :: MacroError { ast, message } => {
593
- let ( file , ast ) = match ast {
590
+ let node = match ast {
594
591
MacroCallKind :: FnLike { ast_id, .. } => {
595
592
let node = ast_id. to_node ( db. upcast ( ) ) ;
596
- ( ast_id. file_id , SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) )
593
+ ast_id. with_value ( SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) )
597
594
}
598
595
MacroCallKind :: Derive { ast_id, .. }
599
596
| MacroCallKind :: Attr { ast_id, .. } => {
600
597
// FIXME: point to the attribute instead, this creates very large diagnostics
601
598
let node = ast_id. to_node ( db. upcast ( ) ) ;
602
- ( ast_id. file_id , SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) )
599
+ ast_id. with_value ( SyntaxNodePtr :: from ( AstPtr :: new ( & node) ) )
603
600
}
604
601
} ;
605
- sink . push ( MacroError { file , node : ast , message : message. clone ( ) } ) ;
602
+ acc . push ( MacroError { node, message : message. clone ( ) } . into ( ) ) ;
606
603
}
607
604
608
605
DefDiagnosticKind :: UnimplementedBuiltinMacro { ast } => {
@@ -1045,23 +1042,25 @@ impl Function {
1045
1042
let source_map = db. body_with_source_map ( self . id . into ( ) ) . 1 ;
1046
1043
for diag in source_map. diagnostics ( ) {
1047
1044
match diag {
1048
- BodyDiagnostic :: InactiveCode { node, cfg, opts } => sink. push ( InactiveCode {
1049
- file : node. file_id ,
1050
- node : node. value . clone ( ) ,
1051
- cfg : cfg. clone ( ) ,
1052
- opts : opts. clone ( ) ,
1053
- } ) ,
1054
- BodyDiagnostic :: MacroError { node, message } => sink. push ( MacroError {
1055
- file : node. file_id ,
1056
- node : node. value . clone ( ) . into ( ) ,
1057
- message : message. to_string ( ) ,
1058
- } ) ,
1059
- BodyDiagnostic :: UnresolvedProcMacro { node } => sink. push ( UnresolvedProcMacro {
1060
- file : node. file_id ,
1061
- node : node. value . clone ( ) . into ( ) ,
1062
- precise_location : None ,
1063
- macro_name : None ,
1064
- } ) ,
1045
+ BodyDiagnostic :: InactiveCode { node, cfg, opts } => acc. push (
1046
+ InactiveCode { node : node. clone ( ) , cfg : cfg. clone ( ) , opts : opts. clone ( ) }
1047
+ . into ( ) ,
1048
+ ) ,
1049
+ BodyDiagnostic :: MacroError { node, message } => acc. push (
1050
+ MacroError {
1051
+ node : node. clone ( ) . map ( |it| it. into ( ) ) ,
1052
+ message : message. to_string ( ) ,
1053
+ }
1054
+ . into ( ) ,
1055
+ ) ,
1056
+ BodyDiagnostic :: UnresolvedProcMacro { node } => acc. push (
1057
+ UnresolvedProcMacro {
1058
+ node : node. clone ( ) . map ( |it| it. into ( ) ) ,
1059
+ precise_location : None ,
1060
+ macro_name : None ,
1061
+ }
1062
+ . into ( ) ,
1063
+ ) ,
1065
1064
BodyDiagnostic :: UnresolvedMacroCall { node, path } => acc. push (
1066
1065
UnresolvedMacroCall { macro_call : node. clone ( ) , path : path. clone ( ) } . into ( ) ,
1067
1066
) ,
0 commit comments