-
Notifications
You must be signed in to change notification settings - Fork 492
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
Document new #[expect]
attribute and reasons
parameter (RFC 2383)
#1237
Document new #[expect]
attribute and reasons
parameter (RFC 2383)
#1237
Conversation
acf12af
to
ad0ef1e
Compare
The CI will fail, until the |
src/attributes/diagnostics.md
Outdated
> Note: Lint expectations have been proposed in [RFC 2383]. It was not defined | ||
> how expectations of the expectation lint should be handled. The rustc | ||
> implementation currently doesn't allow the expextation of the | ||
> `unfulfilled_lint_expectation` lint. This can change in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the link to the RFC is particularly important here. There are also a few typos here (unfulfilled_lint_expectation
(no s) and expextation
). It is also not clear to me what it means by "currently doesn't allow", as it seems to allow it just fine:
#![feature(lint_reasons)]
#![expect(unfulfilled_lint_expectations)]
Produces:
warning: this lint expectation is unfulfilled
--> src/lib.rs:2:11
|
2 | #![expect(unfulfilled_lint_expectations)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
= note: the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
It does seem like it is always a warning, even if unfulfilled_lint_expectations
is triggered (which seems strange).
Is there some more context here?
Perhaps it could say something like:
Note: The behavior of
#[expect(unfulfilled_lint_expectations)]
is currently defined to always generate theunfulfilled_lint_expectations
lint. This may change in the future.
Perhaps this should be clarified before it is stabilized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: The behavior of
#[expect(unfulfilled_lint_expectations)]
is currently defined to always generate theunfulfilled_lint_expectations
lint. This may change in the future.
Yes this is what I intended to say. The context sadly cannot be condensed to one link. This behavior was implemented in rust-lang/rust#94670. This has been discussed in the RFC PR (rust-lang/rfcs#2383 (comment)) with the suggestion to allow the unfulfilled_lint_expectations
to be caught by outer expectations.
This can also be implemented in rustc. However, I decided against this for two reasons:
- I didn't see a benefit. In the RFC Discussion, it was also said that there seems to be no use case for
#[expect(unfulfilled_lint_expectations)]
- Supporting
#[expect(unfulfilled_lint_expectations)]
would add a bunch of complexity. Currently, the lint is emitted at the item the attribute is attached to (For reasons regarding, incremental compilation and hash stability). To support such an expectation, we would need to either store the lint level and then order the expectations by which could fulfill which one or depend on the processing order which has caused some issues in the past. So, either solution would add complexity to the implementation without having an use case. We can also not simply emit the lint at the parent item due to the way lint levels are processed.
btw how did you add the (i) Note
marker? I can sadly not see the MD text
src/attributes/diagnostics.md
Outdated
|
||
With the `#[expect]` attributes lints can be expected in a certain scope. If | ||
this expectation is not fulfilled a new warning is emitted to the user. The | ||
lint levels can be overridden with other lint attributes as usual. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence wasn't really clear to me what it meant. I might suggest breaking the example up into two parts. The first example can show where unfulfilled_lint_expectations
is unfulfilled. Then, after that example, write a small paragraph and a second example that explains how changing the level of a lint within an expectation scope will override the expect
attribute. Perhaps something like:
If the level of a lint is modified within an expect
scope with a warn
or deny
attribute, then triggering that lint does not satisfy the expect
attribute, and the unfulfilled_lint_expectations
will also trigger. Similarly, squelching a lint with allow
will also prevent the lint from being fulfilled.
This behavior seems kinda confusing to me, and it is not really clear to me how it is working, or if that is really intended behavior?
I might also include some text explaining the interaction with forbid
, since that also isn't entirely clear to me. I believe it is something like "if a lint has previously been marked with forbid
, then it is not allowed to use the expect
attribute with that lint".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior seems kinda confusing to me, and it is not really clear to me how it is working, or if that is really intended behavior?
This is intended behavior, see rust-lang/rust#54503 (comment)
I've added more examples and documentation. 🙃
26efdda
to
4bb5560
Compare
4bb5560
to
41b63dc
Compare
With rust-lang/rust#115980 (comment) the semantics of the The CI is currently failing, since the feature is not yet stabilized in rustc. I'll work on that part next. |
src/attributes/diagnostics.md
Outdated
> Note: The behavior of `#[expect(unfulfilled_lint_expectations)]` is currently | ||
> defined to always generate the `unfulfilled_lint_expectations` lint. This may | ||
> change in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what way might this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original RFC had a discussion about expecting the unfulfilled_lint_expectations
lint, but never came up with a valid use case. The current behavior is the result of the way that rustc emits lints. If someone comes up with a valid use case, I think it would be valid to change the behavior of expecting this specific lint, but I honestly can't think of one.
Maybe it would be better, to remove the last sentence? (I'll do that in the typo fix commit)
…y, r=Urgau,blyxyas Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383) Let's give this another try! The [previous stabilization attempt](rust-lang#99063) was stalled by some unresolved questions. These have been discussed in a [lang team](rust-lang/lang-team#191) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in rust-lang#115980 I've just updated the [stabilization report](rust-lang#54503 (comment)) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation. This hopefully covers everything. Let's hope that the CI will be green like the spring. fixes rust-lang#115980 fixes rust-lang#54503 --- r? `@wesleywiser` Tacking Issue: rust-lang#54503 Stabilization Report: rust-lang#54503 (comment) Documentation Update: rust-lang/reference#1237 <!-- For Clippy: changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized --> --- Roses are red, Violets are blue, Let's expect lints, With reason clues
rust-lang/rust#120924 has been merged and this feature will be part of Rust 1.81 🎉 This PR should be ready for review. We'll have to wait one nightly to allow the example code blocks to compile in CI. I'll rebase it tomorrow. I'll be gone over the weekend, but can gat back to it afterwards :D |
…u,blyxyas Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383) Let's give this another try! The [previous stabilization attempt](rust-lang/rust#99063) was stalled by some unresolved questions. These have been discussed in a [lang team](rust-lang/lang-team#191) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in rust-lang/rust#115980 I've just updated the [stabilization report](rust-lang/rust#54503 (comment)) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation. This hopefully covers everything. Let's hope that the CI will be green like the spring. fixes #115980 fixes #54503 --- r? `@wesleywiser` Tacking Issue: rust-lang/rust#54503 Stabilization Report: rust-lang/rust#54503 (comment) Documentation Update: rust-lang/reference#1237 <!-- For Clippy: changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized --> --- Roses are red, Violets are blue, Let's expect lints, With reason clues
600e68a
to
d18480a
Compare
d18480a
to
a1b095a
Compare
I've rebased and the CI is green 🎉 It should be ready for review an maybe merge :D |
…u,blyxyas Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383) Let's give this another try! The [previous stabilization attempt](rust-lang/rust#99063) was stalled by some unresolved questions. These have been discussed in a [lang team](rust-lang/lang-team#191) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in rust-lang/rust#115980 I've just updated the [stabilization report](rust-lang/rust#54503 (comment)) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation. This hopefully covers everything. Let's hope that the CI will be green like the spring. fixes #115980 fixes #54503 --- r? `@wesleywiser` Tacking Issue: rust-lang/rust#54503 Stabilization Report: rust-lang/rust#54503 (comment) Documentation Update: rust-lang/reference#1237 <!-- For Clippy: changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized --> --- Roses are red, Violets are blue, Let's expect lints, With reason clues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I pushed up a small fix.
…u,blyxyas Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383) Let's give this another try! The [previous stabilization attempt](rust-lang/rust#99063) was stalled by some unresolved questions. These have been discussed in a [lang team](rust-lang/lang-team#191) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in rust-lang/rust#115980 I've just updated the [stabilization report](rust-lang/rust#54503 (comment)) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation. This hopefully covers everything. Let's hope that the CI will be green like the spring. fixes #115980 fixes #54503 --- r? `@wesleywiser` Tacking Issue: rust-lang/rust#54503 Stabilization Report: rust-lang/rust#54503 (comment) Documentation Update: rust-lang/reference#1237 <!-- For Clippy: changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized --> --- Roses are red, Violets are blue, Let's expect lints, With reason clues
Update books ## rust-lang/book 2 commits in 45c1a6d69edfd1fc91fb7504cb73958dbd09441e..f1e49bf7a8ea6c31ce016a52b8a4f6e1ffcfbc64 2024-06-25 21:12:15 UTC to 2024-06-20 16:10:32 UTC - Update ch10-00-generics.md (rust-lang/book#3963) - infra: ignore Nova configuration directory (rust-lang/book#3962) ## rust-lang/edition-guide 3 commits in cb58c430b4e8054c2cb81d2d4434092c482a93d8..941db8b3df45fd46cd87b50a5c86714b91dcde9c 2024-06-30 19:26:27 UTC to 2024-06-20 18:43:18 UTC - Add a section for the never type change in e2024 (rust-lang/edition-guide#310) - Add 2024 unsafe attributes. (rust-lang/edition-guide#308) - Add 2024 unsafe extern blocks. (rust-lang/edition-guide#309) ## rust-lang/reference 7 commits in 0b805c65804019b0ac8f2fe3117afad82a6069b8..1ae3deebc3ac16e276b6558e01420f8e605def08 2024-06-29 16:59:51 UTC to 2024-06-18 22:16:37 UTC - Provide an example of `target_family` being multi-valued (rust-lang/reference#1518) - Remove stubs needed for the link checker. (rust-lang/reference#1517) - Document new `#[expect]` attribute and `reasons` parameter (RFC 2383) (rust-lang/reference#1237) - Update recognized tool attributes (rust-lang/reference#1498) - Add example of 1-ary tuple type (rust-lang/reference#1514) - underscore-expr: add more examples (rust-lang/reference#1478) - Remove outdated info about impl Trait in parameters and generics in the same function (rust-lang/reference#1495) ## rust-lang/rust-by-example 4 commits in b1d97bd6113aba732b2091ce093c76f2d05bb8a0..658c6c27cb975b92227936024816986c2d3716fb 2024-06-30 11:58:29 UTC to 2024-06-30 11:52:38 UTC - Remove awkward match in if_let (rust-lang/rust-by-example#1725) - Edit grammatical mistake (rust-lang/rust-by-example#1830) - Update paragraph in src/fn/diverging.md (rust-lang/rust-by-example#1853) - Fix minor typo in from_into.md (rust-lang/rust-by-example#1854) ## rust-lang/rustc-dev-guide 11 commits in aec82168dd3121289a194b381f56076fc789a4d2..d6e3a32a557db5902e714604def8015d6bb7e0f7 2024-07-01 10:51:26 UTC to 2024-06-18 18:24:17 UTC - Update new target check-cfg instructions (rust-lang/rustc-dev-guide#2006) - Add Rust for Linux integration tests documentation (rust-lang/rustc-dev-guide#2004) - Add docs for building Fuchsia locally and in CI (rust-lang/rustc-dev-guide#1989) - provide `libstdc++.so.6` through `LD_LIBRARY_PATH` (rust-lang/rustc-dev-guide#1999) - Document how to run `run-make` tests on Windows (rust-lang/rustc-dev-guide#2002) - Document `needs-symlink` directive (rust-lang/rustc-dev-guide#2001) - Rename `wasm32-wasi` to `wasm32-wasip1` (rust-lang/rustc-dev-guide#1678) - Document inert vs active attributes (rust-lang/rustc-dev-guide#1110) - Document hard-resetting submodules (rust-lang/rustc-dev-guide#2000) - Fix note about compiletest header `rustfix-only-machine-applicable` (rust-lang/rustc-dev-guide#1998) - Mention `RUSTC_ICE=0` to suppress ICE file (rust-lang/rustc-dev-guide#1997)
Rollup merge of rust-lang#127212 - rustbot:docs-update, r=ehuss Update books ## rust-lang/book 2 commits in 45c1a6d69edfd1fc91fb7504cb73958dbd09441e..f1e49bf7a8ea6c31ce016a52b8a4f6e1ffcfbc64 2024-06-25 21:12:15 UTC to 2024-06-20 16:10:32 UTC - Update ch10-00-generics.md (rust-lang/book#3963) - infra: ignore Nova configuration directory (rust-lang/book#3962) ## rust-lang/edition-guide 3 commits in cb58c430b4e8054c2cb81d2d4434092c482a93d8..941db8b3df45fd46cd87b50a5c86714b91dcde9c 2024-06-30 19:26:27 UTC to 2024-06-20 18:43:18 UTC - Add a section for the never type change in e2024 (rust-lang/edition-guide#310) - Add 2024 unsafe attributes. (rust-lang/edition-guide#308) - Add 2024 unsafe extern blocks. (rust-lang/edition-guide#309) ## rust-lang/reference 7 commits in 0b805c65804019b0ac8f2fe3117afad82a6069b8..1ae3deebc3ac16e276b6558e01420f8e605def08 2024-06-29 16:59:51 UTC to 2024-06-18 22:16:37 UTC - Provide an example of `target_family` being multi-valued (rust-lang/reference#1518) - Remove stubs needed for the link checker. (rust-lang/reference#1517) - Document new `#[expect]` attribute and `reasons` parameter (RFC 2383) (rust-lang/reference#1237) - Update recognized tool attributes (rust-lang/reference#1498) - Add example of 1-ary tuple type (rust-lang/reference#1514) - underscore-expr: add more examples (rust-lang/reference#1478) - Remove outdated info about impl Trait in parameters and generics in the same function (rust-lang/reference#1495) ## rust-lang/rust-by-example 4 commits in b1d97bd6113aba732b2091ce093c76f2d05bb8a0..658c6c27cb975b92227936024816986c2d3716fb 2024-06-30 11:58:29 UTC to 2024-06-30 11:52:38 UTC - Remove awkward match in if_let (rust-lang/rust-by-example#1725) - Edit grammatical mistake (rust-lang/rust-by-example#1830) - Update paragraph in src/fn/diverging.md (rust-lang/rust-by-example#1853) - Fix minor typo in from_into.md (rust-lang/rust-by-example#1854) ## rust-lang/rustc-dev-guide 11 commits in aec82168dd3121289a194b381f56076fc789a4d2..d6e3a32a557db5902e714604def8015d6bb7e0f7 2024-07-01 10:51:26 UTC to 2024-06-18 18:24:17 UTC - Update new target check-cfg instructions (rust-lang/rustc-dev-guide#2006) - Add Rust for Linux integration tests documentation (rust-lang/rustc-dev-guide#2004) - Add docs for building Fuchsia locally and in CI (rust-lang/rustc-dev-guide#1989) - provide `libstdc++.so.6` through `LD_LIBRARY_PATH` (rust-lang/rustc-dev-guide#1999) - Document how to run `run-make` tests on Windows (rust-lang/rustc-dev-guide#2002) - Document `needs-symlink` directive (rust-lang/rustc-dev-guide#2001) - Rename `wasm32-wasi` to `wasm32-wasip1` (rust-lang/rustc-dev-guide#1678) - Document inert vs active attributes (rust-lang/rustc-dev-guide#1110) - Document hard-resetting submodules (rust-lang/rustc-dev-guide#2000) - Fix note about compiletest header `rustfix-only-machine-applicable` (rust-lang/rustc-dev-guide#1998) - Mention `RUSTC_ICE=0` to suppress ICE file (rust-lang/rustc-dev-guide#1997)
Update books ## rust-lang/book 2 commits in 45c1a6d69edfd1fc91fb7504cb73958dbd09441e..f1e49bf7a8ea6c31ce016a52b8a4f6e1ffcfbc64 2024-06-25 21:12:15 UTC to 2024-06-20 16:10:32 UTC - Update ch10-00-generics.md (rust-lang/book#3963) - infra: ignore Nova configuration directory (rust-lang/book#3962) ## rust-lang/edition-guide 3 commits in cb58c430b4e8054c2cb81d2d4434092c482a93d8..941db8b3df45fd46cd87b50a5c86714b91dcde9c 2024-06-30 19:26:27 UTC to 2024-06-20 18:43:18 UTC - Add a section for the never type change in e2024 (rust-lang/edition-guide#310) - Add 2024 unsafe attributes. (rust-lang/edition-guide#308) - Add 2024 unsafe extern blocks. (rust-lang/edition-guide#309) ## rust-lang/reference 7 commits in 0b805c65804019b0ac8f2fe3117afad82a6069b8..1ae3deebc3ac16e276b6558e01420f8e605def08 2024-06-29 16:59:51 UTC to 2024-06-18 22:16:37 UTC - Provide an example of `target_family` being multi-valued (rust-lang/reference#1518) - Remove stubs needed for the link checker. (rust-lang/reference#1517) - Document new `#[expect]` attribute and `reasons` parameter (RFC 2383) (rust-lang/reference#1237) - Update recognized tool attributes (rust-lang/reference#1498) - Add example of 1-ary tuple type (rust-lang/reference#1514) - underscore-expr: add more examples (rust-lang/reference#1478) - Remove outdated info about impl Trait in parameters and generics in the same function (rust-lang/reference#1495) ## rust-lang/rust-by-example 4 commits in b1d97bd6113aba732b2091ce093c76f2d05bb8a0..658c6c27cb975b92227936024816986c2d3716fb 2024-06-30 11:58:29 UTC to 2024-06-30 11:52:38 UTC - Remove awkward match in if_let (rust-lang/rust-by-example#1725) - Edit grammatical mistake (rust-lang/rust-by-example#1830) - Update paragraph in src/fn/diverging.md (rust-lang/rust-by-example#1853) - Fix minor typo in from_into.md (rust-lang/rust-by-example#1854) ## rust-lang/rustc-dev-guide 11 commits in aec82168dd3121289a194b381f56076fc789a4d2..d6e3a32a557db5902e714604def8015d6bb7e0f7 2024-07-01 10:51:26 UTC to 2024-06-18 18:24:17 UTC - Update new target check-cfg instructions (rust-lang/rustc-dev-guide#2006) - Add Rust for Linux integration tests documentation (rust-lang/rustc-dev-guide#2004) - Add docs for building Fuchsia locally and in CI (rust-lang/rustc-dev-guide#1989) - provide `libstdc++.so.6` through `LD_LIBRARY_PATH` (rust-lang/rustc-dev-guide#1999) - Document how to run `run-make` tests on Windows (rust-lang/rustc-dev-guide#2002) - Document `needs-symlink` directive (rust-lang/rustc-dev-guide#2001) - Rename `wasm32-wasi` to `wasm32-wasip1` (rust-lang/rustc-dev-guide#1678) - Document inert vs active attributes (rust-lang/rustc-dev-guide#1110) - Document hard-resetting submodules (rust-lang/rustc-dev-guide#2000) - Fix note about compiletest header `rustfix-only-machine-applicable` (rust-lang/rustc-dev-guide#1998) - Mention `RUSTC_ICE=0` to suppress ICE file (rust-lang/rustc-dev-guide#1997)
…u,blyxyas Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383) Let's give this another try! The [previous stabilization attempt](rust-lang/rust#99063) was stalled by some unresolved questions. These have been discussed in a [lang team](rust-lang/lang-team#191) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in rust-lang/rust#115980 I've just updated the [stabilization report](rust-lang/rust#54503 (comment)) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation. This hopefully covers everything. Let's hope that the CI will be green like the spring. fixes #115980 fixes #54503 --- r? `@wesleywiser` Tacking Issue: rust-lang/rust#54503 Stabilization Report: rust-lang/rust#54503 (comment) Documentation Update: rust-lang/reference#1237 <!-- For Clippy: changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized --> --- Roses are red, Violets are blue, Let's expect lints, With reason clues
This PR is created in preparation to stabilize the
lint_reasons
feature. I hope this covers everything 🙃Tracking issue: rust-lang/rust#54503