mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Auto merge of #130597 - matthiaskrgr:rollup-9ls4066, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #130485 (Do not expect infer/bound/placeholder/error in v0 symbol mangling) - #130567 (Register tool docs for compiletest) - #130582 (rustdoc: use the correct span for doctests) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
976487c48b
@ -330,8 +330,12 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||||||
ty::Float(FloatTy::F128) => "C4f128",
|
ty::Float(FloatTy::F128) => "C4f128",
|
||||||
ty::Never => "z",
|
ty::Never => "z",
|
||||||
|
|
||||||
// Placeholders (should be demangled as `_`).
|
// Should only be encountered with polymorphization,
|
||||||
ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => "p",
|
// or within the identity-substituted impl header of an
|
||||||
|
// item nested within an impl item.
|
||||||
|
ty::Param(_) => "p",
|
||||||
|
|
||||||
|
ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => bug!(),
|
||||||
|
|
||||||
_ => "",
|
_ => "",
|
||||||
};
|
};
|
||||||
@ -416,12 +420,18 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||||||
// Mangle all nominal types as paths.
|
// Mangle all nominal types as paths.
|
||||||
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
|
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
|
||||||
| ty::FnDef(def_id, args)
|
| ty::FnDef(def_id, args)
|
||||||
| ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. })
|
|
||||||
| ty::Closure(def_id, args)
|
| ty::Closure(def_id, args)
|
||||||
| ty::CoroutineClosure(def_id, args)
|
| ty::CoroutineClosure(def_id, args)
|
||||||
| ty::Coroutine(def_id, args) => {
|
| ty::Coroutine(def_id, args) => {
|
||||||
self.print_def_path(def_id, args)?;
|
self.print_def_path(def_id, args)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We may still encounter projections here due to the printing
|
||||||
|
// logic sometimes passing identity-substituted impl headers.
|
||||||
|
ty::Alias(ty::Projection, ty::AliasTy { def_id, args, .. }) => {
|
||||||
|
self.print_def_path(def_id, args)?;
|
||||||
|
}
|
||||||
|
|
||||||
ty::Foreign(def_id) => {
|
ty::Foreign(def_id) => {
|
||||||
self.print_def_path(def_id, &[])?;
|
self.print_def_path(def_id, &[])?;
|
||||||
}
|
}
|
||||||
@ -467,8 +477,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||||||
r.print(self)?;
|
r.print(self)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Alias(ty::Inherent, _) => bug!("symbol_names: unexpected inherent projection"),
|
ty::Alias(..) => bug!("symbol_names: unexpected alias"),
|
||||||
ty::Alias(ty::Weak, _) => bug!("symbol_names: unexpected weak projection"),
|
|
||||||
ty::CoroutineWitness(..) => bug!("symbol_names: unexpected `CoroutineWitness`"),
|
ty::CoroutineWitness(..) => bug!("symbol_names: unexpected `CoroutineWitness`"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,21 +559,26 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||||||
let (ct_ty, valtree) = match ct.kind() {
|
let (ct_ty, valtree) = match ct.kind() {
|
||||||
ty::ConstKind::Value(ty, val) => (ty, val),
|
ty::ConstKind::Value(ty, val) => (ty, val),
|
||||||
|
|
||||||
// Placeholders (should be demangled as `_`).
|
// Should only be encountered with polymorphization,
|
||||||
// NOTE(eddyb) despite `Unevaluated` having a `DefId` (and therefore
|
// or within the identity-substituted impl header of an
|
||||||
// a path), even for it we still need to encode a placeholder, as
|
// item nested within an impl item.
|
||||||
// the path could refer back to e.g. an `impl` using the constant.
|
ty::ConstKind::Param(_) => {
|
||||||
ty::ConstKind::Unevaluated(_)
|
|
||||||
| ty::ConstKind::Expr(_)
|
|
||||||
| ty::ConstKind::Param(_)
|
|
||||||
| ty::ConstKind::Infer(_)
|
|
||||||
| ty::ConstKind::Bound(..)
|
|
||||||
| ty::ConstKind::Placeholder(_)
|
|
||||||
| ty::ConstKind::Error(_) => {
|
|
||||||
// Never cached (single-character).
|
// Never cached (single-character).
|
||||||
self.push("p");
|
self.push("p");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We may still encounter unevaluated consts due to the printing
|
||||||
|
// logic sometimes passing identity-substituted impl headers.
|
||||||
|
ty::Unevaluated(ty::UnevaluatedConst { def, args, .. }) => {
|
||||||
|
return self.print_def_path(def, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
ty::ConstKind::Expr(_)
|
||||||
|
| ty::ConstKind::Infer(_)
|
||||||
|
| ty::ConstKind::Bound(..)
|
||||||
|
| ty::ConstKind::Placeholder(_)
|
||||||
|
| ty::ConstKind::Error(_) => bug!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(&i) = self.consts.get(&ct) {
|
if let Some(&i) = self.consts.get(&ct) {
|
||||||
|
@ -1058,6 +1058,13 @@ tool_doc!(
|
|||||||
is_library = true,
|
is_library = true,
|
||||||
crates = ["run_make_support"]
|
crates = ["run_make_support"]
|
||||||
);
|
);
|
||||||
|
tool_doc!(
|
||||||
|
Compiletest,
|
||||||
|
"src/tools/compiletest",
|
||||||
|
rustc_tool = false,
|
||||||
|
is_library = true,
|
||||||
|
crates = ["compiletest"]
|
||||||
|
);
|
||||||
|
|
||||||
#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)]
|
#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)]
|
||||||
pub struct ErrorIndex {
|
pub struct ErrorIndex {
|
||||||
|
@ -945,6 +945,7 @@ impl<'a> Builder<'a> {
|
|||||||
doc::Releases,
|
doc::Releases,
|
||||||
doc::RunMakeSupport,
|
doc::RunMakeSupport,
|
||||||
doc::BuildHelper,
|
doc::BuildHelper,
|
||||||
|
doc::Compiletest,
|
||||||
),
|
),
|
||||||
Kind::Dist => describe!(
|
Kind::Dist => describe!(
|
||||||
dist::Docs,
|
dist::Docs,
|
||||||
|
@ -122,23 +122,14 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
|
|||||||
// anything else, this will combine them for us.
|
// anything else, this will combine them for us.
|
||||||
let attrs = Attributes::from_ast(ast_attrs);
|
let attrs = Attributes::from_ast(ast_attrs);
|
||||||
if let Some(doc) = attrs.opt_doc_value() {
|
if let Some(doc) = attrs.opt_doc_value() {
|
||||||
// Use the outermost invocation, so that doctest names come from where the docs were written.
|
let span = span_of_fragments(&attrs.doc_strings).unwrap_or(sp);
|
||||||
let span = ast_attrs
|
|
||||||
.iter()
|
|
||||||
.find(|attr| attr.doc_str().is_some())
|
|
||||||
.map(|attr| attr.span.ctxt().outer_expn().expansion_cause().unwrap_or(attr.span))
|
|
||||||
.unwrap_or(DUMMY_SP);
|
|
||||||
self.collector.position = span;
|
self.collector.position = span;
|
||||||
markdown::find_testable_code(
|
markdown::find_testable_code(
|
||||||
&doc,
|
&doc,
|
||||||
&mut self.collector,
|
&mut self.collector,
|
||||||
self.codes,
|
self.codes,
|
||||||
self.enable_per_target_ignores,
|
self.enable_per_target_ignores,
|
||||||
Some(&crate::html::markdown::ExtraInfo::new(
|
Some(&crate::html::markdown::ExtraInfo::new(self.tcx, def_id, span)),
|
||||||
self.tcx,
|
|
||||||
def_id,
|
|
||||||
span_of_fragments(&attrs.doc_strings).unwrap_or(sp),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ pub struct TestProps {
|
|||||||
// Build documentation for all specified aux-builds as well
|
// Build documentation for all specified aux-builds as well
|
||||||
pub build_aux_docs: bool,
|
pub build_aux_docs: bool,
|
||||||
/// Build the documentation for each crate in a unique output directory.
|
/// Build the documentation for each crate in a unique output directory.
|
||||||
/// Uses <root output directory>/docs/<test name>/doc
|
/// Uses `<root output directory>/docs/<test name>/doc`.
|
||||||
pub unique_doc_out_dir: bool,
|
pub unique_doc_out_dir: bool,
|
||||||
// Flag to force a crate to be built with the host architecture
|
// Flag to force a crate to be built with the host architecture
|
||||||
pub force_host: bool,
|
pub force_host: bool,
|
||||||
@ -1304,12 +1304,12 @@ pub fn llvm_has_libzstd(config: &Config) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes a directive of the form "<version1> [- <version2>]",
|
/// Takes a directive of the form `"<version1> [- <version2>]"`,
|
||||||
/// returns the numeric representation of <version1> and <version2> as
|
/// returns the numeric representation of `<version1>` and `<version2>` as
|
||||||
/// tuple: (<version1> as u32, <version2> as u32)
|
/// tuple: `(<version1> as u32, <version2> as u32)`.
|
||||||
///
|
///
|
||||||
/// If the <version2> part is omitted, the second component of the tuple
|
/// If the `<version2>` part is omitted, the second component of the tuple
|
||||||
/// is the same as <version1>.
|
/// is the same as `<version1>`.
|
||||||
fn extract_version_range<F>(line: &str, parse: F) -> Option<(u32, u32)>
|
fn extract_version_range<F>(line: &str, parse: F) -> Option<(u32, u32)>
|
||||||
where
|
where
|
||||||
F: Fn(&str) -> Option<u32>,
|
F: Fn(&str) -> Option<u32>,
|
||||||
|
7
tests/rustdoc-ui/doctest/doctest-output-include-fail.md
Normal file
7
tests/rustdoc-ui/doctest/doctest-output-include-fail.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
With a code sample, that has an error:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() {
|
||||||
|
let x = 234 // no semicolon here! oh no!
|
||||||
|
}
|
||||||
|
```
|
7
tests/rustdoc-ui/doctest/doctest-output-include-fail.rs
Normal file
7
tests/rustdoc-ui/doctest/doctest-output-include-fail.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
//@ compile-flags:--test --test-args=--test-threads=1
|
||||||
|
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
|
||||||
|
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||||
|
//@ failure-status: 101
|
||||||
|
|
||||||
|
// https://github.com/rust-lang/rust/issues/130470
|
||||||
|
#![doc = include_str!("doctest-output-include-fail.md")]
|
24
tests/rustdoc-ui/doctest/doctest-output-include-fail.stdout
Normal file
24
tests/rustdoc-ui/doctest/doctest-output-include-fail.stdout
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
running 1 test
|
||||||
|
test $DIR/doctest-output-include-fail.md - (line 3) ... FAILED
|
||||||
|
|
||||||
|
failures:
|
||||||
|
|
||||||
|
---- $DIR/doctest-output-include-fail.md - (line 3) stdout ----
|
||||||
|
error: expected `;`, found `}`
|
||||||
|
--> $DIR/doctest-output-include-fail.md:5:16
|
||||||
|
|
|
||||||
|
LL | let x = 234 // no semicolon here! oh no!
|
||||||
|
| ^ help: add `;` here
|
||||||
|
LL | }
|
||||||
|
| - unexpected token
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
Couldn't compile the test.
|
||||||
|
|
||||||
|
failures:
|
||||||
|
$DIR/doctest-output-include-fail.md - (line 3)
|
||||||
|
|
||||||
|
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
running 3 tests
|
running 3 tests
|
||||||
test $DIR/doctest-output.rs - (line 8) ... ok
|
test $DIR/doctest-output.rs - (line 8) ... ok
|
||||||
test $DIR/doctest-output.rs - ExpandedStruct (line 24) ... ok
|
test $DIR/doctest-output.rs - ExpandedStruct (line 25) ... ok
|
||||||
test $DIR/doctest-output.rs - foo::bar (line 18) ... ok
|
test $DIR/doctest-output.rs - foo::bar (line 18) ... ok
|
||||||
|
|
||||||
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||||
|
Loading…
Reference in New Issue
Block a user