Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not ICE when synthesizing spans falling inside unicode chars #63508

Merged
merged 3 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libsyntax/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,14 @@ impl SourceMap {
}

if let Some(ref src) = local_begin.sf.src {
if !src.is_char_boundary(start_index) || !src.is_char_boundary(end_index) {
return Err(SpanSnippetError::IllFormedSpan(sp));
}
return Ok(extract_source(src, start_index, end_index));
} else if let Some(src) = local_begin.sf.external_src.borrow().get_source() {
if !src.is_char_boundary(start_index) || !src.is_char_boundary(end_index) {
return Err(SpanSnippetError::IllFormedSpan(sp));
}
return Ok(extract_source(src, start_index, end_index));
estebank marked this conversation as resolved.
Show resolved Hide resolved
} else {
return Err(SpanSnippetError::SourceNotAvailable {
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/suggestions/issue-61226.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct X {}
fn main() {
vec![X]; //…
//~^ ERROR expected value, found struct `X`
}
9 changes: 9 additions & 0 deletions src/test/ui/suggestions/issue-61226.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0423]: expected value, found struct `X`
--> $DIR/issue-61226.rs:3:10
|
LL | vec![X]; //…
| ^ did you mean `X { /* fields */ }`?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0423`.