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

Correctly handle comments in attributes in doctests source code #134260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

Fixes #134221.

The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute.

r? @notriddle

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 13, 2024
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Forgot to set only one test thread to prevent having fuzzy sorting...

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

And to replace stdout for time too...

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
#17 exporting to docker image format
#17 sending tarball 29.1s done
#17 DONE 34.5s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
  Downloaded boml v0.3.1
   Compiling boml v0.3.1
   Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
    Finished `release` profile [optimized] target(s) in 4.04s
     Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-system-gcc --use-backend gcc --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --mini-tests --std-tests`
Using system GCC
[BUILD] example
[AOT] mini_core_hello_world
/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc/mini_core_hello_world
abc
---

failures:

---- [ui] tests/rustdoc-ui/doctest/comment-in-attr-134221.rs stdout ----
Saved the actual stdout to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-ui/doctest/comment-in-attr-134221/comment-in-attr-134221.stdout"

1 
2 running 2 tests
- test $DIR/doctest/comment-in-attr-134221.rs - (line 11) ... FAILED
- test $DIR/doctest/comment-in-attr-134221.rs - (line 11) ... FAILED
- test $DIR/doctest/comment-in-attr-134221.rs - (line 17) ... FAILED
+ test $DIR/comment-in-attr-134221.rs - (line 11) ... FAILED
+ test $DIR/comment-in-attr-134221.rs - (line 17) ... FAILED
5 
6 failures:
7 

- ---- $DIR/doctest/comment-in-attr-134221.rs - (line 11) stdout ----
+ ---- $DIR/comment-in-attr-134221.rs - (line 11) stdout ----
9 error[E0635]: unknown feature `foo`
-   --> $DIR/doctest/comment-in-attr-134221.rs:$LINE:$COL
+   --> $DIR/comment-in-attr-134221.rs:$LINE:$COL
12 LL |   foo, //
13    |   ^^^

16 
16 
17 For more information about this error, try `rustc --explain E0635`.
18 Couldn't compile the test.
- ---- $DIR/doctest/comment-in-attr-134221.rs - (line 17) stdout ----
+ ---- $DIR/comment-in-attr-134221.rs - (line 17) stdout ----
20 error[E0635]: unknown feature `foo`
-   --> $DIR/doctest/comment-in-attr-134221.rs:$LINE:$COL
+   --> $DIR/comment-in-attr-134221.rs:$LINE:$COL
23 LL |   foo,
24    |   ^^^

29 Couldn't compile the test.
---
- ---- /checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs - (line 17) stdout ----
-   --> /checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs:18:3
-     /checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs - (line 11)
-     /checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs - (line 17)
+ test $DIR/comment-in-attr-134221.rs - (line 11) ... FAILED
+ test $DIR/comment-in-attr-134221.rs - (line 17) ... FAILED
+ ---- $DIR/comment-in-attr-134221.rs - (line 11) stdout ----
+   --> $DIR/comment-in-attr-134221.rs:$LINE:$COL
+ ---- $DIR/comment-in-attr-134221.rs - (line 17) stdout ----
+   --> $DIR/comment-in-attr-134221.rs:$LINE:$COL
+     $DIR/comment-in-attr-134221.rs - (line 11)
+     $DIR/comment-in-attr-134221.rs - (line 17)

The actual stdout differed from the expected stdout.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args doctest/comment-in-attr-134221.rs`
To only update this specific test, also pass `--test-args doctest/comment-in-attr-134221.rs`

error: 1 errors occurred comparing output.
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "/checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-ui/doctest/comment-in-attr-134221" "-A" "internal_features" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--test" "--test-args" "--test-threads=1"

running 2 tests
test /checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs - (line 11) ... FAILED
test /checkout/tests/rustdoc-ui/doctest/comment-in-attr-134221.rs - (line 17) ... FAILED

@cyrgani
Copy link
Contributor

cyrgani commented Dec 13, 2024

Does this also fix that

//! ```rust
//! #![
//! ```

is incorrectly treated as a sucessful test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

Adding a comment next to #![feature(ptr_metadata,)] silences failing doctests
5 participants