Commit graph

351 commits

Author SHA1 Message Date
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
León Orell Valerian Liehr
57b5d3af62
Compiler: Finalize dyn compatibility renaming 2025-01-26 21:20:31 +01:00
bors
203e6c127c Auto merge of #133154 - estebank:issue-133137, r=wesleywiser
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-25 11:41:21 +00:00
Esteban Küber
dd52bfc76e Reword "crate not found" resolve message
```
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-24 01:19:50 +00:00
Taylor Cramer
d00d4dfe0d Refactor dyn-compatibility error and suggestions
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-22 09:20:57 -08:00
bors
cd805f09ff Auto merge of #133830 - compiler-errors:span-key, r=lcnr
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-21 12:33:33 +00:00
许杰友 Jieyou Xu (Joe)
64768c5630
Rollup merge of #135736 - fmease:rustdoc-fix-flaky-test, r=GuillaumeGomez
rustdoc: Fix flaky doctest test

Fixes #135660.
2025-01-20 12:37:55 +08:00
León Orell Valerian Liehr
64d667ae78
rustdoc: Fix flaky doctest test 2025-01-19 18:41:11 +01:00
Michael Goulet
824a867e82 Rework trait expansion to happen once explicitly 2025-01-15 01:26:24 +00:00
Josh Triplett
ad550f86e5 Remove some empty expected files to fix blessing
https://github.com/rust-lang/rust/pull/134808 made --bless remove empty
expected files. Remove some empty files that were causing noise in
unrelated `--bless` invocations.
2025-01-12 12:49:24 +02:00
John Kåre Alsaker
4bf85c25ec Try to write the panic message with a single write_all call 2025-01-01 15:58:29 +01:00
peicuiping
09541c263e chore: fix some typos
Signed-off-by: peicuiping <ezc5@sina.cn>
2024-12-31 15:11:18 +08:00
Zalathar
835fbcbcab Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
Guillaume Gomez
2d914bed2d Add test to ensure passing --doctest_compilation_args multiple times work 2024-12-20 22:35:00 +01:00
Guillaume Gomez
2bd869082b Add regression test for --doctest-compilation-args 2024-12-20 15:17:47 +01:00
Jacob Pratt
033fbe0a47
Rollup merge of #134481 - estebank:unstable-lint-span, r=compiler-errors
Point at lint name instead of whole attr for gated lints

```
warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |          ^^^^^^^^^^^^^^^^^^
   |
   = note: the `test_unstable_lint` lint is unstable
   = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: the lint level is defined here
  --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9
   |
LL | #![warn(unknown_lints)]
   |         ^^^^^^^^^^^^^

warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |                              ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the `another_unstable_lint` lint is unstable
   = help: add `#![feature(another_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
```

This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18 21:38:11 -05:00
Esteban Küber
19e44f4db4 Point at lint name instead of whole attr for gated lints
```
warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |          ^^^^^^^^^^^^^^^^^^
   |
   = note: the `test_unstable_lint` lint is unstable
   = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: the lint level is defined here
  --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9
   |
LL | #![warn(unknown_lints)]
   |         ^^^^^^^^^^^^^

warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |                              ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the `test_unstable_lint` lint is unstable
   = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: the lint level is defined here
  --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9
   |
LL | #![warn(unknown_lints)]
   |         ^^^^^^^^^^^^^
```

This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18 19:27:44 +00:00
Jacob Pratt
52b4557639
Rollup merge of #134202 - nnethercote:rm-existing_doc_keyword, r=GuillaumeGomez
Remove `rustc::existing_doc_keyword` lint

The check doesn't require a lint.

r? ``@GuillaumeGomez``
2024-12-17 05:36:52 -05:00
Nicholas Nethercote
121e87bf14 Remove rustc::existing_doc_keyword lint.
`CheckAttrVisitor::check_doc_keyword` checks `#[doc(keyword = "..")]`
attributes to ensure they are on an empty module, and that the value is
a non-empty identifier.

The `rustc::existing_doc_keyword` lint checks these attributes to ensure
that the value is the name of a keyword.

It's silly to have two different checking mechanisms for these
attributes. This commit does the following.
- Changes `check_doc_keyword` to check that the value is the name of a
  keyword (avoiding the need for the identifier check, which removes a
  dependency on `rustc_lexer`).
- Removes the lint.
- Updates tests accordingly.

There is one hack: the `SelfTy` FIXME case used to used to be handled by
disabling the lint, but now is handled with a special case in
`is_doc_keyword`. That hack will go away if/when the FIXME is fixed.

Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2024-12-17 13:56:10 +11:00
Matthias Krüger
9451a6132a
Rollup merge of #134260 - GuillaumeGomez:doctest-attrs, r=notriddle
Correctly handle comments in attributes in doctests source code

Fixes https://github.com/rust-lang/rust/issues/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``
2024-12-16 20:00:17 +01:00
Guillaume Gomez
c367cc3ef5 Remove unneeded handling of backlines in doctest attributes 2024-12-16 17:59:07 +01:00
Guillaume Gomez
2383985342 Also handle cases where attributes are unclosed 2024-12-16 13:59:41 +01:00
Guillaume Gomez
9c4a61ff52 Add ui regression test for #134221 2024-12-16 11:47:56 +01:00
Esteban Küber
9f1044ef76 Account for /// when rendering multiline spans
Don't consider `///` and `//!` docstrings to be empty for the purposes of multiline span rendering.
2024-12-13 18:48:33 +00:00
Esteban Küber
49a22a4245 Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
Esteban Küber
65a54a7f27 Tweak multispan rendering
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-12 23:36:27 +00:00
Michael Howell
b5318549c7 rustdoc: rename issue-\d+.rs tests to have meaningful names 2024-12-08 21:59:23 -07:00
Michael Howell
999aed4bff Add URL to test cases 2024-12-08 21:39:48 -07:00
Esteban Küber
af09423967 fix rustdoc test 2024-12-07 21:37:15 +00:00
Esteban Küber
3f2a63a68b Use trait name instead of full constraint in suggestion message
```
help: consider restricting type parameter `T` with traits `Copy` and `Trait`
   |
LL | fn duplicate_custom<T: Copy + Trait>(t: S<T>) -> (S<T>, S<T>) {
   |                      ++++++++++++++
```

```
help: consider restricting type parameter `V` with trait `Copy`
   |
LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V {
   |                  +++++++++++++++++++
```
2024-12-07 21:29:58 +00:00
Esteban Küber
d13c34828e reword trait bound suggestion message to include the bounds 2024-12-07 21:26:20 +00:00
Matthias Krüger
2713dc2641
Rollup merge of #133595 - GuillaumeGomez:missing_doc_code_examples, r=notriddle
Do not emit `missing_doc_code_examples` rustdoc lint on module and a few other items

It doesn't make sense to expect modules to have code examples. Same goes for:

 * Trait aliases
 * Foreign items
 * Associated types and constants

Should make the use of this lint a bit nicer.

r? ``@notriddle``
2024-12-01 14:30:09 +01:00
Matthias Krüger
53bc38b3fe
Rollup merge of #133584 - ehuss:more-2024-unstable-options, r=compiler-errors
Update more 2024 tests to remove -Zunstable-options

This removes `-Zunsable-options` from more tests that I missed in https://github.com/rust-lang/rust/pull/133349.
2024-11-29 16:02:23 +01:00
Nicholas Nethercote
d626f6a2f4 Remove last vestiges of HybridBitSet.
This is in a test where the arrangement of backticks matters, but the
exact words do not.
2024-11-29 17:23:34 +11:00
Eric Huss
6005d1c9f7 Update more 2024 tests to remove -Zunstable-options 2024-11-28 14:32:45 -08:00
Guillaume Gomez
7cf3f8ba7a Do not emit missing_doc_code_examples rustdoc lint on module and a few other items 2024-11-28 21:22:06 +01:00
Michael Goulet
b0ed5ac730
Rollup merge of #133394 - compiler-errors:dyn-more-errors, r=lcnr
Bail on more errors in dyn ty lowering

If we have more than one principal trait, or if we have a principal trait with errors in it, then bail with `TyKind::Error` rather than attempting lowering. Lowering a dyn trait with more than one principal just arbitrarily chooses the first one and drops the subsequent ones, and lowering a dyn trait path with errors in it is just kinda useless.

This suppresses unnecessary errors which I think is net-good, but also is important to make sure that we don't end up leaking `{type error}` in https://github.com/rust-lang/rust/issues/133388 error messaging :)

r? types
2024-11-26 12:03:44 -05:00
Michael Goulet
cfa8fcbf58 Dont create trait object if it has errors in it 2024-11-23 23:31:30 +00:00
bohan
30d68eb9aa only store valid proc marco item for doc link 2024-11-23 13:41:27 +08:00