summary refs log tree commit diff
path: root/tests/rustdoc-ui
AgeCommit message (Collapse)AuthorLines
2025-05-02rustdoc: Fix doctest heuristic for main fn wrappingLeón Orell Valerian Liehr-51/+154
(cherry picked from commit 714ea10ea41e97310a1b3d90fed4cfb3e2dd6b73)
2025-05-02Fix bad handling of macros if there is already a `main` functionGuillaume Gomez-0/+23
(cherry picked from commit aa69e3a0cb8f1b2e086709a038baad6f39249150)
2025-05-02If there is a `;` alone, we consider that the doctest needs to be put inside ↵Guillaume Gomez-27/+4
a function (cherry picked from commit 3ef98a55ef95b058e55897f1b213dd965839e3ed)
2025-05-02Add regression ui test for #140162 and for #139651Guillaume Gomez-0/+28
(cherry picked from commit 81438c0b05f177ae7bc0d6511d1cc507652eb241)
2025-04-17Use `eprint!` instead of `eprintln!`Guillaume Gomez-32/+22
(cherry picked from commit f9927ee042f7d7418fbb64082272ce1feff4d895)
2025-04-17Add regression test for #137970Guillaume Gomez-0/+44
(cherry picked from commit fff2484700bb7d1fa320a666109d1868767dfa6a)
2025-03-28Rollup merge of #138104 - GuillaumeGomez:simplify-doctest-parsing, r=fmeaseMatthias Krüger-6/+35
Greatly simplify doctest parsing and information extraction The original process was pretty terrible, as it tried to extract information such as attributes by performing matches over tokens like `#!`, which doesn't work very well considering you can have `# ! [`, which is valid. Also, it now does it in one pass: if the parser is happy, then we try to extract information, otherwise we return early. r? `@fmease`
2025-03-27Correctly handle line comments in attributes and generate extern cratesGuillaume Gomez-3/+32
outside of wrapping function
2025-03-27Update rustdoc-ui testsGuillaume Gomez-3/+3
2025-03-25Rollup merge of #138877 - TaKO8Ki:enable-per-target-ignores-for-doctests, ↵Jacob Pratt-0/+20
r=notriddle Ignore doctests only in specified targets Quick fix for #138863 FIxes #138863 cc `@yotamofek` `@notriddle`
2025-03-25compiletest: Support matching on diagnostics without a spanVadim Petrochenkov-0/+24
2025-03-25ignore doctests only in specified targetsTakayuki Maeda-0/+20
add necessary lines fix ui test error
2025-03-23Rollup merge of #138293 - clubby789:doc-cfg-gate, r=GuillaumeGomezMichael Goulet-0/+49
rustdoc: Gate unstable `doc(cfg())` predicates Fixes #138113 Since the extraction process treats `cfg(true)` as having no cfg attribute, we have to do the gating during parsing; so we remove the unused `features` arg from `Cfg::matches`
2025-03-16Fix ICE: attempted to remap an already remapped filenameCharalampos Mitrodimas-0/+9
This commit fixes an internal compiler error (ICE) that occurs when rustdoc attempts to process macros with a remapped filename. The issue arose during macro expansion when the `--remap-path-prefix` option was used. Instead of passing remapped filenames through, which would trigger the "attempted to remap an already remapped filename" panic, we now extract the original local path from remapped filenames before processing them. A test case has been added to verify this behavior. Fixes #138520 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-2/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-11rustdoc: Add FIXME test for `doc_cfg` interaction with `check_cfg`clubby789-0/+16
2025-03-10rustdoc: Gate unstable `doc(cfg())` predicatesclubby789-0/+33
2025-03-10doctests: build test bundle and harness separatelyMichael Howell-1/+71
This prevents the included test case from getting at nightly-only features when run on stable. The harness builds with RUSTC_BOOTSTRAP, but the bundle doesn't.
2025-03-07Fix rustdoc testEsteban Küber-2/+2
2025-03-03Don't typeck during WF, instead check outside of WF in check_crateMichael Goulet-7/+8
2025-03-03Rollup merge of #137632 - RalfJung:rustdoc-target-features, r=workingjubileeMatthias Krüger-0/+28
rustdoc: when merging target features, keep the highest stability This addresses https://github.com/rust-lang/rust/issues/137366. (Not closing since we might consider a backport.) rustdoc wants to pretend that it runs for all targets at once and has all target features, so `tcx.rust_target_features()` will actually be all the target features. For target features that exist on multiple targets, the stability info for one of the targets will be picked (first or last in the list, I guess). All the code consuming that query has to be aware that the data is basically nonsense when running in rustdoc, but the logic checking for unstable or forbidden `#[target_feature]` attributes was not aware of that. This PR makes the `tcx.rust_target_features()` info in rustdoc slightly less nonsensical (and decidedly less random) by having the "most stable" target feature take precedent. That deals with #137366 (a conflict between a stable and a "forbidden" target feature of the same name for different targets), and also deals with the situation (that we did not seem to have yet) of a conflict between a stable and an unstable target feature of the same name. Note that if there are two unstable target features of the same name, rustdoc might still require the "wrong" nightly feature to be enabled -- but this can only possibly affect unstable code so I guess we can wait until that actually happens, and then someone will have to rewrite this entire thing to be less hacky.
2025-03-01also skip abi_required_features check in rustdocRalf Jung-3/+13
2025-02-28add testRalf Jung-0/+18
2025-02-27Move "unused_exter_crate" test from rustdoc-ui to rustdocYotam Ofek-19/+0
2025-02-27Fix test directives that were accidentally ignoredYotam Ofek-1/+0
2025-02-17Rollup merge of #137120 - ChrisDenton:its-all-relative, r=GuillaumeGomezMatthias Krüger-3/+3
Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows The problem with the error message on Windows is: - The path separators are different - The OS error message string is different Normalizing those two things makes the test pass on Windows.
2025-02-16Enable relative-path-include-bytes on WindowsChris Denton-3/+3
2025-02-15rustdoc: improve refdef handling in the unresolved link lintMichael Howell-30/+79
This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes.
2025-02-12Rollup merge of #136927 - GuillaumeGomez:add-missing-hashtag-escape, r=notriddleJacob Pratt-0/+17
Correctly escape hashtags when running `invalid_rust_codeblocks` lint Fixes #136899. We forgot to use `map_line` when we wrote this lint. r? ``@notriddle``
2025-02-12Add regression test for #136899Guillaume Gomez-0/+17
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-184/+276
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-04Rollup merge of #136274 - compiler-errors:sized-wf, r=lcnrMatthias Krüger-3/+6
Check Sizedness of return type in WF Still need to clean this up a bit. This should fix https://github.com/rust-lang/trait-system-refactor-initiative/issues/150. r? lcnr
2025-02-04Rollup merge of #134777 - saethlin:enable-more-tests-on-windows, r=NoratriebJacob Pratt-1/+1
Enable more tests on Windows As part of the discussion of https://github.com/rust-lang/compiler-team/issues/822 on Zulip, it was mentioned that problems with the i686-pc-windows-gnu target may have resulted in tests being disabled on Windows. So in this PR, I've ripped out all our `//@ ignore-windows` directives, then re-added all the ones that are definitely required based on the outcome of try-builds, and in some cases I've improved the justification or tightened the directives to `//@ ignore-msvc` or ignoring specific targets.
2025-02-04Add missing lang items in no_core tests in rustdocMichael Goulet-3/+6
2025-02-03Enable more tests on WindowsBen Kimock-1/+1
2025-01-31Rollup merge of #135860 - fmease:compiler-mv-obj-save-dyn-compat-ii, r=jieyouxuMatthias Krüger-2/+2
Compiler: Finalize dyn compatibility renaming Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME. Follow-up to #130826. Part of #130852. ~~Blocking it on #133372.~~ (merged) r? ghost
2025-01-31Rollup merge of #134531 - GuillaumeGomez:extract-doctests, ↵Matthias Krüger-1/+20
r=notriddle,aDotInTheVoid [rustdoc] Add `--extract-doctests` command-line flag Part of https://github.com/rust-lang/rust/issues/134529. It was discussed with the Rust-for-Linux project recently that they needed a way to extract doctests so they can modify them and then run them more easily (look for "a way to extract doctests" [here](https://github.com/Rust-for-Linux/linux/issues/2)). For now, I output most of `ScrapedDoctest` fields in JSON format with `serde_json`. So it outputs the following information: * filename * line * langstr * text cc `@ojeda` r? `@notriddle`
2025-01-30Give 104145, 103463, and 31948 more descriptive namesMichael Howell-0/+0
2025-01-29rustdoc: rename `issue-\d+.rs` tests to have meaningful namesMichael Howell-0/+32
2025-01-29Improve check for `--output-format` combinations and add ui regression testGuillaume Gomez-1/+4
2025-01-29Move extracted doctest code and types into its own fileGuillaume Gomez-1/+1
2025-01-29Add ui test for new rustdoc `--output-format=doctest` optionGuillaume Gomez-0/+16
2025-01-26Compiler: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-2/+2
2025-01-25Auto merge of #133154 - estebank:issue-133137, r=wesleywiserbors-9/+9
Reword resolve errors caused by likely missing crate in dep tree Reword label and add `help`: ``` error[E0432]: unresolved import `some_novel_crate` --> f704.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` | = help: if you wanted to use a crate named `some_novel_crate`, use `cargo add some_novel_crate` to add it to your `Cargo.toml` ``` Fix #133137.
2025-01-24Reword "crate not found" resolve messageEsteban Küber-9/+9
``` error[E0432]: unresolved import `some_novel_crate` --> file.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` ``` On resolve errors where there might be a missing crate, mention `cargo add foo`: ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From<nope::Thing> for Error { | ^^^^ use of unresolved module or unlinked crate `nope` | = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` ```
2025-01-22Refactor dyn-compatibility error and suggestionsTaylor Cramer-11/+13
This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
2025-01-21Auto merge of #133830 - compiler-errors:span-key, r=lcnrbors-2/+2
Rework dyn trait lowering to stop being so intertwined with trait alias expansion This PR reworks the trait object lowering code to stop handling trait aliases so funky, and removes the `TraitAliasExpander` in favor of a much simpler design. This refactoring is important for making the code that I'm writing in https://github.com/rust-lang/rust/pull/133397 understandable and easy to maintain, so the diagnostics regressions are IMO inevitable. In the old trait object lowering code, we used to be a bit sloppy with the lists of traits in their unexpanded and expanded forms. This PR largely rewrites this logic to expand the trait aliases *once* and handle them more responsibly throughout afterwards. Please review this with whitespace disabled. r? lcnr
2025-01-20Rollup merge of #135736 - fmease:rustdoc-fix-flaky-test, r=GuillaumeGomez许杰友 Jieyou Xu (Joe)-1/+2
rustdoc: Fix flaky doctest test Fixes #135660.
2025-01-19rustdoc: Fix flaky doctest testLeón Orell Valerian Liehr-1/+2
2025-01-15Rework trait expansion to happen once explicitlyMichael Goulet-2/+2