File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -554,8 +554,14 @@ impl SourceMap {
554554 }
555555
556556 if let Some ( ref src) = local_begin. sf . src {
557+ if !src. is_char_boundary ( start_index) || !src. is_char_boundary ( end_index) {
558+ return Err ( SpanSnippetError :: IllFormedSpan ( sp) ) ;
559+ }
557560 return Ok ( extract_source ( src, start_index, end_index) ) ;
558561 } else if let Some ( src) = local_begin. sf . external_src . borrow ( ) . get_source ( ) {
562+ if !src. is_char_boundary ( start_index) || !src. is_char_boundary ( end_index) {
563+ return Err ( SpanSnippetError :: IllFormedSpan ( sp) ) ;
564+ }
559565 return Ok ( extract_source ( src, start_index, end_index) ) ;
560566 } else {
561567 return Err ( SpanSnippetError :: SourceNotAvailable {
Original file line number Diff line number Diff line change 1+ struct X { }
2+ fn f ( ) {
3+ vec ! [ X ] ; //…
4+ //~^ ERROR expected value, found struct `X`
5+ }
Original file line number Diff line number Diff line change 1+ error[E0423]: expected value, found struct `X`
2+ --> $DIR/issue-61226.rs:3:10
3+ |
4+ LL | vec![X]; //…
5+ | ^
6+ | |
7+ | did you mean `X { /* fields */ }`?
8+ | help: a function with a similar name exists: `f`
9+
10+ error[E0601]: `main` function not found in crate `issue_61226`
11+ |
12+ = note: consider adding a `main` function to `$DIR/issue-61226.rs`
13+
14+ error: aborting due to 2 previous errors
15+
16+ Some errors have detailed explanations: E0423, E0601.
17+ For more information about an error, try `rustc --explain E0423`.
You can’t perform that action at this time.
0 commit comments