Skip to content

Bad file/lines in error (assert/fail/alt check) messages from inline functions #1972

Closed
@marijnh

Description

@marijnh

Spans of inlined things currently end up pointing at the start of the crate file. This makes them quite useless and confusing.

Example (adapted from pnkfelix's comments below):

% cat -n /tmp/foo.rs
     1  #[link(name="foo", vers="0.0")];
     2  
     3  #[inline(always)]
     4  pub fn access_inline_always(a: &[int], i: uint) -> int {
     5      info!("foo::access_inline_always");
     6      a[i]
     7  }
     8  
     9  #[inline(never)]
    10  pub fn access_inline_never(a: &[int], i: uint) -> int {
    11      info!("foo::access_inline_never");
    12      a[i]
    13  }
% cat -n /tmp/bar.rs
     1  extern mod foo;
     2  
     3  fn main() {
     4      let arr = [1, 2, 3];
     5      let a_0 = foo::access_inline_never(arr, 0);
     6      let a_1 = foo::access_inline_always(arr, 1);
     7      println(format!("arr[0]: {:?} arr[1]: {:?}", a_0, a_1));
     8      let a_4 = foo::access_inline_always(arr, 4);
     9      println(format!("arr[4]: {:?}", a_4));
    10  }
% rustc --cfg debug --lib /tmp/foo.rs
warning: no debug symbols in executable (-arch x86_64)
% rustc -L/tmp /tmp/bar.rs
warning: no debug symbols in executable (-arch x86_64)
% RUST_LOG=foo /tmp/bar
"foo::access_inline_never"
"foo::access_inline_always"
arr[0]: 1 arr[1]: 2
"foo::access_inline_always"
task '<unnamed>' failed at 'index out of bounds: the len is 3 but the index is 4', /tmp/bar.rs:1

Note that the error message points one to /tmp/bar.rs:1 but it should probably point at the vector access itself at line foo.rs:6

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsP-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions