diff options
| author | bors <bors@rust-lang.org> | 2022-11-23 16:29:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-23 16:29:17 +0000 |
| commit | d121aa3b5584eb919a4aaf64dbae0ea1e8e30231 (patch) | |
| tree | 461296940a2cde7aafa71a03a1e2e9cb274af082 /src | |
| parent | 80b3c6dbde3ff89a44f8eaa63e08054398b30ecd (diff) | |
| parent | 5d7b68c82bf4e6b4ba1171b01da2d11a0886f751 (diff) | |
| download | rust-d121aa3b5584eb919a4aaf64dbae0ea1e8e30231.tar.gz rust-d121aa3b5584eb919a4aaf64dbae0ea1e8e30231.zip | |
Auto merge of #104776 - Dylan-DPC:rollup-rf4c2u0, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #104269 (Fix hang in where-clause suggestion with `predicate_can_apply`) - #104286 (copy doc output files by format) - #104509 (Use obligation ctxt instead of dyn TraitEngine) - #104721 (Remove more `ref` patterns from the compiler) - #104744 (rustdoc: give struct fields CSS `display: block`) - #104751 (Fix an ICE parsing a malformed attribute.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/builder.rs | 8 | ||||
| -rw-r--r-- | src/bootstrap/doc.rs | 21 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 2 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-verify-output-files/Makefile | 36 | ||||
| -rw-r--r-- | src/test/run-make/rustdoc-verify-output-files/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/test_docs/lib.rs | 5 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/struct-fields.goml | 5 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-104620.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/parser/issue-104620.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/traits/predicate_can_apply-hang.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/traits/predicate_can_apply-hang.stderr | 21 | ||||
| -rw-r--r-- | src/test/ui/typeck/hang-in-overflow.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/typeck/hang-in-overflow.stderr | 22 |
13 files changed, 144 insertions, 14 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 8d999302a6d..251431a15eb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1094,7 +1094,13 @@ impl<'a> Builder<'a> { let my_out = match mode { // This is the intended out directory for compiler documentation. Mode::Rustc | Mode::ToolRustc => self.compiler_doc_out(target), - Mode::Std => out_dir.join(target.triple).join("doc"), + Mode::Std => { + if self.config.cmd.json() { + out_dir.join(target.triple).join("json-doc") + } else { + out_dir.join(target.triple).join("doc") + } + } _ => panic!("doc mode {:?} not expected", mode), }; let rustdoc = self.rustdoc(compiler); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3180a12c85b..571396eb835 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -564,27 +564,22 @@ fn doc_std( ); } let compiler = builder.compiler(stage, builder.config.build); + + let target_doc_dir_name = if format == DocumentationFormat::JSON { "json-doc" } else { "doc" }; + let target_dir = + builder.stage_out(compiler, Mode::Std).join(target.triple).join(target_doc_dir_name); + // This is directory where the compiler will place the output of the command. // We will then copy the files from this directory into the final `out` directory, the specified // as a function parameter. - let out_dir = builder.stage_out(compiler, Mode::Std).join(target.triple).join("doc"); - // `cargo` uses the same directory for both JSON docs and HTML docs. - // This could lead to cross-contamination when copying files into the specified `out` directory. - // For example: - // ```bash - // x doc std - // x doc std --json - // ``` - // could lead to HTML docs being copied into the JSON docs output directory. - // To avoid this issue, we clean the doc folder before invoking `cargo`. - if out_dir.exists() { - builder.remove_dir(&out_dir); - } + let out_dir = target_dir.join(target.triple).join("doc"); let run_cargo_rustdoc_for = |package: &str| { let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc"); compile::std_cargo(builder, target, compiler.stage, &mut cargo); cargo + .arg("--target-dir") + .arg(&*target_dir.to_string_lossy()) .arg("-p") .arg(package) .arg("-Zskip-rustdoc-fingerprint") diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d4e881ad832..63530b924c2 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -701,6 +701,8 @@ a { } .small-section-header { + /* fields use <span> tags, but should get their own lines */ + display: block; position: relative; } diff --git a/src/test/run-make/rustdoc-verify-output-files/Makefile b/src/test/run-make/rustdoc-verify-output-files/Makefile new file mode 100644 index 00000000000..bfabbbc6586 --- /dev/null +++ b/src/test/run-make/rustdoc-verify-output-files/Makefile @@ -0,0 +1,36 @@ +include ../../run-make-fulldeps/tools.mk + +OUTPUT_DIR := "$(TMPDIR)/rustdoc" +TMP_OUTPUT_DIR := "$(TMPDIR)/tmp-rustdoc" + +all: + # Generate html docs + $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) + + # Copy first output for to check if it's exactly same after second compilation + cp -R $(OUTPUT_DIR) $(TMP_OUTPUT_DIR) + + # Generate html docs once again on same output + $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) + + # Check if everything exactly same + $(DIFF) -r -q $(OUTPUT_DIR) $(TMP_OUTPUT_DIR) + + # Generate json doc on the same output + $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) -Z unstable-options --output-format json + + # Check if expected json file is generated + [ -e $(OUTPUT_DIR)/foobar.json ] + + # TODO + # We should re-generate json doc once again and compare the diff with previously + # generated one. Because layout of json docs changes in each compilation, we can't + # do that currently. + # + # See https://github.com/rust-lang/rust/issues/103785#issuecomment-1307425590 for details. + + # remove generated json doc + rm $(OUTPUT_DIR)/foobar.json + + # Check if json doc compilation broke any of the html files generated previously + $(DIFF) -r -q $(OUTPUT_DIR) $(TMP_OUTPUT_DIR) diff --git a/src/test/run-make/rustdoc-verify-output-files/src/lib.rs b/src/test/run-make/rustdoc-verify-output-files/src/lib.rs new file mode 100644 index 00000000000..5df7576133a --- /dev/null +++ b/src/test/run-make/rustdoc-verify-output-files/src/lib.rs @@ -0,0 +1 @@ +// nothing to see here diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 8eea5ad01c0..dea154c9319 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -408,6 +408,11 @@ pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut p: P, } +pub struct StructWithPublicUndocumentedFields { + pub first: u32, + pub second: u32, +} + pub const CONST: u8 = 0; pub trait TraitWithoutGenerics { diff --git a/src/test/rustdoc-gui/struct-fields.goml b/src/test/rustdoc-gui/struct-fields.goml new file mode 100644 index 00000000000..3ec60b58cfd --- /dev/null +++ b/src/test/rustdoc-gui/struct-fields.goml @@ -0,0 +1,5 @@ +goto: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html" + +// Both fields must be on their own line. In other words, they have display: block. +store-property: (first_top, "//*[@id='structfield.first']", "offsetTop") +assert-property-false: ("//*[@id='structfield.second']", { "offsetTop": |first_top| }) diff --git a/src/test/ui/parser/issue-104620.rs b/src/test/ui/parser/issue-104620.rs new file mode 100644 index 00000000000..f49476c4408 --- /dev/null +++ b/src/test/ui/parser/issue-104620.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#![rustc_dummy=5z] //~ ERROR unexpected expression: `5z` +fn main() {} diff --git a/src/test/ui/parser/issue-104620.stderr b/src/test/ui/parser/issue-104620.stderr new file mode 100644 index 00000000000..d06a6b2554b --- /dev/null +++ b/src/test/ui/parser/issue-104620.stderr @@ -0,0 +1,8 @@ +error: unexpected expression: `5z` + --> $DIR/issue-104620.rs:3:16 + | +LL | #![rustc_dummy=5z] + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/traits/predicate_can_apply-hang.rs b/src/test/ui/traits/predicate_can_apply-hang.rs new file mode 100644 index 00000000000..5f01645da52 --- /dev/null +++ b/src/test/ui/traits/predicate_can_apply-hang.rs @@ -0,0 +1,6 @@ +fn f<B>(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq<B> { + //~^ ERROR can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` + x +} + +fn main() {} diff --git a/src/test/ui/traits/predicate_can_apply-hang.stderr b/src/test/ui/traits/predicate_can_apply-hang.stderr new file mode 100644 index 00000000000..49fe63b412a --- /dev/null +++ b/src/test/ui/traits/predicate_can_apply-hang.stderr @@ -0,0 +1,21 @@ +error[E0277]: can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` + --> $DIR/predicate_can_apply-hang.rs:1:38 + | +LL | fn f<B>(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq<B> { + | ^^^^^^^^^^^^^^^^^ no implementation for `Vec<[[[B; 1]; 1]; 1]> == B` +LL | +LL | x + | - return type was inferred to be `Vec<[[[B; 1]; 1]; 1]>` here + | + = help: the trait `PartialEq<B>` is not implemented for `Vec<[[[B; 1]; 1]; 1]>` + = help: the following other types implement trait `PartialEq<Rhs>`: + <Vec<T, A1> as PartialEq<Vec<U, A2>>> + <Vec<T, A> as PartialEq<&[U; N]>> + <Vec<T, A> as PartialEq<&[U]>> + <Vec<T, A> as PartialEq<&mut [U]>> + <Vec<T, A> as PartialEq<[U; N]>> + <Vec<T, A> as PartialEq<[U]>> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/typeck/hang-in-overflow.rs b/src/test/ui/typeck/hang-in-overflow.rs new file mode 100644 index 00000000000..a8330c9b65c --- /dev/null +++ b/src/test/ui/typeck/hang-in-overflow.rs @@ -0,0 +1,19 @@ +// normalize-stderr-test "the requirement `.*`" -> "the requirement `...`" +// normalize-stderr-test "required for `.*` to implement `.*`" -> "required for `...` to implement `...`" +// normalize-stderr-test: ".*the full type name has been written to.*\n" -> "" + +// Currently this fatally aborts instead of hanging. +// Make sure at least that this doesn't turn into a hang. + +fn f() { + foo::<_>(); + //~^ ERROR overflow evaluating the requirement +} + +fn foo<B>() +where + Vec<[[[B; 1]; 1]; 1]>: PartialEq<B>, +{ +} + +fn main() {} diff --git a/src/test/ui/typeck/hang-in-overflow.stderr b/src/test/ui/typeck/hang-in-overflow.stderr new file mode 100644 index 00000000000..7a7b85b19b4 --- /dev/null +++ b/src/test/ui/typeck/hang-in-overflow.stderr @@ -0,0 +1,22 @@ +error[E0275]: overflow evaluating the requirement `...` + --> $DIR/hang-in-overflow.rs:9:5 + | +LL | foo::<_>(); + | ^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`hang_in_overflow`) + = note: required for `...` to implement `...` + = note: 127 redundant requirements hidden + = note: required for `...` to implement `...` +note: required by a bound in `foo` + --> $DIR/hang-in-overflow.rs:15:28 + | +LL | fn foo<B>() + | --- required by a bound in this +LL | where +LL | Vec<[[[B; 1]; 1]; 1]>: PartialEq<B>, + | ^^^^^^^^^^^^ required by this bound in `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. |
