]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Don't modify library path for doctests
authorOliver Middleton <olliemail27@gmail.com>
Sun, 20 Jan 2019 10:14:26 +0000 (10:14 +0000)
committerOliver Middleton <olliemail27@gmail.com>
Sun, 20 Jan 2019 10:14:26 +0000 (10:14 +0000)
It shouldn't be needed anymore because doctests are no longer compiled with `prefer-dynamic`.

src/librustdoc/test.rs
src/test/rustdoc-ui/failed-doctest-output.stdout

index 0b9fbc81da626a600824de2922d6e15ab1890dba..f4b67771c16638ef55cee7eb2f0cdaf6e05932dd 100644 (file)
@@ -5,12 +5,11 @@
 use rustc_driver::{self, driver, target_features, Compilation};
 use rustc_driver::driver::phase_2_configure_and_expand;
 use rustc_metadata::cstore::CStore;
-use rustc_metadata::dynamic_lib::DynamicLibrary;
 use rustc::hir;
 use rustc::hir::intravisit;
 use rustc::session::{self, CompileIncomplete, config};
 use rustc::session::config::{OutputType, OutputTypes, Externs, CodegenOptions};
-use rustc::session::search_paths::{SearchPath, PathKind};
+use rustc::session::search_paths::SearchPath;
 use syntax::ast;
 use syntax::source_map::SourceMap;
 use syntax::edition::Edition;
@@ -21,7 +20,6 @@
 use testing;
 
 use std::env;
-use std::ffi::OsString;
 use std::io::prelude::*;
 use std::io;
 use std::path::PathBuf;
@@ -265,7 +263,7 @@ fn path(&self) -> &std::path::Path {
         }
     }
 
-    let (libdir, outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| {
+    let (outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| {
         let source_map = Lrc::new(SourceMap::new(sessopts.file_path_mapping()));
         let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
                                                         Some(source_map.clone()),
@@ -304,7 +302,6 @@ fn path(&self) -> &std::path::Path {
                                 .expect("rustdoc needs a tempdir"))
             }
         );
-        let libdir = sess.target_filesearch(PathKind::All).get_lib_path();
         let mut control = driver::CompileController::basic();
 
         let mut cfg = config::build_configuration(&sess, config::parse_cfgspecs(cfgs.clone()));
@@ -336,7 +333,7 @@ fn path(&self) -> &std::path::Path {
             Err(_) | Ok(Err(CompileIncomplete::Errored(_))) => Err(())
         };
 
-        (libdir, outdir, compile_result)
+        (outdir, compile_result)
     });
 
     match (compile_result, compile_fail) {
@@ -362,21 +359,7 @@ fn path(&self) -> &std::path::Path {
     if no_run { return }
 
     // Run the code!
-    //
-    // We're careful to prepend the *target* dylib search path to the child's
-    // environment to ensure that the target loads the right libraries at
-    // runtime. It would be a sad day if the *host* libraries were loaded as a
-    // mistake.
     let mut cmd = Command::new(&outdir.lock().unwrap().path().join("rust_out"));
-    let var = DynamicLibrary::envvar();
-    let newpath = {
-        let path = env::var_os(var).unwrap_or(OsString::new());
-        let mut path = env::split_paths(&path).collect::<Vec<_>>();
-        path.insert(0, libdir);
-        env::join_paths(path).unwrap()
-    };
-    cmd.env(var, &newpath);
-
     match cmd.output() {
         Err(e) => panic!("couldn't run the test: {}{}", e,
                         if e.kind() == io::ErrorKind::PermissionDenied {
index 8af05e9ca97b1d60fd9557cb76d290c9e1bb6491..b7617ec556d2083651f881f0bb8f0adb0165c88d 100644 (file)
@@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope
 3 | no
   | ^^ not found in this scope
 
-thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:354:13
+thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
 
 ---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ----
@@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test
 thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
 
-', src/librustdoc/test.rs:389:17
+', src/librustdoc/test.rs:372:17
 
 
 failures: