Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #134492

Merged
merged 28 commits into from
Dec 19, 2024
Merged

Rollup of 8 pull requests #134492

merged 28 commits into from
Dec 19, 2024

Conversation

jhpratt
Copy link
Member

@jhpratt jhpratt commented Dec 19, 2024

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

jieyouxu and others added 28 commits December 17, 2024 19:09
- Move `tests/ui/attr-bad-crate-attr.rs` to `tests/ui/attributes/`.
- Briefly document test intent add link to relevant Reference docs.
- Move `tests/ui/attr-shebang.rs` to `tests/ui/attributes/`.
- Downgrade test to `check-pass`, this would fail very early if the
  parser did not accept `#![..]` attributes.
- Briefly document test intent.
- Move `tests/ui/attr-usage-inline.rs` to `tests/ui/attributes/inline/`.
- Briefly document test intent.
- Drop unnecessary `#[allow(dead_code)]` as this is allowed-by-default
  for ui test suite.
- Move `tests/ui/attrs-resolution-errors.rs` to `tests/ui/resolve/`.
- Document test intent.
- Rename test to `attr-macros-positional-rejection.rs` to better reflect
  test intent.
- Move `tests/ui/attrs-resolution.rs` to `tests/ui/resolve/`.
- Document test intent.
- Rename test to `non-macro-attrs-accepted.rs` to better reflect test
  intent.
This PR aims to improve the testing coverage for
`#[diagnostic::do_not_recommend]`. It ensures that all tests are run for
the old and new solver to verify that the behaviour is the same for both
variants. It also adds two new tests:

* A test with 4 traits having wild card impl for each other, with
alternating `#[diagnostic::do_not_recommend]` attributse
* A test with a lifetime dependend wild card impl, which is something
that's not supported yet
This commit adds a check that verifies that no arguments are passed to
`#[diagnostic::do_not_recommend]`. If we detect arguments we emit a warning.
This commit seeks to stabilize the `#[diagnostic::do_not_recommend]`
attribute.
This attribute was first proposed as `#[do_not_recommend`] attribute in
RFC 2397 (rust-lang/rfcs#2397). It gives the
crate authors the ability to not suggest to the compiler to not show
certain traits in it's error messages. With the presence of the
`#[diagnostic]` tool attribute namespace it was decided to move the
attribute there, as that lowers the amount of guarantees the compiler
needs to give about the exact way this influences error messages. It
turns the attribute into a hint which can be ignored. In addition to the
original proposed functionality this attribute now also hides the marked
trait in help messages ("This trait is implemented by: ").
The attribute does not accept any argument and can only be placed on
trait implementations. If it is placed somewhere else a lint warning is
emitted and the attribute is otherwise ignored. If an argument is
detected a lint warning is emitted and the argument is ignored. This
follows the rules outlined by the diagnostic namespace.

This attribute allows crates like diesel to improve their error messages
drastically. The most common example here is the following error
message:

```
error[E0277]: the trait bound `&str: Expression` is not satisfied
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>`
   |
   = help: the following other types implement trait `Expression`:
             Bound<T>
             SelectInt
note: required for `&str` to implement `AsExpression<Integer>`
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13
   |
LL | impl<T, ST> AsExpression<ST> for T
   |             ^^^^^^^^^^^^^^^^     ^
LL | where
LL |     T: Expression<SqlType = ST>,
   |        ------------------------ unsatisfied trait bound introduced here
```

By applying the new attribute to the wild card trait implementation of
`AsExpression` for `T: Expression` the error message becomes:

```
error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied
  --> $DIR/as_expression.rs:55:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str`
   |
   = help: the trait `AsExpression<Text>` is implemented for `&str`
   = help: for that trait implementation, expected `Text`, found `Integer`
```

which makes it much easier for users to understand that they are facing
a type mismatch.

Other explored example usages included

* This standard library error message: rust-lang#128008
* That bevy derived example:
https://github.com/rust-lang/rust/blob/e1f306899514ea80abc1d1c9f6a57762afb304a3/tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.rs (No
more tuple pyramids)

Fixes rust-lang#51992
Signed-off-by: acceptacross <csqcqs@gmail.com>
```
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.
Signed-off-by: leejaehong <jaehong2.lee@samsung.com>
…nd_final_tests, r=compiler-errors

Stabilize `#[diagnostic::do_not_recommend]`

This PR seeks to stabilize the `#[diagnostic::do_not_recommend]`attribute.

