Change:
(pnkfelix says: "if you are looking at this bug, please try to keep this test up-to-date ... potentially by checking the newest linked dupes in the comment feed below.") Script to reproduce: Backtrace: Version:
I've auto-reduced this down to: thanks creduce and
Seems like something is wrong in filemap.
I can't repdrouce this no more on master branch:
It's still present with .
The core issue is: the assertion is expanded into which causes type error as expected. However, token is from macro (), while is from . They are even in different files! Here span computation goes bad, and printer tries to print wrong code area.
Was closed by typo
This also causes the issue. I believe this is the simplest case that causes it. Any fewer new lines and it stops occurring. The text is on the 13th line. You can confirm that the offset in the line doesn't matter by putting the assert! on a newline and deleting one of the new lines before the fn main().
It looks like I'm affected by this one too. Here is a non minimal test case: On Arch Linux: rustc 0.13.0-nightly ( 2014-11-02 23:27:10 +0000) binary: rustc commit-hash: commit-date: 2014-11-02 23:27:10 +0000 host: x8664-unknown-linux-gnu release: 0.13.0-nightly Full backtrace: Edit: I've fixed my code to use asserteq!(), which does not trigger the bug for me.
I'm getting this on the rust playground rustc 1.12.0, using assert!(1, 1) and also vecs.

Discussion:
/// get a line from the list of pre-computed line-beginnings /// <del> pub fn get_line(&self, line: int) -> String { </del> <ins> pub fn get_line(&self, line_number: uint) -> Option<String> { </ins> let lines = self.lines.borrow(); <del> let begin: BytePos = (*lines)[line as uint] - self.start_pos; let begin = begin.to_uint(); let slice = self.src.as_slice().slice_from(begin); match slice.find('n') { Some(e) => slice.slice_to(e).to_string(), None => slice.to_string() } </del> <ins> lines.get(line_number).map(|&line| { let begin: BytePos = line - self.start_pos; let begin = begin.to_uint(); let slice = self.src.as_slice().slice_from(begin); match slice.find('n') { Some(e) => slice.slice_to(e), None => slice }.to_string() }) </ins> } pub fn record_multibyte_char(&self, pos: BytePos, bytes: uint) {

let fm = cm.new_filemap("blork.rs".to_string(), "first line.nsecond line".to_string()); fm.next_line(BytePos(0)); <del> assert_eq!(&fm.get_line(0),&"first line.".to_string()); </del> <ins> assert_eq!(fm.get_line(0), Some("first line.".to_string())); </ins> // TESTING BROKEN BEHAVIOR: fm.next_line(BytePos(10)); <del> assert_eq!(&fm.get_line(1), &".".to_string()); </del> <ins> assert_eq!(fm.get_line(1), Some(".".to_string())); </ins> } #[test]

elided = true; } // Print the offending lines <del> for line in display_lines.iter() { try!(write!(&mut err.dst, "{}:{} {}n", fm.name, *line + 1, fm.get_line(*line as int))); </del> <ins> for &line_number in display_lines.iter() { if let Some(line) = fm.get_line(line_number) { try!(write!(&mut err.dst, "{}:{} {}n", fm.name, line_number + 1, line)); } </ins> } if elided { let last_line = display_lines[display_lines.len() - 1u];

for _ in range(0, skip) { s.push(' '); } <del> let orig = fm.get_line(lines.lines[0] as int); for pos in range(0u, left-skip) { let cur_char = orig.as_bytes()[pos] as char; // Whenever a tab occurs on the previous line, we insert one on // the error-point-squiggly-line as well (instead of a space). // That way the squiggly line will usually appear in the correct // position. match cur_char { 't' => s.push('t'), _ => s.push(' '), }; </del> <ins> if let Some(orig) = fm.get_line(lines.lines[0]) { for pos in range(0u, left - skip) { let cur_char = orig.as_bytes()[pos] as char; // Whenever a tab occurs on the previous line, we insert one on // the error-point-squiggly-line as well (instead of a space). // That way the squiggly line will usually appear in the correct // position. match cur_char { 't' => s.push('t'), _ => s.push(' '), }; } </ins> } try!(write!(&mut err.dst, "{}", s)); let mut s = String::from_str("^"); let hi = cm.lookup_char_pos(sp.hi); if hi.col != lo.col { // the ^ already takes up one space <del> let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u; </del> <ins> let num_squigglies = hi.col.to_uint() - lo.col.to_uint() - 1u; </ins> for _ in range(0, num_squigglies) { s.push('~'); }

let lines = lines.lines.as_slice(); if lines.len() > MAX_LINES { <del> try!(write!(&mut w.dst, "{}:{} {}n", fm.name, lines[0] + 1, fm.get_line(lines[0] as int))); </del> <ins> if let Some(line) = fm.get_line(lines[0]) { try!(write!(&mut w.dst, "{}:{} {}n", fm.name, lines[0] + 1, line)); } </ins> try!(write!(&mut w.dst, "...n")); <del> let last_line = lines[lines.len()-1]; try!(write!(&mut w.dst, "{}:{} {}n", fm.name, last_line + 1, fm.get_line(last_line as int))); } else { for line in lines.iter() { </del> <ins> let last_line_number = lines[lines.len() - 1]; if let Some(last_line) = fm.get_line(last_line_number) { </ins> try!(write!(&mut w.dst, "{}:{} {}n", fm.name, <del> *line + 1, fm.get_line(*line as int))); </del> <ins> last_line_number + 1, last_line)); } } else { for &line_number in lines.iter() { if let Some(line) = fm.get_line(line_number) { try!(write!(&mut w.dst, "{}:{} {}n", fm.name, line_number + 1, line)); } </ins> } } let last_line_start = format!("{}:{} ", fm.name, lines[lines.len()-1]+1);

<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern: cannot apply unary operator `!` to type `BytePos` // Very // sensitive pub struct BytePos(pub u32); // to particular // line numberings / offsets fn main() { let x = BytePos(1); assert!(x, x); } </ins>

<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern: expected `bool`, found `_` (expected bool, found integral variable) fn main(){assert!(1,1);} </ins>