rust-lang / rust-lang/reference

Document test restriction in placement

Open
#908 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-attributes
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

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 https://github.com/rust-lang/rust/issues/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]".

Originally posted by @ehuss in https://github.com/rust-lang/reference/issues/906#issuecomment-732410897

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/attributes/testing.md at the linked test-attribute section, then inspect the sentence above its example and locate the test_only function. Done means the documentation describes the restriction on #[test] and #[bench], and the referenced wording and function name are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.