diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 6e69b361ad..2cedcf4ea8 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -135,6 +135,9 @@ pub fn build(target: &Triple, matches: &ArgMatches, run_after_build: bool) -> io Err(LoadingProblem::ParsingFailedReport(report)) => { print!("{}", report); } + Err(LoadingProblem::NoPlatform) => { + print!("The file you ran did not provide a platform\nMaybe you are trying to run an Interface module?"); + } Err(other) => { panic!("build_file failed with error:\n{:?}", other); } diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index 9cfe7c1f80..721fa41509 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -980,6 +980,8 @@ pub enum LoadingProblem<'a> { }, ParsingFailed(ParseProblem<'a, SyntaxError<'a>>), UnexpectedHeader(String), + /// there is no platform (likely running an Interface module) + NoPlatform, MsgChannelDied, ErrJoiningWorkerThreads, @@ -1479,7 +1481,7 @@ where state, subs, exposed_to_host, - ))); + )?)); } Msg::FailedToParse(problem) => { // Shut down all the worker threads. @@ -2044,7 +2046,7 @@ fn finish_specialization( state: State, subs: Subs, exposed_to_host: MutMap, -) -> MonomorphizedModule { +) -> Result { let module_ids = Arc::try_unwrap(state.arc_modules) .unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids")) .into_inner() @@ -2085,7 +2087,7 @@ fn finish_specialization( } } Some(To::NewPackage(p_or_p)) => p_or_p, - None => panic!("no platform!"), + None => return Err(LoadingProblem::NoPlatform), }; match package_or_path { @@ -2097,7 +2099,7 @@ fn finish_specialization( let platform_path = path_to_platform.into(); - MonomorphizedModule { + Ok(MonomorphizedModule { can_problems, mono_problems, type_problems, @@ -2110,7 +2112,7 @@ fn finish_specialization( procedures, sources, timings: state.timings, - } + }) } fn finish(