diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index f46af9088d81d..041191aaf23b6 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -307,7 +307,8 @@ impl<'a> Context<'a> { format!("found possibly newer version of crate `{}`", self.ident) } else if self.rejected_via_triple.len() > 0 { - format!("found incorrect triple for crate `{}`", self.ident) + format!("couldn't find crate `{}` with expected target triple {}", + self.ident, self.triple) } else { format!("can't find crate for `{}`", self.ident) }; @@ -318,15 +319,12 @@ impl<'a> Context<'a> { }; self.sess.span_err(self.span, message.as_slice()); - let mismatches = self.rejected_via_triple.iter(); if self.rejected_via_triple.len() > 0 { - self.sess.span_note(self.span, - format!("expected triple of {}", - self.triple).as_slice()); + let mismatches = self.rejected_via_triple.iter(); for (i, &CrateMismatch{ ref path, ref got }) in mismatches.enumerate() { self.sess.fileline_note(self.span, - format!("crate `{}` path {}{}, triple {}: {}", - self.ident, "#", i+1, got, path.display()).as_slice()); + format!("crate `{}`, path #{}, triple {}: {}", + self.ident, i+1, got, path.display()).as_slice()); } } if self.rejected_via_hash.len() > 0 { diff --git a/src/test/run-make/mismatching-target-triples/Makefile b/src/test/run-make/mismatching-target-triples/Makefile new file mode 100644 index 0000000000000..e79abf822337c --- /dev/null +++ b/src/test/run-make/mismatching-target-triples/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Issue #10814 +# +# these are no_std to avoid having to have the standard library or any +# linkers/assemblers for the relevant platform + +all: + $(RUSTC) foo.rs --target=i686-unknown-linux-gnu + $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ + | grep "couldn't find crate .foo. with expected target triple x86_64-unknown-linux-gnu" diff --git a/src/test/run-make/mismatching-target-triples/bar.rs b/src/test/run-make/mismatching-target-triples/bar.rs new file mode 100755 index 0000000000000..ed15e5d880a9b --- /dev/null +++ b/src/test/run-make/mismatching-target-triples/bar.rs @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![no_std] +extern crate foo; diff --git a/src/test/run-make/mismatching-target-triples/foo.rs b/src/test/run-make/mismatching-target-triples/foo.rs new file mode 100755 index 0000000000000..8afa43710dd93 --- /dev/null +++ b/src/test/run-make/mismatching-target-triples/foo.rs @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![no_std] +#![crate_type = "lib"]