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

Use doc, not test for fn item inner attr example #906

Merged
merged 2 commits into from
Nov 25, 2020

Conversation

Havvy
Copy link
Contributor

@Havvy Havvy commented Nov 21, 2020

Using test causes a deny-by-default lint to trigger. See
rust-lang/rust#79003 for more information.

Using `test` causes a deny-by-default lint to trigger. See
rust-lang/rust#79003 for more information.
@ehuss
Copy link
Contributor

ehuss commented Nov 23, 2020

Thanks! The sentence above the example should probably be updated (The function will only be available while running tests.) and the function name (test_only) should also probably be changed.

I think it would also be a good idea to document this behavior somehow. AFAIK (rustc_builtin_macros), the only attributes this affects is test and bench. I don't know how soon rust-lang/rust#54726 might get stabilized, but if it might be a long time, maybe a brief mention at https://github.com/rust-lang/reference/blob/master/src/attributes/testing.md#the-test-attribute that says something along the lines of: "similar to proc-macros, the #[test] attribute only works as an [outer attribute], and cannot be used as an [inner attribute]".

@@ -295,7 +295,7 @@ available while running tests.

```rust
fn test_only() {
#![test]
#![doc("Example")]
Copy link
Contributor

@petrochenkov petrochenkov Nov 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#![doc("Example")]
#![doc = "Example"]

doc("Example") is not currently rejected by validation, but it doesn't do anything.

@camelid camelid mentioned this pull request Nov 25, 2020
@Havvy
Copy link
Contributor Author

Havvy commented Nov 25, 2020

I want to focus this PR on just getting toolstate working, so the update to the test file shall be in its own PR.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Seems reasonable, I don't think there is any rush. It's an extreme edge case, that hopefully some day will be removed, in which case there will be no need to document it.

@ehuss ehuss merged commit 762f9e9 into rust-lang:master Nov 25, 2020
@Havvy Havvy deleted the fix-toolstate branch November 25, 2020 20:51
@Havvy Havvy restored the fix-toolstate branch November 25, 2020 20:56
@Havvy Havvy deleted the fix-toolstate branch November 29, 2020 05:58
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Dec 1, 2020
Update books

## nomicon

1 commits in 23c49f1d5ce4720bc5b7e3a920f47eccc8da6b63..d8383b65f7948c2ca19191b3b4bd709b403aaf45
2020-11-05 13:30:53 +0900 to 2020-11-22 10:24:42 -0500
- Clarify that any alignment is valid for ZSTs

## reference

5 commits in a7de763c213292f5b44bf10acb87ffa38724814d..a8afdca5d0715b2257b6f8b9a032fd4dd7dae855
2020-11-11 19:13:21 -0800 to 2020-11-30 06:44:46 -0800
- Describe relationship between reference and optimizers (rust-lang/reference#902)
- A simple missing space (rust-lang/reference#909)
- Cleanup formatting (rust-lang/reference#907)
- Use `doc`, not `test` for fn item inner attr example (rust-lang/reference#906)
- Update where our chat is. (rust-lang/reference#903)

## book

1 commits in 13e1c05420bca86ecc79e4ba5b6d02de9bd53c62..a190438d77d28041f24da4f6592e287fab073a61
2020-10-20 14:57:32 -0500 to 2020-11-16 10:44:08 -0600
- Change SipHash not found (404) link to SipHash in Wikipedia (rust-lang/book#2503)

## rust-by-example

4 commits in 1886fda6981b723e4de637074455558f8bc1e83c..236c734a2cb323541b3394f98682cb981b9ec086
2020-10-28 13:46:54 -0500 to 2020-11-30 14:05:49 -0300
- Update old invalid link (rust-lang/rust-by-example#1392)
- Moved "See also" link to the correct page. (rust-lang/rust-by-example#1389)
- Fix some markdown lint warnings (rust-lang/rust-by-example#1388)
- Minor grammar suggestion (rust-lang/rust-by-example#1386)

## embedded-book

1 commits in ca8169e69b479f615855d0eece7e318138fcfc00..ba34b8a968f9531d38c4dc4411d5568b7c076bfe
2020-10-15 15:06:35 +0000 to 2020-11-17 00:20:43 +0000
- Clarify CAS availability  (rust-embedded/book#273)
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Dec 1, 2020
Update books

## nomicon

1 commits in 23c49f1d5ce4720bc5b7e3a920f47eccc8da6b63..d8383b65f7948c2ca19191b3b4bd709b403aaf45
2020-11-05 13:30:53 +0900 to 2020-11-22 10:24:42 -0500
- Clarify that any alignment is valid for ZSTs

## reference

5 commits in a7de763c213292f5b44bf10acb87ffa38724814d..a8afdca5d0715b2257b6f8b9a032fd4dd7dae855
2020-11-11 19:13:21 -0800 to 2020-11-30 06:44:46 -0800
- Describe relationship between reference and optimizers (rust-lang/reference#902)
- A simple missing space (rust-lang/reference#909)
- Cleanup formatting (rust-lang/reference#907)
- Use `doc`, not `test` for fn item inner attr example (rust-lang/reference#906)
- Update where our chat is. (rust-lang/reference#903)

## book

1 commits in 13e1c05420bca86ecc79e4ba5b6d02de9bd53c62..a190438d77d28041f24da4f6592e287fab073a61
2020-10-20 14:57:32 -0500 to 2020-11-16 10:44:08 -0600
- Change SipHash not found (404) link to SipHash in Wikipedia (rust-lang/book#2503)

## rust-by-example

4 commits in 1886fda6981b723e4de637074455558f8bc1e83c..236c734a2cb323541b3394f98682cb981b9ec086
2020-10-28 13:46:54 -0500 to 2020-11-30 14:05:49 -0300
- Update old invalid link (rust-lang/rust-by-example#1392)
- Moved "See also" link to the correct page. (rust-lang/rust-by-example#1389)
- Fix some markdown lint warnings (rust-lang/rust-by-example#1388)
- Minor grammar suggestion (rust-lang/rust-by-example#1386)

## embedded-book

1 commits in ca8169e69b479f615855d0eece7e318138fcfc00..ba34b8a968f9531d38c4dc4411d5568b7c076bfe
2020-10-15 15:06:35 +0000 to 2020-11-17 00:20:43 +0000
- Clarify CAS availability  (rust-embedded/book#273)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants