Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garbled compile errors when running cargo test #1717

Closed
Stebalien opened this issue Jun 15, 2015 · 1 comment
Closed

Garbled compile errors when running cargo test #1717

Stebalien opened this issue Jun 15, 2015 · 1 comment

Comments

@Stebalien
Copy link
Contributor

When compiling with cargo build, cargo forwards rustc's error messages without any issues. However, when compiling with cargo test, build errors are often garbled:

src/lib.rs:4:1: 6:2 error: duplicate definition of value `fialure`
src/lib.rs:4 fn fialure() {
src/lib.rs:5     bad;
src/lib.rs:6 }
src/lib.rs:1:1: 3:2 note: first definition of value `fialure` here
src/lib.rs:1 fn fialure() {
src/lib.rs:2     bad;
src/lib.rs:3 }
src/lib.rs:7:1: 9:2 error: duplicate definition of value `fialure`
src/lib.rs:7 fn fialure() {
src/lib.rs:8     bad;
src/lib.rs:9 }
src/lib.rs:4:1: 6:2 note: first definition of value `fialure` here
src/lib.rs:4 fn fialure() {
src/lib.rs:5     bad;
src/lib.rs:6 }
src/lib.rs:10:1: 12:2 error: duplicate definition of value `fialure`
src/lib.rs:10 fn fialure() {
src/lib.rs:11     bad;
src/lib.rs:12 }
src/lib.rs:7:1: 9:2 note: first definition of value `fialure` here
src/lib.rs:7 fn fialure() {
src/lib.rs:8     bad;
src/lib.rs:9 }
src/lib.rs:13:1: 15:2 error: duplicate definition of value `fialure`
src/lib.rs:13 fn fialure() {
src/lib.rs:14     bad;
src/lib.rs:15 }
src/lib.rs:10:1: 12:2 note: first definition of value `fialure` here
src/lib.rs:10 fn fialure() {
src/lib.rs:11     bad;
src/lib.rs:12 }
src/lib.rs:4:1: 6:2 src/lib.rs:16:1: 18:2 error: error: duplicate definition of value `fialure`duplicate definition of value `fialure`

src/lib.rssrc/lib.rs::416 fn fialure() { 
fn fialure() {src/lib.rs:
5 src/lib.rs    bad;
:src/lib.rs17:6  }    bad;

src/lib.rssrc/lib.rs:1:1: 3:2 :18note:  }
first definition of value `fialure` heresrc/lib.rs:13:1: 15:2
src/lib.rs :1 fn fialure() {note: 
src/lib.rs:2first definition of value `fialure` here     bad;
src/lib.rs:
3 }src/lib.rs:
13src/lib.rs:7:1: 9:2 fn fialure() { 
error: src/lib.rs:14duplicate definition of value `fialure`     bad;

src/lib.rssrc/lib.rs::715 fn fialure() { 
src/lib.rs}:8
     bad;
src/lib.rssrc/lib.rs:19:1: 21:2:9  }
src/lib.rs:4:1: 6:2error:  note: duplicate definition of value `fialure`first definition of value `fialure` here

src/lib.rssrc/lib.rs:4: fn fialure() {19
src/lib.rs: 5fn fialure() {
 src/lib.rs    bad;
:20src/lib.rs :6    bad; }

src/lib.rs:src/lib.rs:10:1: 12:221  }error: 
src/lib.rs:16:1: 18:2duplicate definition of value `fialure` 
src/lib.rs:note: 10 fn fialure() {
first definition of value `fialure` heresrc/lib.rs:11
     bad;
src/lib.rs:src/lib.rs:1612  }
fn fialure() {src/lib.rs:7:1: 9:2 
src/lib.rsnote: :17 first definition of value `fialure` here    bad;

src/lib.rssrc/lib.rs::718 fn fialure() { 
}src/lib.rs:
8     bad;
src/lib.rs:22:1: 24:2src/lib.rs: 9 }
error: src/lib.rs:13:1: 15:2 duplicate definition of value `fialure`error: 
duplicate definition of value `fialure`src/lib.rs
:src/lib.rs22:13  fn fialure() {fn fialure() {
src/lib.rs
:14src/lib.rs     bad;:
src/lib.rs23:15  }    bad;

src/lib.rs:10:1: 12:2 src/lib.rs:note: 24 }first definition of value `fialure` here

src/lib.rs:19:1: 21:2src/lib.rs: 10 fn fialure() {
note: src/lib.rs:11     bad;first definition of value `fialure` here
src/lib.rs:
12 }src/lib.rs
:19src/lib.rs:16:1: 18:2  fn fialure() {error: 
src/lib.rs:duplicate definition of value `fialure`20 
src/lib.rs    bad;:
16 src/lib.rsfn fialure() {
:src/lib.rs:2117      bad;
}src/lib.rs:
18 }
src/lib.rs:25:1: 27:2src/lib.rs:13:1: 15:2  note: error: first definition of value `fialure` here
src/lib.rsduplicate definition of value `fialure`:13 
fn fialure() {
src/lib.rssrc/lib.rs::1425     bad; 
src/lib.rsfn fialure() {:15
 }src/lib.rs
:src/lib.rs:19:1: 21:226  error:     bad;
src/lib.rsduplicate definition of value `fialure`:27
src/lib.rs }:19
 fn fialure() {
src/lib.rssrc/lib.rs:22:1: 24:2: 20     bad;
note: src/lib.rs:21 }
first definition of value `fialure` heresrc/lib.rs:16:1: 18:2 
note: src/lib.rs:first definition of value `fialure` here22 
src/lib.rsfn fialure() {:
16 src/lib.rsfn fialure() {
:src/lib.rs:2317      bad;
    bad;src/lib.rs:
18 src/lib.rs}
:24src/lib.rs:22:1: 24:2  }error: 
duplicate definition of value `fialure`
error: src/lib.rs:22 aborting due to 8 previous errorsfn fialure() {
src/lib.rs:
23     bad;
src/lib.rs:24 }
src/lib.rs:19:1: 21:2 note: first definition of value `fialure` here
src/lib.rs:19 fn fialure() {
src/lib.rs:20     bad;
src/lib.rs:21 }
src/lib.rs:25:1: 27:2 error: duplicate definition of value `fialure`
src/lib.rs:25 fn fialure() {
src/lib.rs:26     bad;
src/lib.rs:27 }
src/lib.rs:22:1: 24:2 note: first definition of value `fialure` here
src/lib.rs:22 fn fialure() {
src/lib.rs:23     bad;
src/lib.rs:24 }
error: aborting due to 8 previous errors
Build failed, waiting for other jobs to finish...
Could not compile `tmp`.

To learn more, run the command again with --verbose.

Test code (intentionally broken):

fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
fn fialure() {
    bad;
}
#[test]
fn it_works() {
    failure()
}

rustc --test does not exhibit the same behavior.

@alexcrichton
Copy link
Member

Thanks for the report! What's actually happening here is that the library is being compiled twice (once with --test and once for doc tests later on), and this is a dupe of #1534 and #851. This is intended behavior though, and you can use various flags like --test, --lib, or -j to not run rustc in parallel, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants