Commit graph

389 commits

Author SHA1 Message Date
Guillaume Gomez
88a5e1ef68 Add regression test for #140026 2025-04-19 21:10:40 +02:00
Matthias Krüger
0de803c38d
Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, r=davidtwco,Urgau,traviscross
Stabilize `cfg_boolean_literals`

Closes #131204
`@rustbot` labels +T-lang +I-lang-nominated
This will end up conflicting with the test in #138293 so whichever doesn't land first will need updating

--

# Stabilization Report

## General design

### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?

[RFC 3695](https://github.com/rust-lang/rfcs/pull/3695), none.

### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

None

### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?

None

## Has a call-for-testing period been conducted? If so, what feedback was received?

Yes; only positive feedback was received.

## Implementation quality

### Summarize the major parts of the implementation and provide links into the code (or to PRs)

Implemented in [#131034](https://github.com/rust-lang/rust/pull/131034).

### Summarize existing test coverage of this feature

- [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](6d71251cf9/tests/ui/cfg/true-false.rs)
- [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](6d71251cf9/tests/ui/cfg/raw-true-false.rs)
- [Interaction with the unstable `#[doc(cfg(..))]` feature](6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs)
- [Denying `--check-cfg=cfg(true/false)`](6d71251/tests/ui/check-cfg/invalid-arguments.rs)
- Ensuring `--cfg false` on the command line doesn't change the meaning of `cfg(false)`: `tests/ui/cfg/cmdline-false.rs`
- Ensuring both `cfg(true)` and `cfg(false)` on the same item result in it being disabled: `tests/ui/cfg/both-true-false.rs`

### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?

The above mentioned issue; it should not block as it interacts with another unstable feature.

### What FIXMEs are still in the code for that feature and why is it ok to leave them there?

None

### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization
- `@clubby789` (RFC)
- `@Urgau` (Implementation in rustc)

### Which tools need to be adjusted to support this feature. Has this work been done?

`rustdoc`'s  unstable`#[doc(cfg(..)]` has been updated to respect it. `cargo` has been updated with a forward compatibility lint to enable supporting it in cargo once stabilized.

## Type system and execution rules

### What updates are needed to the reference/specification? (link to PRs when they exist)

A few lines to be added to the reference for configuration predicates, specified in the RFC.
2025-04-17 06:25:15 +02:00
bors
07d3fd1d9b Auto merge of #138603 - xizheyin:issue-137405, r=chenyukang
Report line number of test when should_panic test failed

Closes #137405

---

try-job: x86_64-gnu-llvm-19-3
try-job: test-various
2025-04-14 13:33:44 +00:00
xizheyin
c73598f0fb Report span of test when should_panic test failed
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-14 10:36:11 +08:00
Vadim Petrochenkov
93bee0789a UI tests: migrate remaining compile time error-patterns to line annotations
when possible.
2025-04-13 21:48:53 +03:00
bors
71b68da1bd Auto merge of #139578 - ferrocene:pa-compiletest-edition, r=jieyouxu
Fix breakage when running compiletest with `--test-args=--edition=2015`

Compiletest has an `--edition` flag to change the default edition tests are run with. Unfortunately no test suite successfully executes when that flag is passed. If the edition is set to something greater than 2015 the breakage is expected, since the test suite currently supports only edition 2015 (Ferrous Systems will open an MCP about fixing that soonish). Surprisingly, the test suite is also broken if `--edition=2015` is passed to compiletest. This PR focuses on fixing the latter.

This PR fixes the two categories of failures happening when `--edition=2015` is passed:

* Some edition-specific tests set their edition through `//@ compile-flags` instead of `//@ edition`. Compiletest doesn't parse the compile flags, so it would see no `//@ edition` and add another `--edition` flag, leading to a rustc error.
* Compiletest would add the edition after `//@ compile-flags`, while some tests depend on flags passed to `//@ compile-flags` being the last flags in the rustc invocation.

Note that for the first category, I opted to manually go and replace all `//@ compile-flags` setting an edition with an explicit `//@ edition`. We could've changed compiletest to instead check whether an edition was set in `//@ compile-flags`, but I thought it was better to enforce a consistent way to set the edition in tests.

I also added the edition to the stamp, so that changing `--edition` results in tests being re-executed.

r? `@jieyouxu`
2025-04-11 10:53:45 +00:00
Pietro Albini
cd371b90e2
replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
Noah Lev
8b227a42fa rustdoc: Enable Markdown extensions when looking for doctests
We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in #139064.
2025-04-09 13:04:57 -04:00
Vadim Petrochenkov
b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Matthias Krüger
cfc2297cfc
Rollup merge of #139328 - GuillaumeGomez:fix-panic-output-137970, r=fmease
Fix 2024 edition doctest panic output

Fixes #137970.

The problem was that the output was actually displayed by rustc itself because we're exiting with `Result<(), String>`, and the display is really not great. So instead, we get the output, we print it and then we return an `ExitCode`.

r? ````@aDotInTheVoid````
2025-04-04 21:54:57 +02:00
clubby789
984c51f6a1 Stabilize cfg_boolean_literals 2025-04-03 18:10:48 +00:00
Guillaume Gomez
f9927ee042 Use eprint! instead of eprintln! 2025-04-03 19:37:18 +02:00
Guillaume Gomez
fff2484700 Add regression test for #137970 2025-04-03 17:21:03 +02:00
Vadim Petrochenkov
4d64990690 compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
Matthias Krüger
ad87732cae
Rollup merge of #138104 - GuillaumeGomez:simplify-doctest-parsing, r=fmease
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-28 12:59:55 +01:00
Guillaume Gomez
123ea25542 Correctly handle line comments in attributes and generate extern crates
outside of wrapping function
2025-03-27 11:18:43 +01:00
Guillaume Gomez
01fb7c3ac6 Update rustdoc-ui tests 2025-03-27 11:18:43 +01:00
Jacob Pratt
fc8fc051b6
Rollup merge of #138877 - TaKO8Ki:enable-per-target-ignores-for-doctests, r=notriddle
Ignore doctests only in specified targets

Quick fix for #138863

FIxes  #138863

cc `@yotamofek` `@notriddle`
2025-03-25 20:34:48 -04:00
Vadim Petrochenkov
8d5109aa6e compiletest: Support matching on diagnostics without a span 2025-03-25 17:33:09 +03:00
Takayuki Maeda
90c541d637 ignore doctests only in specified targets
add necessary lines

fix ui test error
2025-03-25 15:39:41 +09:00
Michael Goulet
856ba39bd9
Rollup merge of #138293 - clubby789:doc-cfg-gate, r=GuillaumeGomez
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-23 14:59:30 -04:00
Charalampos Mitrodimas
b14810669a Fix ICE: attempted to remap an already remapped filename
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-16 23:37:09 +01:00
Esteban Küber
f0b8e13b59 Do not suggest using -Zmacro-backtrace for builtin macros
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-14 19:50:03 +00:00
clubby789
85b1116a18 rustdoc: Add FIXME test for doc_cfg interaction with check_cfg 2025-03-11 17:03:00 +00:00
clubby789
28bd22c3d9 rustdoc: Gate unstable doc(cfg()) predicates 2025-03-10 14:18:56 +00:00
Michael Howell
9cf531d26f
doctests: build test bundle and harness separately
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-10 01:47:36 +01:00
Esteban Küber
cb82b79f02 Fix rustdoc test 2025-03-07 17:55:08 +00:00
Michael Goulet
0baee2432a Don't typeck during WF, instead check outside of WF in check_crate 2025-03-03 23:09:42 +00:00
Matthias Krüger
962e492847
Rollup merge of #137632 - RalfJung:rustdoc-target-features, r=workingjubilee
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-03 06:41:34 +01:00
Ralf Jung
4c939db0e7 also skip abi_required_features check in rustdoc 2025-03-01 15:14:02 +01:00
Ralf Jung
dc04c0ca48 add test 2025-02-28 16:51:53 +01:00
Yotam Ofek
0881dba5d3 Move "unused_exter_crate" test from rustdoc-ui to rustdoc 2025-02-27 13:22:46 +00:00
Yotam Ofek
660241d1d4 Fix test directives that were accidentally ignored 2025-02-27 13:22:16 +00:00
Matthias Krüger
7cae8e1f50
Rollup merge of #137120 - ChrisDenton:its-all-relative, r=GuillaumeGomez
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-17 06:38:15 +01:00
Chris Denton
95a5ecc995
Enable relative-path-include-bytes on Windows 2025-02-16 10:40:04 +00:00
Michael Howell
61a97448e5 rustdoc: improve refdef handling in the unresolved link lint
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-15 12:21:35 -07:00
Jacob Pratt
9fe0d25fcb
Rollup merge of #136927 - GuillaumeGomez:add-missing-hashtag-escape, r=notriddle
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-12 20:10:01 -05:00
Guillaume Gomez
17cf100f11 Add regression test for #136899 2025-02-12 19:46:07 +01:00
Esteban Küber
f0845adb0c Show diff suggestion format on verbose replacement
```
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-10 20:21:39 +00:00
Matthias Krüger
a8ecb79d19
Rollup merge of #136274 - compiler-errors:sized-wf, r=lcnr
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-04 18:49:37 +01:00
Jacob Pratt
2a8a1911da
Rollup merge of #134777 - saethlin:enable-more-tests-on-windows, r=Noratrieb
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-04 05:36:50 -05:00
Michael Goulet
36839759ce Add missing lang items in no_core tests in rustdoc 2025-02-04 01:05:31 +00:00
Ben Kimock
7dfc786df1 Enable more tests on Windows 2025-02-03 10:39:32 -05:00
Matthias Krüger
308ea7120b
Rollup merge of #135860 - fmease:compiler-mv-obj-save-dyn-compat-ii, r=jieyouxu
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-31 12:28:15 +01:00
Matthias Krüger
86595e4c88
Rollup merge of #134531 - GuillaumeGomez:extract-doctests, 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-31 12:28:15 +01:00
Michael Howell
a1a55a2e0a Give 104145, 103463, and 31948 more descriptive names 2025-01-30 12:05:31 -07:00
Michael Howell
eb457da5ca rustdoc: rename issue-\d+.rs tests to have meaningful names 2025-01-29 11:38:15 -07:00
Guillaume Gomez
b7951380ca Improve check for --output-format combinations and add ui regression test 2025-01-29 15:18:14 +01:00
Guillaume Gomez
43bf52989a Move extracted doctest code and types into its own file 2025-01-29 13:57:27 +01:00
Guillaume Gomez
7fa2094cb1 Add ui test for new rustdoc --output-format=doctest option 2025-01-29 13:57:27 +01:00