Issue 1:
I was building this repo: https://github.com/pistondevelopers/gfx_graphics

using this command: cargo run --example image test

and got this backtrace:

Compiling piston2d-gfx_graphics v0.1.7 (~/Documents/code/rust/gfx_graphics)
examples/imagetest.rs:42:10: 42:19 warning: use of deprecated item: use std::path instead, #[warn(deprecated)] on by default
examples/imagetest.rs:42 &Path::new("./assets/rust.png")).unwrap();
^~~~~~~~~
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'arithmetic operation overflowed', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/codemap.rs:73

stack backtrace:
1: 0x1078afd1b - sys::backtrace::write::h3b83b15177f4f6b5fCC
2: 0x1078d8afd - panicking::on_panic::h77e742d34f7c8b14DsI
3: 0x1077f8b37 - rt::unwind::begin_unwind_inner::h8c5748c6ec61f668EbI
4: 0x1077f930e - rt::unwind::begin_unwind_fmt::h09f57cab0d3c2b0cfaI
5: 0x1078d85bd - rust_begin_unwind
6: 0x107928325 - panicking::panic_fmt::h81bb86f758192917ZSs
7: 0x1079202e7 - panicking::panic::h67ccdd3fa7b140bcbRs
8: 0x106f67aaf - codemap::BytePos.Sub::sub::ha963a332df6226d2X7y
9: 0x10479fa30 - middle::astencode::DecodeContext<'a, 'b, 'tcx>::tr_span::ha609caf2be923751UBa
10: 0x1047b1bb4 - fold::noop_fold_expr::h6052110651558964661
11: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
12: 0x1047b5385 - fold::noop_fold_expr::closure.65772
13: 0x1047b200d - fold::noop_fold_expr::h6052110651558964661
14: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
15: 0x1047b5385 - fold::noop_fold_expr::closure.65772
16: 0x1047b200d - fold::noop_fold_expr::h6052110651558964661
17: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
18: 0x1047b5385 - fold::noop_fold_expr::closure.65772
19: 0x1047b1dea - fold::noop_fold_expr::h6052110651558964661
20: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
21: 0x1047b27d8 - fold::noop_fold_expr::h6052110651558964661
22: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
23: 0x1047b5322 - fold::noop_fold_expr::closure.65767
24: 0x1047b9b5d - fold::noop_fold_local::closure.65998
25: 0x1047b9558 - fold::noop_fold_decl::closure.65995
26: 0x1047b7631 - fold::Folder::fold_stmt::closure.65925
27: 0x1047b6ded - fold::noop_fold_block::closure.65876
28: 0x1047b6a21 - iter::FlatMap<I, U, F>.Iterator::next::h8831031901394782976
29: 0x1047b61ef - vec::Vec<T>.FromIterator<T>::from_iter::h390922894093893598
30: 0x1047b5b04 - fold::noop_fold_block::closure.65785
31: 0x1047b558a - fold::noop_fold_block::h2848417533559784555
32: 0x1047b2cc4 - fold::noop_fold_expr::h6052110651558964661
33: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
34: 0x1047b753f - fold::Folder::fold_stmt::closure.65925
35: 0x1047b6ded - fold::noop_fold_block::closure.65876
36: 0x1047b6a21 - iter::FlatMap<I, U, F>.Iterator::next::h8831031901394782976
37: 0x1047b61ef - vec::Vec<T>.FromIterator<T>::from_iter::h390922894093893598
38: 0x1047b5b04 - fold::noop_fold_block::closure.65785
39: 0x1047b558a - fold::noop_fold_block::h2848417533559784555
40: 0x1047b2cc4 - fold::noop_fold_expr::h6052110651558964661
41: 0x1047b18d5 - ptr::P<T>::map::h7940627982087708418
42: 0x1047b5322 - fold::noop_fold_expr::closure.65767
43: 0x1047b5b90 - fold::noop_fold_block::closure.65785
44: 0x1047b558a - fold::noop_fold_block::h2848417533559784555
45: 0x1047d4df6 - fold::noop_fold_impl_item::closure.66340
46: 0x1047d46fd - fold::noop_fold_impl_item::h1408433769782516448
47: 0x1047a27ff - middle::astencode::decode_inlined_item::h98be5341b5740066vqa
48: 0x104363b0c - trans::inline::instantiate_inline::closure.39503
49: 0x104bc9c2f - metadata::decoder::maybe_get_item_ast::h9f3b16f53943285a3hg
50: 0x1049aeb48 - metadata::csearch::maybe_get_item_ast::hc0376cacdb4fc82fVHi
51: 0x10436236b - trans::inline::instantiate_inline::hcb4baf4731bceaee7hd
52: 0x1043b4a06 - trans::callee::trans_fn_ref_with_substs::h3dd799fcfb10c61ankg
53: 0x1043b3b84 - trans::meth::trans_static_method_callee::h87b6e738c13b7befj8x
54: 0x1043b0654 - trans::callee::trans::hebb18e30873529a9eYf
55: 0x1043c78ad - trans::callee::trans_call_inner::h11696719501217594510
56: 0x1043d54dc - trans::expr::trans_rvalue_dps_unadjusted::he9f6005922fd4409xzi
57: 0x1043d2e0c - trans::expr::trans_unadjusted::h9175a3adfcc3bf5723h
58: 0x104383f5b - trans::expr::trans::h95e8c24c95ef80fcath
59: 0x104483bae - trans::_match::trans_match_inner::hb05eebe09d542d345Ew
60: 0x1043d48d3 - trans::expr::trans_rvalue_dps_unadjusted::he9f6005922fd4409xzi
61: 0x1043823c6 - trans::expr::trans_into::h3e47f96968378458Smh
62: 0x10449db76 - trans::_match::mk_binding_alloca::h6146964086414757799
63: 0x104381830 - trans::base::init_local::h0459eb09a8f2f5e3Vys
64: 0x1043831e2 - trans::controlflow::trans_block::hec4993ebaa40ee52t6d
65: 0x104462739 - trans::base::trans_closure::h1c51c7ed964051ddRjt
66: 0x10436a895 - trans::base::trans_fn::hd22a8a4bf4f7572dKut
67: 0x10436c022 - trans::monomorphize::monomorphic_fn::hc946d75d050bcc6e2td
68: 0x1043b4bbb - trans::callee::trans_fn_ref_with_substs::h3dd799fcfb10c61ankg
69: 0x1043b314e - trans::callee::trans_fn_ref::h2efc8153c5a2595dX8f
70: 0x1043b0810 - trans::callee::trans::hebb18e30873529a9eYf
71: 0x1043c78ad - trans::callee::trans_call_inner::h11696719501217594510
72: 0x1043d54dc - trans::expr::trans_rvalue_dps_unadjusted::he9f6005922fd4409xzi
73: 0x1043d2e0c - trans::expr::trans_unadjusted::h9175a3adfcc3bf5723h
74: 0x104383f5b - trans::expr::trans::h95e8c24c95ef80fcath
75: 0x1043c2e11 - trans::callee::trans_args::he2b83edef17c4356F0g
76: 0x1043ca547 - trans::callee::trans_call_inner::h37094392144590770
77: 0x1043d405a - trans::expr::trans_rvalue_dps_unadjusted::he9f6005922fd4409xzi
78: 0x1043823c6 - trans::expr::trans_into::h3e47f96968378458Smh
79: 0x10449db76 - trans::_match::mk_binding_alloca::h6146964086414757799
80: 0x104381830 - trans::base::init_local::h0459eb09a8f2f5e3Vys
81: 0x1043831e2 - trans::controlflow::trans_block::hec4993ebaa40ee52t6d
82: 0x104462739 - trans::base::trans_closure::h1c51c7ed964051ddRjt
83: 0x10436a895 - trans::base::trans_fn::hd22a8a4bf4f7572dKut
84: 0x10436c022 - trans::monomorphize::monomorphic_fn::hc946d75d050bcc6e2td
85: 0x1043b4bbb - trans::callee::trans_fn_ref_with_substs::h3dd799fcfb10c61ankg
86: 0x1043b314e - trans::callee::trans_fn_ref::h2efc8153c5a2595dX8f
87: 0x1043b0810 - trans::callee::trans::hebb18e30873529a9eYf
88: 0x1043c78ad - trans::callee::trans_call_inner::h11696719501217594510
89: 0x1043d54dc - trans::expr::trans_rvalue_dps_unadjusted::he9f6005922fd4409xzi
90: 0x1043823c6 - trans::expr::trans_into::h3e47f96968378458Smh
91: 0x10449db76 - trans::_match::mk_binding_alloca::h6146964086414757799
92: 0x104381830 - trans::base::init_local::h0459eb09a8f2f5e3Vys
93: 0x1043831e2 - trans::controlflow::trans_block::hec4993ebaa40ee52t6d
94: 0x104462739 - trans::base::trans_closure::h1c51c7ed964051ddRjt
95: 0x10436a895 - trans::base::trans_fn::hd22a8a4bf4f7572dKut
96: 0x10436627d - trans::base::trans_item::hb9b1cc2d4ac9a43fCSt
97: 0x10446b9db - trans::base::trans_crate::h162d55e78175069bfPu
98: 0x103dc1007 - driver::phase_4_translate_to_llvm::he30ee8c0cb343082kOa
99: 0x103d9cd5a - driver::compile_input::h17478feb88f6e172Rba
100: 0x103e5d193 - run_compiler::he252d03d9462df9cx2b
... <frames omitted>

Issue 2:
https://travis-ci.org/GuillaumeGomez/rust-GSL/builds/53335854

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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'arithmetic operation overflowed', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/codemap.rs:73

stack backtrace:
1: 0x7fd52b3bcf6f - sys::backtrace::write::h2f046b875b210aadOBA
2: 0x7fd52b3e7c82 - panicking::on_panic::h792ac47fb8c07faehHJ
3: 0x7fd52b31cf2a - rt::unwind::begin_unwind_inner::hbffac672008352c8knJ
4: 0x7fd52b31d641 - rt::unwind::begin_unwind_fmt::hbe64affaa986f482VlJ
5: 0x7fd52b3e7807 - rust_begin_unwind
6: 0x7fd52b433114 - panicking::panic_fmt::h81cd96819f02da8dIZs
7: 0x7fd52b42f53d - panicking::panic::h8ea414638b29b322UXs
8: 0x7fd5286f98ac - codemap::BytePos.Sub::sub::h13c0a0f10f07c348YWB
9: 0x7fd529035ec0 - middle::astencode::DecodeContext<'a, 'b, 'tcx>::tr_span::hdd7910e968f71d01FCa
10: 0x7fd52904679c - fold::noop_fold_expr::h1258022642513463166
11: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
12: 0x7fd529049c9e - fold::noop_fold_expr::closure.66610
13: 0x7fd5290469e1 - fold::noop_fold_expr::h1258022642513463166
14: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
15: 0x7fd529049c9e - fold::noop_fold_expr::closure.66610
16: 0x7fd529046bbe - fold::noop_fold_expr::h1258022642513463166
17: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
18: 0x7fd529049c4b - fold::noop_fold_expr::closure.66605
19: 0x7fd52904e0a4 - fold::noop_fold_local::closure.66836
20: 0x7fd52904da97 - fold::noop_fold_decl::closure.66833
21: 0x7fd52904bc9b - fold::Folder::fold_stmt::closure.66763
22: 0x7fd52904b553 - fold::noop_fold_block::closure.66714
23: 0x7fd52904b208 - iter::FlatMap<I, U, F>.Iterator::next::h9223681505759829108
24: 0x7fd52904a9cf - vec::Vec<T>.FromIterator<T>::from_iter::h13016817088923062838
25: 0x7fd52904a295 - fold::noop_fold_block::closure.66623
26: 0x7fd529049e32 - fold::noop_fold_block::h14827012078068820658
27: 0x7fd529047873 - fold::noop_fold_expr::h1258022642513463166
28: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
29: 0x7fd529049c4b - fold::noop_fold_expr::closure.66605
30: 0x7fd52904a327 - fold::noop_fold_block::closure.66623
31: 0x7fd529049e32 - fold::noop_fold_block::h14827012078068820658
32: 0x7fd529047873 - fold::noop_fold_expr::h1258022642513463166
33: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
34: 0x7fd52904c176 - fold::Folder::fold_stmt::closure.66763
35: 0x7fd52904b553 - fold::noop_fold_block::closure.66714
36: 0x7fd52904b208 - iter::FlatMap<I, U, F>.Iterator::next::h9223681505759829108
37: 0x7fd52904a9cf - vec::Vec<T>.FromIterator<T>::from_iter::h13016817088923062838
38: 0x7fd52904a295 - fold::noop_fold_block::closure.66623
39: 0x7fd529049e32 - fold::noop_fold_block::h14827012078068820658
40: 0x7fd529046f87 - fold::noop_fold_expr::h1258022642513463166
41: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
42: 0x7fd52904bb9b - fold::Folder::fold_stmt::closure.66763
43: 0x7fd52904b553 - fold::noop_fold_block::closure.66714
44: 0x7fd52904b208 - iter::FlatMap<I, U, F>.Iterator::next::h9223681505759829108
45: 0x7fd52904a9cf - vec::Vec<T>.FromIterator<T>::from_iter::h13016817088923062838
46: 0x7fd52904a295 - fold::noop_fold_block::closure.66623
47: 0x7fd529049e32 - fold::noop_fold_block::h14827012078068820658
48: 0x7fd529047873 - fold::noop_fold_expr::h1258022642513463166
49: 0x7fd5290464a3 - ptr::P<T>::map::h4462110055941524197
50: 0x7fd529049c4b - fold::noop_fold_expr::closure.66605
51: 0x7fd52904a327 - fold::noop_fold_block::closure.66623
52: 0x7fd529049e32 - fold::noop_fold_block::h14827012078068820658
53: 0x7fd529069f57 - fold::noop_fold_method::closure.67217
54: 0x7fd5290696c5 - fold::noop_fold_method::h2920979874065131956
55: 0x7fd529038abb - middle::astencode::decode_inlined_item::h674342a5ff4e1a27Pqa
56: 0x7fd52a9f81ff - trans::inline::instantiate_inline::closure.39610
57: 0x7fd529427c2b - metadata::decoder::maybe_get_item_ast::h6b38702aa8f07983PDi
58: 0x7fd52922aec6 - metadata::csearch::maybe_get_item_ast::hf5174e6ae59eb7b5o3k
59: 0x7fd52a9f6a5d - trans::inline::instantiate_inline::h6a8d7203fac7c299bid
60: 0x7fd52aa45d85 - trans::callee::trans_fn_ref_with_substs::h85a6252d422343b2qng
61: 0x7fd52aa4452e - trans::callee::trans_fn_ref::h7eebc758d7f24cf00bg
62: 0x7fd52aa5b344 - trans::meth::trans_method_callee::h175c0aff2b6fe67998x
63: 0x7fd52aa59a19 - trans::callee::trans_call_inner::h18244630176801372264
64: 0x7fd52aa638e9 - trans::expr::trans_rvalue_dps_unadjusted::h62a8f691df1cee3cqCi
65: 0x7fd52aa154e6 - trans::expr::trans_into::h3bbb0e210c9fb401Vph
66: 0x7fd52aa14684 - trans::controlflow::trans_stmt_semi::hd74052e320e3d8baK6d
67: 0x7fd52aa15fc0 - trans::controlflow::trans_block::h4b526e186a057814x7d
68: 0x7fd52aa640de - trans::expr::trans_rvalue_dps_unadjusted::h62a8f691df1cee3cqCi
69: 0x7fd52aa154e6 - trans::expr::trans_into::h3bbb0e210c9fb401Vph
70: 0x7fd52aa14684 - trans::controlflow::trans_stmt_semi::hd74052e320e3d8baK6d
71: 0x7fd52aa15fc0 - trans::controlflow::trans_block::h4b526e186a057814x7d
72: 0x7fd52aaed3b1 - trans::base::trans_closure::h194b7ad0474e43a46mt
73: 0x7fd52a9fe948 - trans::base::trans_fn::h5416ef5d9cea730bZxt
74: 0x7fd52a9fa6e1 - trans::base::trans_item::h2af153dd6f7fd52bRVt
75: 0x7fd52aaf674c - trans::base::trans_crate::h5cb53f6b3e2377862Ru
76: 0x7fd52b9f7613 - driver::phase_4_translate_to_llvm::h60575195b9fa298dENa
77: 0x7fd52b9d305b - driver::compile_input::h9772b425fd1776fdNba
78: 0x7fd52ba97697 - run_compiler::h17c28dbe4dd58e3bV5b
79: 0x7fd52ba952c9 - thunk::F.Invoke<A, R>::invoke::h3041729087284544127
80: 0x7fd52ba93f40 - rt::unwind::try::try_fn::h11775082019993619070
81: 0x7fd52b457e38 - rust_try_inner
82: 0x7fd52b457e25 - rust_try
83: 0x7fd52ba946df - thunk::F.Invoke<A, R>::invoke::h10556879288050829464
84: 0x7fd52b3d29b5 - sys::thread::thread_start::hfe8c2cac3ec4afcdr8E
85: 0x7fd52520fe99 - start_thread
86: 0x7fd52af8a4bc - <unknown>

Offending code:

impl Sub for BytePos {
type Output = BytePos;

fn sub(self, rhs: BytePos) -> BytePos {
BytePos((self.to_usize() - rhs.to_usize()) as u32)
}
}

and the code calling it:

pub fn tr_span(&self, span: Span) -> Span {
let imported_filemaps = &self.cdata.codemap_import_info[..];

let filemap_index = {
// Optimize for the case that most spans within a translated item
// originate from the same filemap.
let last_filemap_index = self.last_filemap_index.get();

if span.lo >= imported_filemaps[last_filemap_index].original_start_pos &&
span.hi <= imported_filemaps[last_filemap_index].original_end_pos {
last_filemap_index
} else {
let mut a = 0;
let mut b = imported_filemaps.len();

while b - a > 1 {
let m = (a + b) / 2;
if imported_filemaps[m].original_start_pos > span.lo {
b = m;
} else {
a = m;
}
}

self.last_filemap_index.set(a);
a
}
};

let lo = (span.lo - imported_filemaps[filemap_index].original_start_pos) +
imported_filemaps[filemap_index].translated_filemap.start_pos;
let hi = (span.hi - imported_filemaps[filemap_index].original_start_pos) +
imported_filemaps[filemap_index].translated_filemap.start_pos;

codemap::mk_sp(lo, hi)
}

We might want a bounds check there (resolving to 0?), but there seems to be something broken in the astencode code too.

cc @GuillaumeGomez @pnkfelix