From fba35e1a3c87892823d1f4d436b9f00a7864cf16 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 30 Jan 2012 21:00:57 -0800 Subject: Require alts to be exhaustive middle::check_alt does the work. Lots of changes to add default cases into alts that were previously inexhaustive. --- src/comp/back/rpath.rs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/comp/back') diff --git a/src/comp/back/rpath.rs b/src/comp/back/rpath.rs index b848ca94590..a2030e10fab 100644 --- a/src/comp/back/rpath.rs +++ b/src/comp/back/rpath.rs @@ -11,6 +11,13 @@ import util::filesearch; export get_rpath_flags; +pure fn not_win32(os: session::os) -> bool { + alt os { + session::os_win32 { false } + _ { true } + } +} + fn get_rpath_flags(sess: session::session, out_filename: str) -> [str] { let os = sess.targ_cfg.os; @@ -99,12 +106,13 @@ fn get_rpaths_relative_to_output(os: session::os, fn get_rpath_relative_to_output(os: session::os, cwd: fs::path, output: fs::path, - &&lib: fs::path) -> str { + &&lib: fs::path) : not_win32(os) -> str { // Mac doesn't appear to support $ORIGIN let prefix = alt os { session::os_linux { "$ORIGIN" + fs::path_sep() } session::os_freebsd { "$ORIGIN" + fs::path_sep() } session::os_macos { "@executable_path" + fs::path_sep() } + session::os_win32 { std::util::unreachable(); } }; prefix + get_relative_to( @@ -309,24 +317,31 @@ mod test { #[test] #[cfg(target_os = "linux")] fn test_rpath_relative() { - let res = get_rpath_relative_to_output(session::os_linux, + let o = session::os_linux; + check not_win32(o); + let res = get_rpath_relative_to_output(o, "/usr", "bin/rustc", "lib/libstd.so"); - assert res == "$ORIGIN/../lib"; + assert res == "$ORIGIN/../lib"; } #[test] #[cfg(target_os = "freebsd")] fn test_rpath_relative() { - let res = get_rpath_relative_to_output(session::os_freebsd, + let o = session::os_freebsd; + check not_win32(o); + let res = get_rpath_relative_to_output(o, "/usr", "bin/rustc", "lib/libstd.so"); - assert res == "$ORIGIN/../lib"; + assert res == "$ORIGIN/../lib"; } #[test] #[cfg(target_os = "macos")] fn test_rpath_relative() { - let res = get_rpath_relative_to_output(session::os_macos, - "/usr", "bin/rustc", "lib/libstd.so"); + // this is why refinements would be nice + let o = session::os_macos; + check not_win32(o); + let res = get_rpath_relative_to_output(o, "/usr", "bin/rustc", + "lib/libstd.so"); assert res == "@executable_path/../lib"; } -- cgit 1.4.1-3-g733a5