This attribute was first proposed as `#[do_not_recommend`] attribute in RFC 2397 (rust-lang/rfcs#2397). It gives the crate authors the ability to not suggest to the compiler to not show certain traits in its error messages.

With the presence of the `#[diagnostic]` tool attribute namespace it was decided to move the attribute there, as that lowers the amount of guarantees the compiler needs to give about the exact way this influences error messages. It turns the attribute into a hint which can be ignored. In addition to the original proposed functionality this attribute now also hides the marked trait in help messages ("This trait is implemented by: ").

The attribute does not accept any argument and can only be placed on trait implementations. If it is placed somewhere else a lint warning is emitted and the attribute is otherwise ignored. If an argument is detected a lint warning is emitted and the argument is ignored. This follows the rules outlined by the diagnostic namespace.

This attribute allows crates like diesel to improve their error messages drastically. The most common example here is the following error message:

```
error[E0277]: the trait bound `&str: Expression` is not satisfied
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>`
   |
   = help: the following other types implement trait `Expression`:
             Bound<T>
             SelectInt
note: required for `&str` to implement `AsExpression<Integer>`
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13
   |
LL | impl<T, ST> AsExpression<ST> for T
   |             ^^^^^^^^^^^^^^^^     ^
LL | where
LL |     T: Expression<SqlType = ST>,
   |        ------------------------ unsatisfied trait bound introduced here
```

By applying the new attribute to the wild card trait implementation of
`AsExpression` for `T: Expression` the error message becomes:

```
error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied
  --> $DIR/as_expression.rs:55:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str`
   |
   = help: the trait `AsExpression<Text>` is implemented for `&str`
   = help: for that trait implementation, expected `Text`, found `Integer`
```

which makes it much easier for users to understand that they are facing a type mismatch.

Other explored example usages include:

* This standard library error message: rust-lang#128008
* That bevy derived example:
https://github.com/rust-lang/rust/blob/e1f306899514ea80abc1d1c9f6a57762afb304a3/tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.rs (No
more tuple pyramids)

Fixes rust-lang#51992

r? ``@compiler-errors``

This PR also adds a few more tests, makes sure that all the tests are run for the old and new trait solver and adds a check that the attribute does not contain arguments.
…errors

-Znext-solver: modify candidate preference rules

This implements the design proposed in the FCP in rust-lang#132325 and matches the old solver behavior. I hope the inline comments are all sufficiently clear, I personally think this is a fairly clear improvement over the existing approach using `fn discard_impls_shadowed_by_env`. This fixes rust-lang/trait-system-refactor-initiative#96.

This also fixes rust-lang#133639 which encounters an ICE in negative coherence when evaluating the where-clause. Given the features required to trigger this ICE 🤷

r? ``@compiler-errors``
Update books

## rust-lang/book

21 commits in 9900d976bbfecf4e8124da54351a9ad85ee3c7f3..ad2011d3bcad9f152d034faf7635c22506839d58
2024-12-16 16:11:34 UTC to 2024-12-05 19:19:24 UTC

- Ch. 10: clarify note about compiler errors and `'static` (rust-lang/book#4164)
- Introduce `let`-`else` statement (rust-lang/book#3702)
- Fix misleading explanation of comma in `$(),*` (rust-lang/book#3800)
- ch18-03: Matching Named Variables: mention `if let`/`while let` (rust-lang/book#3110)
- Ch. 4: Rephrase/clarify paragraph on reference scope (rust-lang/book#3688)
- Simplify note about functions in ch13-01-closures.md (rust-lang/book#3699)
- fix: make the reason more understandable (rust-lang/book#4074)
- Fixed grammatical error in the comment on line 22 (rust-lang/book#3180)
- ch17-02: Monomorphization applies to generics in general  (rust-lang/book#3367)
- Ch. 21: Use `Vec::drain` to teach alternatives to `Option` (rust-lang/book#4159)
- fix(typo): correct punctuation in ch15-06-reference-cycles.md (rust-lang/book#4155)
- Ch. 20: show both `impl Fn` and `Box<dyn Fn>` (rust-lang/book#4152)
- Add `use super::*;` to unit-test examples. (rust-lang/book#4151)
- Remove emphasis on four-space indents (rust-lang/book#4150)
- Fix `.git-blame-ignore-revs` file (rust-lang/book#4149)
- Rust 2024: distinguish `unsafe fn` vs. `unsafe` blocks (rust-lang/book#4148)
- Update README.md typo (rust-lang/book#4146)
- Ch. 15.5: account for improved error message (rust-lang/book#4142)
- Document use of rustfmt and dprint for formatting (rust-lang/book#4138)
- tools: fix nostarch build reference to mdbook-trpl (rust-lang/book#4137)
- Revise sentence to not refer to two subjects as it (rust-lang/book#4136)

## edition-guide

6 commits in 128669297c8a7fdf771042eaec18b8adfaeaf0cd..bc4ce51e1d4dacb9350a92e95f6159a42de2f8c6
2024-12-03 22:02:43 +0000 to 2024-12-18 05:34:59 +0000

- Add chapter for 2024 match ergonomics reservations (rust-lang/edition-guide#349)
- Re-title "Additions to the prelude" (rust-lang/edition-guide#348)
- Show tail expression temporary example that fails in 2024 (rust-lang/edition-guide#345)
- Add more triagebot labeling support (rust-lang/edition-guide#346)
- 2024: Assignment operator RHS indentation (rust-lang/edition-guide#341)
- 2024: Add chapter on single-line `where` clauses (rust-lang/edition-guide#340)

## rust-lang/nomicon

1 commits in 0674321898cd454764ab69702819d39a919afd68..97e84a38c94bf9362b11284c20b2cb4adaa1e868
2024-12-10 02:41:27 UTC to 2024-12-10 02:41:27 UTC

- races.md: data race -> race condition to violate memory safety (rust-lang/nomicon#470)

## reference

8 commits in ede56d1bbe132bac476b5029cd6d7508ca9572e9..9f41bc11342d46544ae0732caf14ec0bcaf27376
2024-12-03 22:26:55 +0000 to 2024-12-18 23:04:30 +0000

- `coverage` attribute (rust-lang/reference#1628)
- Clarify that `extern crate foo as føø` is allowed (rust-lang/reference#1697)
- Fix rule auto-linking on Windows (rust-lang/reference#1698)
- Reflect rust#133422 & rust#133587 to inline assembly documentation (rust-lang/reference#1695)
- Describe async closures (rust-lang/reference#1692)
- Update closures for edition 2021 disjoint closure capturing (rust-lang/reference#1521)
- Fix paragraphs with trailing `\1` (rust-lang/reference#1696)
- Add triagebot autolabel (rust-lang/reference#1694)

## rust-lang/rust-by-example

1 commits in e1d1f2cdcee4d52b9a01ff7c448be4372a377b70..76406337f4131253443aea0ed7e7f451b464117c
2024-12-07 00:24:30 UTC to 2024-12-07 00:24:30 UTC

- Fix rust-lang#1900 (rust-lang/rust-by-example#1901)

## rust-lang/rustc-dev-guide

9 commits in b21d99b..7f7ba48f04abc2ad25e52f30b5e2bffa286b019f
2024-12-16 07:12:01 UTC to 2024-12-05 05:01:46 UTC

- Specify what a CGU is (rust-lang/rustc-dev-guide#2163)
- functionality removed from codebase (part 2) (rust-lang/rustc-dev-guide#2160)
- functionality removed from codebase (rust-lang/rustc-dev-guide#2159)
- remove polymorphization (rust-lang/rustc-dev-guide#2158)
- squashing: recommend --keep-base when squashing without a conflict (rust-lang/rustc-dev-guide#2157)
- update section even more (rust-lang/rustc-dev-guide#2156)
- extend closure constraints section (rust-lang/rustc-dev-guide#2155)
- Remove `//@ compare-output-lines-by-subset` directive (rust-lang/rustc-dev-guide#2151)
- Document `needs-target-has-atomic` directive (rust-lang/rustc-dev-guide#2154)
…errors

Advent of `tests/ui` (misc cleanups and improvements) [3/N]

Part of rust-lang#133895.

Misc improvements to some ui tests immediately under `tests/ui/`.

Best reviewed commit-by-commit. Each commit's commit message contains further elaboration and rationale for changes.

r? compiler
…piler-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.
…r=nnethercote

Add nnethercote to the `triagebot.toml` vacation list.

r? `@nnethercote`
Fix typo in ptr/mod.rs

- Type: Document
- Description: I found a typo and want to fix it.
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 19, 2024
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Dec 19, 2024
@jhpratt
Copy link
Member Author

jhpratt commented Dec 19, 2024

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Dec 19, 2024

📌 Commit 80cf85d has been approved by jhpratt

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 19, 2024
@bors
Copy link
Contributor

bors commented Dec 19, 2024

⌛ Testing commit 80cf85d with merge bab18a5...

@bors
Copy link
Contributor

bors commented Dec 19, 2024

☀️ Test successful - checks-actions
Approved by: jhpratt
Pushing bab18a5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 19, 2024
@bors bors merged commit bab18a5 into rust-lang:master Dec 19, 2024
7 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 19, 2024
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#132056 Stabilize #[diagnostic::do_not_recommend] 2ecfa69a4fdd012fa17a96516c00b2cd32590744 (link)
#133643 -Znext-solver: modify candidate preference rules 979bb472195b24980e88a50c4b744ea5ee385744 (link)
#134388 Update books af9a61bd4449ea29516a7e67cb43587c2f840336 (link)
#134418 Advent of tests/ui (misc cleanups and improvements) [3/N] 9c85e3c580bed68a2413d2b01066b3ab53c63ddd (link)
#134473 chore: fix some typos 66fe38b45bb41dc51c5d5453203d93732840edb2 (link)
#134481 Point at lint name instead of whole attr for gated lints 08953042ebf1a0a0fca4ea91019f23ffe4eceb59 (link)
#134484 Add nnethercote to the triagebot.toml vacation list. 2bd6757c0a146566b8f5610c78a66ffd0cf8c454 (link)
#134490 Fix typo in ptr/mod.rs 352d05ce79fc2416dc6bd0a8cd2cdbbede04ea58 (link)

previous master: 023521e682

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bab18a5): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.7%] 10
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) 0.4% [0.2%, 0.7%] 10

Max RSS (memory usage)

Results (primary 1.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.7% [1.5%, 1.9%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.7% [1.5%, 1.9%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 770.305s -> 769.934s (-0.05%)
Artifact size: 330.31 MiB -> 330.37 MiB (0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants