about summary refs log tree commit diff
path: root/src/librustc/session
diff options
context:
space:
mode:
authorRyan Prichard <ryan.prichard@gmail.com>2015-03-13 23:49:44 -0700
committerRyan Prichard <ryan.prichard@gmail.com>2015-03-13 23:49:44 -0700
commit85b084f4bd5c61adf23ca0de08cfba3d23ef1cfc (patch)
tree0ce13f4224635dced5d20397e622c25447078cbf /src/librustc/session
parent00211ecfda53521ea6b6405beff1c490b04f3ce5 (diff)
downloadrust-85b084f4bd5c61adf23ca0de08cfba3d23ef1cfc.tar.gz
rust-85b084f4bd5c61adf23ca0de08cfba3d23ef1cfc.zip
Reject `-L ""`, `-L native=`, and other empty search paths.
It wasn't clear to me that early_error was correct here, but it seems to
work. This code is reachable from `rustdoc`, which is problematic, because
early_error panics. rustc handles the panics gracefully (without ICEing or
crashing), but rustdoc does not. It's not the first such rustdoc problem,
though:

    $ rustdoc hello.rs --extern std=bad-std
    error: extern location for std does not exist: bad-std
    hello.rs:1:1: 1:1 error: can't find crate for `std`
    hello.rs:1
           ^
    error: aborting due to 2 previous errors
    thread '<unnamed>' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:151
    thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "rustc failed"', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:744
    thread '<main>' panicked at 'child thread None panicked', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thread.rs:661
Diffstat (limited to 'src/librustc/session')
-rw-r--r--src/librustc/session/search_paths.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustc/session/search_paths.rs b/src/librustc/session/search_paths.rs
index f85fb303910..3c5d9744505 100644
--- a/src/librustc/session/search_paths.rs
+++ b/src/librustc/session/search_paths.rs
@@ -10,6 +10,7 @@
 
 use std::slice;
 use std::path::{Path, PathBuf};
+use session::early_error;
 
 #[derive(Clone, Debug)]
 pub struct SearchPaths {
@@ -50,6 +51,9 @@ impl SearchPaths {
         } else {
             (PathKind::All, path)
         };
+        if path.is_empty() {
+            early_error("empty search path given via `-L`");
+        }
         self.paths.push((kind, PathBuf::new(path)));
     }