Rollup of 6 pull requests#156652
Closed
GuillaumeGomez wants to merge 19 commits into
Closed
Conversation
…r` is found This commit adds a diagnostic suggestion to help users who forget to call `.collect()` when they have an iterator and the function or variable expects a `String`. The logic checks if the expected type is `std::string::String` and if the found type implements the `Iterator` trait, if so the compiler provides a suggestion to add `.collect()` Includes also a UI test to verify if the suggestion appears correctly
Co-authored-by: Qai Juang <qaijuang@gmail.com>
Using rust-lang/rustfmt#6893, reformat the codebase. The result is that matches that *would have* been formatted under normal circumstances get their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR. Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime.
Thanks VSCode!
It has a single call site.
It's always `None`.
It was only used by rustdoc and doesn't seem like it was necessary there. No tests fail at least.
`LintExpectationId` has two variants, `Unstable` and `Stable`. There are some places where both variants are possible, but there are also places where only one of `Unstable` or `Stable` is possible. This commit encodes this into the type system by introducing new types `UnstableLintExpectationId` and `StableLintExpectationId`. The variants of `LintExpectationId` now enclose these. This makes it clearer what values are possible where. Other things of note: - `LintLevelsProvider` gets an associated type and some method changes. - `LintContext` gets an associated type. - `LevelSpec` is made generic. `UnstableLevelSpec` and `StableLevelSpec` typedefs are added. - The unstable types are now guaranteed by the type system to never be stably hashed. Previously this was a runtime check.
I find these make the code harder to understand.
Describing things that took me a while to work out.
…notriddle Remove driver_lint_caps It was only used by rustdoc and doesn't seem like it was necessary there. No tests fail at least. r? rust-lang/rustdoc
…ing, r=estebank compiler: suggest `.collect()` when `String` is expected and `Iterator` is found This commit adds a diagnostic suggestion to help users who forget to call `.collect()` when they have an iterator and the function or variable expects a `String`. The logic checks if the expected type is `std::string::String` and if the found type implements the `Iterator` trait, if so the compiler provides a suggestion to add `.collect()` Includes also a UI test to verify if the suggestion appears correctly
[style] rustfmt `match`es with comments in or-patterns Using rust-lang/rustfmt#6893, I reformatted the whole codebase. The result is that `match`es that *should have* been formatted under normal circumstances but are getting skipped now got their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR. Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime. (Introduced and) removed a bunch of stray backticks \` likely left after an editor autoclosed the intended closing \`, resulting in <code>\`name\`\`</code> in comments.
… r=GuillaumeGomez Split `LintExpectationId`s This PR makes clearer where stable and unstable `LintExpectationIds` can occur, plus a few other small cleanups. Details in individual commits. r? @GuillaumeGomez
…=mejrs Test EII UI tests with prefer-dynamic Tracking issue: rust-lang#125418 Remove `no-prefer-dynamic` from the EII UI tests now that rust-lang#153648 fixed exporting EII declaration aliases from dylibs. Fixes rust-lang#151271. Tested with: ```sh python3 x.py test tests/ui/eii --force-rerun ```
…est, r=mu001999 Add regression test for issue rust-lang#41261 Adds a regression test for rust-lang#41261.
Member
Author
|
@bors r+ p=5 rollup=never |
Contributor
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
May 16, 2026
Rollup of 6 pull requests Successful merges: - #152852 (Remove driver_lint_caps) - #156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - #156518 ([style] rustfmt `match`es with comments in or-patterns) - #156596 (Split `LintExpectationId`s) - #156577 (Test EII UI tests with prefer-dynamic) - #156633 (Add regression test for issue #41261)
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
|
💔 Test for 41c0bc7 failed: CI. Failed job:
|
Member
Author
|
I have no idea where the failure seems to come from. Closing and let's see which PR will fail... |
Contributor
|
This pull request was unapproved due to being closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
.collect()whenStringis expected andIteratoris found #156121 (compiler: suggest.collect()whenStringis expected andIteratoris found)matches with comments in or-patterns #156518 ([style] rustfmtmatches with comments in or-patterns)LintExpectationIds #156596 (SplitLintExpectationIds)r? @ghost
Create a similar rollup