Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit 9e4ba10

Browse files
committed
Merge pull request #207 from birkenfeld/new-error-format
Use new rustc error format.
2 parents d823f81 + 73cca0e commit 9e4ba10

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

bin/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -o errexit
44

5-
TERM=xterm rustc - -o ./out "$@"
5+
RUST_NEW_ERROR_FORMAT=1 TERM=xterm rustc - -o ./out "$@"
66
printf '\377' # 255 in octal
77
exec cat out

bin/evaluate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -o errexit
44

5-
TERM=xterm rustc - -o ./out "$@"
5+
RUST_NEW_ERROR_FORMAT=1 TERM=xterm rustc - -o ./out "$@"
66
printf '\377' # 255 in octal
77
if [ "${*#*--test}" != "$*" ] && [ "${*#*--color=always}" != "$*" ]; then
88
# For /evaluate.json, we have {test: true, color: true}. Let's make the

static/web.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,23 @@
576576
" class=\"linejump\">" + text + "</a>";
577577
}
578578

579+
//Similarly to jumpToLine, except this one acts on eg. "<anon>:2:31"
580+
function jumpToPoint(text, r1,c1) {
581+
return "<a onclick=\"javascript:editGo("+r1+","+c1+")\"" +
582+
" onmouseover=\"javascript:editShowPoint("+r1+","+c1+")\"" +
583+
" onmouseout=\"javascript:editRestore()\"" +
584+
" class=\"linejump\">" + text + "</a>";
585+
}
586+
579587
function formatCompilerOutput(text) {
580-
return ansi2html(text).replace(/\[(E\d\d\d\d)\]/g, function(text, code) {
581-
return "[<a href=https://doc.rust-lang.org/error-index.html#" + code + ">" + code + "</a>]";
588+
return ansi2html(text).replace(/\[(--explain )?(E\d\d\d\d)\]/g, function(text, prefix, code) {
589+
return "[<a href=https://doc.rust-lang.org/error-index.html#" + code + ">" + prefix + code + "</a>]";
582590
}).replace(/run `rustc --explain (E\d\d\d\d)` to see a detailed explanation/g, function(text, code) {
583591
return "see the <a href=https://doc.rust-lang.org/error-index.html#" + code + ">detailed explanation for " + code + "</a>";
584592
}).replace(/&lt;anon&gt;:(\d+)$/mg, jumpToLine) // panicked at 'foo', $&
585593
.replace(/^&lt;anon&gt;:(\d+):(\d+):\s+(\d+):(\d+)/mg, jumpToRegion)
586-
.replace(/^&lt;anon&gt;:(\d+)/mg, jumpToLine);
594+
.replace(/^&lt;anon&gt;:(\d+)/mg, jumpToLine)
595+
.replace(/&lt;anon&gt;:(\d+):(\d+)/mg, jumpToPoint); // new errors
587596
}
588597

589598
addEventListener("DOMContentLoaded", function() {
@@ -830,3 +839,14 @@ function editShowLine(r1) {
830839
es.moveCursorLineEnd();
831840
es.selectTo(r1-1, 0);
832841
}
842+
843+
function editShowPoint(r1,c1) {
844+
var e = editorGet();
845+
var es = e.selection;
846+
old_range = es.getRange();
847+
es.clearSelection();
848+
e.scrollToLine(r1, true, true);
849+
es.moveCursorTo(r1-1, 0);
850+
es.moveCursorLineEnd();
851+
es.selectTo(r1-1, c1-1);
852+
}

0 commit comments

Comments
 (0)