@@ -16,7 +16,8 @@ use dependencies::{Build, BuildManager};
16
16
use lazy_static:: lazy_static;
17
17
use parser:: { ErrorMatch , MaybeSpanned , OptWithLine , Revisioned , Spanned } ;
18
18
use regex:: bytes:: { Captures , Regex } ;
19
- use rustc_stderr:: { Level , Message , Span } ;
19
+ use rustc_stderr:: { Level , Message } ;
20
+ use spanned:: Span ;
20
21
use status_emitter:: { StatusEmitter , TestStatus } ;
21
22
use std:: borrow:: Cow ;
22
23
use std:: collections:: { HashSet , VecDeque } ;
@@ -432,7 +433,7 @@ fn parse_and_test_file(
432
433
mut config : Config ,
433
434
file_contents : Vec < u8 > ,
434
435
) -> Result < Vec < TestRun > , Errored > {
435
- let comments = parse_comments ( & file_contents) ?;
436
+ let comments = parse_comments ( & file_contents, status . path ( ) ) ?;
436
437
const EMPTY : & [ String ] = & [ String :: new ( ) ] ;
437
438
// Run the test for all revisions
438
439
let revisions = comments. revisions . as_deref ( ) . unwrap_or ( EMPTY ) ;
@@ -470,8 +471,8 @@ fn parse_and_test_file(
470
471
. collect ( ) )
471
472
}
472
473
473
- fn parse_comments ( file_contents : & [ u8 ] ) -> Result < Comments , Errored > {
474
- match Comments :: parse ( file_contents) {
474
+ fn parse_comments ( file_contents : & [ u8 ] , file : & Path ) -> Result < Comments , Errored > {
475
+ match Comments :: parse ( file_contents, file ) {
475
476
Ok ( comments) => Ok ( comments) ,
476
477
Err ( errors) => Err ( Errored {
477
478
command : Command :: new ( "parse comments" ) ,
@@ -526,7 +527,7 @@ fn build_aux(
526
527
stderr : err. to_string ( ) . into_bytes ( ) ,
527
528
stdout : vec ! [ ] ,
528
529
} ) ?;
529
- let comments = parse_comments ( & file_contents) ?;
530
+ let comments = parse_comments ( & file_contents, aux_file ) ?;
530
531
assert_eq ! (
531
532
comments. revisions, None ,
532
533
"aux builds cannot specify revisions"
@@ -826,7 +827,9 @@ fn run_rustfix(
826
827
extra_args : Vec < OsString > ,
827
828
) -> Result < ( ) , Errored > {
828
829
let no_run_rustfix =
829
- comments. find_one_for_revision ( revision, "`no-rustfix` annotations" , |r| r. no_rustfix ) ?;
830
+ comments. find_one_for_revision ( revision, "`no-rustfix` annotations" , |r| {
831
+ r. no_rustfix . clone ( )
832
+ } ) ?;
830
833
831
834
let global_rustfix = match mode {
832
835
Mode :: Pass | Mode :: Run { .. } | Mode :: Panic => RustfixMode :: Disabled ,
@@ -877,7 +880,7 @@ fn run_rustfix(
877
880
let edition = comments. edition ( revision, config) ?;
878
881
let edition = edition
879
882
. map ( |mwl| {
880
- let line = mwl. span ( ) . unwrap_or ( Span :: INVALID ) ;
883
+ let line = mwl. span ( ) . unwrap_or_default ( ) ;
881
884
Spanned :: new ( mwl. into_inner ( ) , line)
882
885
} )
883
886
. into ( ) ;
@@ -886,7 +889,7 @@ fn run_rustfix(
886
889
revisioned : std:: iter:: once ( (
887
890
vec ! [ ] ,
888
891
Revisioned {
889
- span : Span :: INVALID ,
892
+ span : Span :: default ( ) ,
890
893
ignore : vec ! [ ] ,
891
894
only : vec ! [ ] ,
892
895
stderr_per_bitwidth : false ,
@@ -908,8 +911,8 @@ fn run_rustfix(
908
911
. flat_map ( |r| r. aux_builds . iter ( ) . cloned ( ) )
909
912
. collect ( ) ,
910
913
edition,
911
- mode : OptWithLine :: new ( Mode :: Pass , Span :: INVALID ) ,
912
- no_rustfix : OptWithLine :: new ( ( ) , Span :: INVALID ) ,
914
+ mode : OptWithLine :: new ( Mode :: Pass , Span :: default ( ) ) ,
915
+ no_rustfix : OptWithLine :: new ( ( ) , Span :: default ( ) ) ,
913
916
needs_asm_support : false ,
914
917
} ,
915
918
) )
@@ -1127,11 +1130,12 @@ fn check_annotations(
1127
1130
let required_annotation_level = comments. find_one_for_revision (
1128
1131
revision,
1129
1132
"`require_annotations_for_level` annotations" ,
1130
- |r| r. require_annotations_for_level ,
1133
+ |r| r. require_annotations_for_level . clone ( ) ,
1131
1134
) ?;
1132
1135
1133
- let required_annotation_level =
1134
- required_annotation_level. map_or ( lowest_annotation_level, |l| * l) ;
1136
+ let required_annotation_level = required_annotation_level
1137
+ . into_inner ( )
1138
+ . map_or ( lowest_annotation_level, |l| * l) ;
1135
1139
let filter = |mut msgs : Vec < Message > | -> Vec < _ > {
1136
1140
msgs. retain ( |msg| msg. level >= required_annotation_level) ;
1137
1141
msgs
@@ -1155,9 +1159,9 @@ fn check_annotations(
1155
1159
errors. push ( Error :: ErrorsWithoutPattern {
1156
1160
path : Some ( Spanned :: new (
1157
1161
path. to_path_buf ( ) ,
1158
- Span {
1162
+ spanned :: Span {
1159
1163
line_start : line,
1160
- ..Span :: INVALID
1164
+ ..spanned :: Span :: default ( )
1161
1165
} ,
1162
1166
) ) ,
1163
1167
msgs,
0 commit comments