From 6d78620bd77f1760e3730ef44aba7e53e3b38a23 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 12 Sep 2016 22:43:48 -0700 Subject: [PATCH] rustbuild: Nicer error for host builds of targets If a triple is configured only as a target, not a host, then trying to build that triple with host artifacts would cause a panic. Fail a little nicer instead. Closes #36268 --- src/bootstrap/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 94c14f7ea25..efeda1d6b54 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -959,7 +959,11 @@ fn ar(&self, target: &str) -> Option<&Path> { /// Returns the path to the C++ compiler for the target specified, may panic /// if no C++ compiler was configured for the target. fn cxx(&self, target: &str) -> &Path { - self.cxx[target].path() + match self.cxx.get(target) { + Some(p) => p.path(), + None => panic!("\n\ntarget `{}` is not configured as a host, + only as a target\n\n", target), + } } /// Returns flags to pass to the compiler to generate code for `target`.