Skip to content

Commit fcccf06

Browse files
committed
Auto merge of #56514 - ollie27:rustdoc_test_libdir, r=QuietMisdreavus
rustdoc: Don't modify library path for doctests It shouldn't be needed anymore because doctests are no longer compiled with `prefer-dynamic` (since #54939). r? @QuietMisdreavus
2 parents 32471f7 + ad09d7f commit fcccf06

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

src/librustdoc/test.rs

+3-20
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ use rustc_lint;
55
use rustc_driver::{self, driver, target_features, Compilation};
66
use rustc_driver::driver::phase_2_configure_and_expand;
77
use rustc_metadata::cstore::CStore;
8-
use rustc_metadata::dynamic_lib::DynamicLibrary;
98
use rustc::hir;
109
use rustc::hir::intravisit;
1110
use rustc::session::{self, CompileIncomplete, config};
1211
use rustc::session::config::{OutputType, OutputTypes, Externs, CodegenOptions};
13-
use rustc::session::search_paths::{SearchPath, PathKind};
12+
use rustc::session::search_paths::SearchPath;
1413
use syntax::ast;
1514
use syntax::source_map::SourceMap;
1615
use syntax::edition::Edition;
@@ -21,7 +20,6 @@ use tempfile::Builder as TempFileBuilder;
2120
use testing;
2221

2322
use std::env;
24-
use std::ffi::OsString;
2523
use std::io::prelude::*;
2624
use std::io;
2725
use std::path::PathBuf;
@@ -265,7 +263,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
265263
}
266264
}
267265

268-
let (libdir, outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| {
266+
let (outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| {
269267
let source_map = Lrc::new(SourceMap::new(sessopts.file_path_mapping()));
270268
let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
271269
Some(source_map.clone()),
@@ -304,7 +302,6 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
304302
.expect("rustdoc needs a tempdir"))
305303
}
306304
);
307-
let libdir = sess.target_filesearch(PathKind::All).get_lib_path();
308305
let mut control = driver::CompileController::basic();
309306

310307
let mut cfg = config::build_configuration(&sess, config::parse_cfgspecs(cfgs.clone()));
@@ -336,7 +333,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
336333
Err(_) | Ok(Err(CompileIncomplete::Errored(_))) => Err(())
337334
};
338335

339-
(libdir, outdir, compile_result)
336+
(outdir, compile_result)
340337
});
341338

342339
match (compile_result, compile_fail) {
@@ -362,21 +359,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
362359
if no_run { return }
363360

364361
// Run the code!
365-
//
366-
// We're careful to prepend the *target* dylib search path to the child's
367-
// environment to ensure that the target loads the right libraries at
368-
// runtime. It would be a sad day if the *host* libraries were loaded as a
369-
// mistake.
370362
let mut cmd = Command::new(&outdir.lock().unwrap().path().join("rust_out"));
371-
let var = DynamicLibrary::envvar();
372-
let newpath = {
373-
let path = env::var_os(var).unwrap_or(OsString::new());
374-
let mut path = env::split_paths(&path).collect::<Vec<_>>();
375-
path.insert(0, libdir);
376-
env::join_paths(path).unwrap()
377-
};
378-
cmd.env(var, &newpath);
379-
380363
match cmd.output() {
381364
Err(e) => panic!("couldn't run the test: {}{}", e,
382365
if e.kind() == io::ErrorKind::PermissionDenied {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope
1212
3 | no
1313
| ^^ not found in this scope
1414

15-
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:354:13
15+
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
1616
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
1717

1818
---- $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
2121
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
2222
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2323

24-
', src/librustdoc/test.rs:389:17
24+
', src/librustdoc/test.rs:372:17
2525

2626

2727
failures:

0 commit comments

Comments
 (0)