Repository navigation
Rollup of 10 pull requests - #165312
Closed
jhpratt wants to merge 27 commits into
Closed
Rollup of 10 pull requests#165312jhpratt wants to merge 27 commits into
jhpratt wants to merge 27 commits into
Conversation
``` error[E0425]: cannot find function `bar` in this scope --> $DIR/suggest-self-2.rs:9:9 | LL | bar(&&self, 102); | ^^^ | help: try calling `bar` as a method | LL - bar(&&self, 102); LL + self.bar(102); | ```
The old message, “help: use `let _ = ...` to ignore the resulting value” (or its variation with `let _unused` for `needs_drop` values), contains no indication that this is something that you might not want to do, and in fact can be read as saying that one *should* do this. The new message, “if you wish to disregard this recommendation, use `let _ = ...` to ignore the value”, is intended to make it clear that this is a choice.
Use more accurate span when suggesting to remove guard and body of a never-pattern match arm (`feature(never_patterns)`]. ``` error: a guard on a never pattern will never be run --> $DIR/ICE-119271-never-arm-attr-in-guard.rs:8:13 | LL | false | ^^^^^ | help: remove the guard, leaving only the pattern | LL - Some(!) LL - LL - if #[deny(unused_mut)] LL - false LL + Some(!) | ```
* Add regression test * Recover inner attributes in algebraic data types * Try to recover after every field and variant
We should not forbid users from experimenting on their own forks. https://x.com/0xalpharush/status/2116964999000478125
… r=fmease
Recover inner attributes in algebraic data types
Previously, if you'd put an inner attribute in an empty ADT, such as a struct:
```rust
struct Test1 {
#![inline]
}
```
You'd get the following errors
```
error: an inner attribute is not permitted in this context
--> src/lib.rs:5:5
|
5 | #![cfg(false)]
| ^^^^^^^^^^^^^^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
= note: outer attributes, like `#[test]`, annotate the item following them
error: expected identifier, found `}`
--> src/lib.rs:6:1
|
4 | struct Test3 {
| ----- while parsing this struct
5 | #![cfg(false)]
6 | }
| ^ expected identifier
error: could not compile `rust-test` (lib) due to 2 previous errors
```
The second error is spurious. It was caused by us only recovering inner attributes just before parsing a field, meaning if we see an inner attribute and recover we expect a field next. This PR fixes that by recovering inner attributes just after the curly brace as well.
Make the suggestion message of `unused_must_use` scarier. The old message, “help: use `let _ = ...` to ignore the resulting value”, contains no indication that this is something that you might not want to do, and in fact can be read as saying that one *should* do this. The new message, “help: if you wish to disregard this recommendation and immediately drop the value, use `let _ = ...`”, is intended to make it clear that this is a choice, and choosing it has the particular effect of immediately dropping the value. A possible further improvement, not part of this change, might be to distinguish between types that are `must_use` and have a destructor (whose side-effects are likely relevant), and types that are `must_use` and do not have a destructor, where the timing is irrelevant and the consequence is just ignoring information that was provided. However, not every destructor is relevant to `must_use`; for example, `Result<(), Box<dyn Error>>` has a destructor and is `must_use`, but the destructor is only managing memory for the error value and it has no side effects relevant to the caller (unless the error in the box has side effects of its own). Inspired by [#t-lang > Lint for assigning drop guards to _](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Lint.20for.20assigning.20drop.20guards.20to.20_/with/624036822) @rustbot label +A-lints +L-unused_must_use
…mease
Use verbose suggestion for type literal with wrong syntax
```
error[E0423]: cannot find value `StructWithFields` in crate `xcrate_unit_struct`
--> $DIR/unit-struct.rs:9:33
|
LL | let _ = xcrate_unit_struct::StructWithFields;
| ^^^^^^^^^^^^^^^^
|
::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1
|
LL | pub struct StructWithFields {
| --------------------------- `xcrate_unit_struct::StructWithFields` defined here
|
= note: a struct named `xcrate_unit_struct::StructWithFields` exists in another namespace
help: use struct literal syntax instead
|
LL | let _ = xcrate_unit_struct::StructWithFields { foo: val };
| ++++++++++++
```
```
error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor`
--> $DIR/match-pattern-field-mismatch-2.rs:12:11
|
LL | enum Color {
LL | NoColor,
| ------- `Color::NoColor` defined here
...
LL | Color::NoColor(_) => { }
| ^^^^^^^^^^^^^^^^^
|
help: use the unit struct syntax instead
|
LL - Color::NoColor(_) => { }
LL + Color::NoColor => { }
|
```
…tern-comma-suggestion, r=fmease Fix multiple pattern comma suggestions in diagnostics `skip_pat_list` and `recover_unexpected_comma` is on cold path, so there will be no perf issue here.
…d-qualifications-wildcard, r=fmease Don't lint unused_qualifications when the unqualified path is ambiguous Fixes rust-lang#163310
… r=fmease Tweak suggestion of "unreachable due to never pattern" Use more accurate span when suggesting to remove guard and body of a never-pattern match arm (`feature(never_patterns)`]. ``` error: a guard on a never pattern will never be run --> $DIR/ICE-119271-never-arm-attr-in-guard.rs:8:13 | LL | false | ^^^^^ | help: remove the guard, leaving only the pattern | LL - Some(!) LL - LL - if #[deny(unused_mut)] LL - false LL + Some(!) | ```
Improve span for unused_mut lint Closes rust-lang#165269 I basically used trim to avoid the overlap of spans mentioned on the issue. I kept the whitespace in the "mut" span since the fix removes the whole span and not removing the whitespace would mean for uglier code after fix. If this is really important, I could add an extra span to the diagnostic struct, but I'll wait on feedback.
…gjubilee Forward `AbiAlign` `Debug` impl to `Align` The `Debug` output of `AbiAlign` shows up in UI test stderr output via `LayoutData`. The first commit of this PR changes `Debug` impl of `AbiAlign` to directly forward to `Align`, meaning that the future change from `AbiAlign` to `Align` won't affect test output. The second commit removes unused `//@ normalize-stderr` directives for preferred alignment. Commits are easiest to review individually - most of the changes are just blessing tests. r? @workingjubilee
…ecks-desc, r=chenyukang unstable.rs: add missing `]` in description of `cfg_ub_checks`
…=jieyouxu Clarify AGENTS.md around pushing to a fork We should not forbid users from experimenting on their own forks. https://x.com/0xalpharush/status/2116964999000478125 r? @jyn514
Member
Author
|
@bors r+ p=5 force |
Contributor
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
|
PR #163764, which is a member of this rollup, was unapproved. This rollup was thus unapproved. |
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:
unused_must_usescarier. #162819 (Make the suggestion message ofunused_must_usescarier.)AbiAlignDebugimpl toAlign#165285 (ForwardAbiAlignDebugimpl toAlign)]in description ofcfg_ub_checks#165294 (unstable.rs: add missing]in description ofcfg_ub_checks)r? @ghost
Create a similar rollup