Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #125848

Closed
wants to merge 13 commits into from

Conversation

GuillaumeGomez
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

GuillaumeGomez and others added 13 commits May 1, 2024 16:45
…de_classes_in_docs, r=rustdoc

Stabilize `custom_code_classes_in_docs` feature

Fixes rust-lang#79483.

This feature has been around for quite some time now, I think it's fine to stabilize it now.

## Summary

## What is the feature about?

In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation:

 * Allow to disable generation of `language-*` CSS classes with the `custom` attribute.
 * Add your own CSS classes to a code block so that you can use other tools to highlight them.

#### The `custom` attribute

Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example:

```rust
/// ```custom,c
/// int main(void) {
///     return 0;
/// }
/// ```
```

The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes.

#### Adding your own CSS classes

The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well.

This allow users to write the following:

```rust
/// Some code block with `{class=language-c}` as the language string.
///
/// ```custom,{class=language-c}
/// int main(void) {
///     return 0;
/// }
/// ```
fn main() {}
```

This will notably produce the following HTML:

```html
<pre class="language-c">
int main(void) {
    return 0;
}</pre>
```

Instead of:

```html
<pre class="rust rust-example-rendered">
<span class="ident">int</span> <span class="ident">main</span>(<span class="ident">void</span>) {
    <span class="kw">return</span> <span class="number">0</span>;
}
</pre>
```

To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect.

One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all.

In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this:

```rust
/// ```custom,class:language-c
/// main;
/// ```
pub fn foo() {}
```

Without this `unknown` field, it would generate in the DOM: `<pre class="language-class:language-c language-c">`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `<pre class="language-c">`. I added tests to cover this.

EDIT(camelid): This description is out-of-date. Using `custom,class:language-c` will generate the output `<pre class="language-class:language-c">` as would be expected; it treats `class:language-c` as just the name of a language (similar to the langstring `c` or `js` or what have you) since it does not use the designed class syntax.

Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend.

As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](rust-lang#110800 (comment))).

r? `@notriddle`
…=jieyouxu

Rewrite `suspicious-library`, `resolve-rename` and `incr-prev-body-beyond-eof` `run-make` tests in `rmake.rs` format

Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Some oddly specific ignore flags in `incr-prev-body-beyond-eof`:

```rs
// ignore-none
// ignore-nvptx64-nvidia-cuda
```

it could be interesting to run a try job, but it seems there is no nvidia-cuda in the CI settings (`jobs.yml`).
…ylib, r=jieyouxu

Migrate run make cdylib

Part of rust-lang#121876.

r? `@jieyouxu`
…link-to-rust-dylib, r=jieyouxu

Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs`

Part of rust-lang#121876.

First commit comes from rust-lang#125773.

r? `@jieyouxu`
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Jun 1, 2024
@GuillaumeGomez
Copy link
Member Author

@bors r+ p=4 rollup=never

@bors
Copy link
Contributor

bors commented Jun 1, 2024

📌 Commit a93557f has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 1, 2024
@bors
Copy link
Contributor

bors commented Jun 1, 2024

⌛ Testing commit a93557f with merge ab1d67f...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 1, 2024
…llaumeGomez

Rollup of 4 pull requests

Successful merges:

 - rust-lang#124577 (Stabilize `custom_code_classes_in_docs` feature)
 - rust-lang#125683 (Rewrite `suspicious-library`, `resolve-rename` and `incr-prev-body-beyond-eof` `run-make` tests in `rmake.rs` format)
 - rust-lang#125773 (Migrate run make cdylib)
 - rust-lang#125808 (Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job armhf-gnu failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [run-make] tests/run-make/incr-prev-body-beyond-eof stdout ----

error: rmake recipe failed to complete
status: exit status: 1
command: cd "/checkout/tests/run-make/incr-prev-body-beyond-eof" && env -u CARGO_MAKEFLAGS -u MAKEFLAGS -u MFLAGS -u RUSTFLAGS AR="arm-linux-gnueabihf-ar" CC="arm-linux-gnueabihf-gcc" CC_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfpu=vfp" CXX="arm-linux-gnueabihf-g++" CXX_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfpu=vfp" HOST_RPATH_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" LD_LIB_PATH_ENVVAR="LD_LIBRARY_PATH" LLVM_BIN_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm/bin" LLVM_COMPONENTS="aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen codegentypes core coroutines coverage csky cskyasmparser cskycodegen cskydesc cskydisassembler cskyinfo debuginfobtf debuginfocodeview debuginfodwarf debuginfogsym debuginfologicalview debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker dwarflinkerclassic dwarflinkerparallel dwp engine executionengine extensions filecheck frontenddriver frontendhlsl frontendoffloading frontendopenacc frontendopenmp fuzzercli fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo hipstdpar instcombine instrumentation interfacestub interpreter ipo irprinter irreader jitlink libdriver lineeditor linker loongarch loongarchasmparser loongarchcodegen loongarchdesc loongarchdisassembler loongarchinfo lto m68k m68kasmparser m68kcodegen m68kdesc m68kdisassembler m68kinfo mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts objcopy object objectyaml option orcdebugging orcjit orcshared orctargetprocess passes powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvtargetmca runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target targetparser textapi textapibinaryreader transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsdriver windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86targetmca xray" LLVM_FILECHECK="/checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" PYTHON="/usr/bin/python3" REMOTE_TEST_CLIENT="/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client" RUSTC="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" RUSTC_LINKER="arm-linux-gnueabihf-gcc" RUSTDOC="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" RUST_BUILD_STAGE="stage2-arm-unknown-linux-gnueabihf" S="/checkout" TARGET="arm-unknown-linux-gnueabihf" TARGET_RPATH_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib" TARGET_RPATH_ENV="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib" TMPDIR="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/rmake"
--- stderr -------------------------------
command failed at line 27
command failed at line 27
LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof" "-Cincremental=/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/incr" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/src/main.rs" "--target=arm-unknown-linux-gnueabihf"
output status: `exit status: 1`
=== STDOUT ===


=== STDERR ===
error: linking with `cc` failed: exit status: 1
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/rustcxEjBv7/symbols.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.1w9phmwf86bycewoyncpk8d6s.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.4kjoct3arcenoesaejow44nht.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.77day5r8gc7sbu0izkh9hzs2o.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.9jwmupvoukkb9wrugs9qku7rk.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.9scds5ey9rjl3rge2rkfi4y98.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.cylbvvmgiyytsub5v1xab818h.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.eurlr1q7codjs8p0s283fj8qx.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.ez5p3m1jv3ildhc2cwdqgvfug.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.2uoctswmurc6ir5rvoay0p9ke.rcgu.o" "-Wl,--as-needed" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libstd-a106e723a2b5febb.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libpanic_unwind-c05e89eeb843e5a6.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libobject-de677c79b7e6ad8c.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libmemchr-139155ece87263c3.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libaddr2line-9224ec90435039c4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libgimli-eeb24dd470ccf717.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librustc_demangle-f1562b6922974877.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libstd_detect-f61ea3747beca4ed.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libhashbrown-ff33068892c9a1e1.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librustc_std_workspace_alloc-4956c6d56cd0511d.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libminiz_oxide-86b64b27d73942e8.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libadler-0bf7ba0fca323211.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libunwind-b805ca251b78c7ef.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcfg_if-062629dd51e8064b.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liblibc-e9121d4f919e3bec.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc-138bb2e82b721562.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librustc_std_workspace_core-503ff6c4e0fa470e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcore-be9ec42889b42df8.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcompiler_builtins-6540d2bd15b9c254.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.1w9phmwf86bycewoyncpk8d6s.rcgu.o: relocations in generic ELF (EM: 40)
          /usr/bin/ld: /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.1w9phmwf86bycewoyncpk8d6s.rcgu.o: relocations in generic ELF (EM: 40)
          /usr/bin/ld: /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/incr-prev-body-beyond-eof/incr-prev-body-beyond-eof/main.1w9phmwf86bycewoyncpk8d6s.rcgu.o: error adding symbols: file in wrong format
          

error: aborting due to 1 previous error
------------------------------------------

@bors
Copy link
Contributor

bors commented Jun 1, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 1, 2024
@GuillaumeGomez GuillaumeGomez deleted the rollup-jfjee06 branch June 2, 2024 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants