Skip to content

Stop prepending the path and line number to every line in error messages #3533

Closed
@bstrie

Description

@bstrie

For the sake of people with 80-character terminals, Rust code is limited to 78 characters in width. So why do error messages on 80-character terminals look like this:

/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:24:0: 29:1 wa
rning: type, variant, or trait must be camel case
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:24 trait file
search {
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:25     fn sys
root() -> Path;
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:26     fn lib
_search_paths() -> ~[Path];
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:27     fn get
_target_lib_path() -> Path;
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:28     fn get
_target_lib_file_path(file: &Path) -> Path;
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs:29 }

This is a pathological case, but I still manage to hit this frequently even though my term is often well wider than 80 characters.

Here's how Java formats its error messages:

jello.java:3: cannot find symbol
symbol  : variable Exception
location: class jello
        throw Exception;
              ^
1 error

Taking inspiration from this, Rust error messages could instead look like:

Warning: type, variant, or trait must be camel case
/home/ben/code/rust-projects/rust/src/rustc/metadata/filesearch.rs 24:0-29:1
trait filesearch {
    fn sysroot() -> Path;
    fn lib_search_paths() -> ~[Path];
    fn get_target_lib_path() -> Path;
    fn get_target_lib_file_path(file: &Path) -> Path;
}

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions