forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syntax: fixed ICEs and incorrect line nums when reporting Spans at th…
…e end of the file. CodeMap.span_to_* perform a lookup of a BytePos(sp.hi), which lands into the next filemap if the last byte of range denoted by Span is also the last byte of the filemap, which results in ICEs or incorrect error reports. Example: ```` pub fn main() { let mut num = 3; let refe = &mut num; *refe = 5; println!("{}", num); }```` (note the empty line in the beginning and the absence of newline at the end) The above would have caused ICE when trying to report where "refe" borrow ends. The above without an empty line in the beginning would have reported borrow end to be the first line. Most probably, this is also responsible for (at least some occurrences of) issue rust-lang#8256. The issue is fixed by always adding a newline at the end of non-empty filemaps in case there isn't a new line there already.
- Loading branch information
Showing
1 changed file
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43a8f7b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=nick29581