summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/doctest.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /src/librustdoc/doctest.rs
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librustdoc/doctest.rs')
-rw-r--r--src/librustdoc/doctest.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index db70029f6..81d9c4644 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -19,7 +19,7 @@ use rustc_span::edition::Edition;
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::sym;
use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
-use rustc_target::spec::TargetTriple;
+use rustc_target::spec::{Target, TargetTriple};
use tempfile::Builder as TempFileBuilder;
use std::env;
@@ -293,6 +293,16 @@ struct UnusedExterns {
unused_extern_names: Vec<String>,
}
+fn add_exe_suffix(input: String, target: &TargetTriple) -> String {
+ let exe_suffix = match target {
+ TargetTriple::TargetTriple(_) => Target::expect_builtin(target).options.exe_suffix,
+ TargetTriple::TargetJson { contents, .. } => {
+ Target::from_json(contents.parse().unwrap()).unwrap().0.options.exe_suffix
+ }
+ };
+ input + &exe_suffix
+}
+
fn run_test(
test: &str,
crate_name: &str,
@@ -313,7 +323,9 @@ fn run_test(
let (test, line_offset, supports_color) =
make_test(test, Some(crate_name), lang_string.test_harness, opts, edition, Some(test_id));
- let output_file = outdir.path().join("rust_out");
+ // Make sure we emit well-formed executable names for our target.
+ let rust_out = add_exe_suffix("rust_out".to_owned(), &target);
+ let output_file = outdir.path().join(rust_out);
let rustc_binary = rustdoc_options
.test_builder
@@ -551,6 +563,7 @@ pub(crate) fn make_test(
false,
Some(80),
false,
+ false,
)
.supports_color();
@@ -564,6 +577,7 @@ pub(crate) fn make_test(
false,
None,
false,
+ false,
);
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
@@ -748,6 +762,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
false,
None,
false,
+ false,
);
let handler = Handler::with_emitter(false, None, Box::new(emitter));
@@ -1290,7 +1305,7 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>
}
fn visit_variant(&mut self, v: &'hir hir::Variant<'_>) {
- self.visit_testable(v.ident.to_string(), v.id, v.span, |this| {
+ self.visit_testable(v.ident.to_string(), v.hir_id, v.span, |this| {
intravisit::walk_variant(this, v);
});
}