diff options
| author | kennytm <kennytm@gmail.com> | 2018-02-01 02:26:48 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-02-01 02:26:48 +0800 |
| commit | 68135d1936f6c19529136d1de3515412a1056fb2 (patch) | |
| tree | 04166e4d6a46e239987b0846c5603536b916951a /src/rustllvm/RustWrapper.cpp | |
| parent | 64fc9d2b9e7c64f8eff6c8464406d62cbf1ea6ac (diff) | |
| parent | c6377f8e17cd7f3cf906397f3f48b522b0521471 (diff) | |
| download | rust-68135d1936f6c19529136d1de3515412a1056fb2.tar.gz rust-68135d1936f6c19529136d1de3515412a1056fb2.zip | |
Rollup merge of #47677 - etaoins:avoid-underflow-in-rennder-source-line, r=estebank
Avoid underflow in render_source_line While testing rust-lang/rust#47655 I was able to make the compiler panic when it's compiled with debug assertions: ```shell > rustc /dev/null --crate-type proc-macro error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.25.0-dev running on x86_64-apple-darwin note: run with `RUST_BACKTRACE=1` for a backtrace thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49 ``` Without debug assertions the following warning is emitted: ```shell > rustc /dev/null --crate-type proc-macro warning: unused variable: `registrar` --> /dev/null:0:1 | | = note: #[warn(unused_variables)] on by default = note: to avoid this warning, consider using `_registrar` instead ``` The panic is due to the unused variable warning being spanned to `/dev/null:0:1`. When `render_source_line` subtracts 1 from the line number to look up the source line it panics due to underflow. Without debug assertions this would wrap and cause us to return a blank string instead. Fix by explicitly testing for 0 and exiting early. I'm unsure how to automatically test this now that rust-lang/rust#46655 has been approved.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
