Attribute documentation for used, expect, should_panic, cfg_attr, and path#158664
Attribute documentation for used, expect, should_panic, cfg_attr, and path#158664kantnero wants to merge 5 commits into
used, expect, should_panic, cfg_attr, and path#158664Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /// Used for conditional application of attributes. | ||
| /// | ||
| /// The `cfg_attr` attribute applies one or more attributes to an item only if a given | ||
| /// configuration predicate is true. If the condition is false, the attributes are ignored. |
There was a problem hiding this comment.
| /// configuration predicate is true. If the condition is false, the attributes are ignored. |
| /// | ||
| /// ```rust | ||
| /// // This function is annotated with `#[test]` only when testing is active. | ||
| /// #[cfg_attr(test, test)] |
There was a problem hiding this comment.
It's neat, but I think it's a bit too complex (test is present twice). I suggest instead to make it a test only on linux for example. Like that we have a clear predicate, completely different than the applied attribute.
| /// } | ||
| /// ``` | ||
| /// | ||
| /// The predicate uses the same syntax as [`cfg`]. For complex conditions, you can combine |
There was a problem hiding this comment.
Does it link to the right cfg page?
There was a problem hiding this comment.
You still didn't answer this question. When you generate doc locally, what is the link of this item?
There was a problem hiding this comment.
/rust/build/x86_64-unknown-linux-gnu/doc/core/attribute.cfg.html
There was a problem hiding this comment.
I just checked it links to macro cfg
There was a problem hiding this comment.
So it's not the right link.
There was a problem hiding this comment.
Yes, I have removed it
| /// ``` | ||
| /// | ||
| /// The predicate uses the same syntax as [`cfg`]. For complex conditions, you can combine | ||
| /// `all(...)`, `any(...)`, and `not(...)` just like with [`cfg`]. |
There was a problem hiding this comment.
Add the same listing and example you added for cfg.
| /// from optimizing them away even if they are not referenced anywhere else in the code. | ||
| /// | ||
| /// It tells the compiler that an item is still in use or needed elsewhere and, because of this, | ||
| /// it is kept in the output object. |
There was a problem hiding this comment.
"output object"?
There was a problem hiding this comment.
Ah ok I got it, so instead:
| /// it is kept in the output object. | |
| /// it is kept in the generated object files (files generated by `rustc` when compiling). |
| // | ||
| /// The `ignore` attribute is used with the `test` attribute to stop the test harness from | ||
| /// executing a function as a test. The `ignore` attribute may only be applied to functions | ||
| /// annotated with the test attribute. |
There was a problem hiding this comment.
| /// annotated with the test attribute. | |
| /// annotated with the `test` attribute. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
|
@rustbot author Not all review comments have been addressed, e.g., https://github.com/rust-lang/rust/pull/158664/changes#r3513255509, https://github.com/rust-lang/rust/pull/158664/changes#r3557842583, etc. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…h, and ignore Signed-off-by: Emmanuel Ugwu <emmanuelugwu121@gmail.com>
Signed-off-by: Emmanuel Ugwu <emmanuelugwu121@gmail.com>
Signed-off-by: Emmanuel Ugwu <emmanuelugwu121@gmail.com>
Signed-off-by: Emmanuel Ugwu <emmanuelugwu121@gmail.com>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Emmanuel Ugwu <emmanuelugwu121@gmail.com>
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
☔ The latest upstream changes (presumably #159336) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
View all comments
Attribute documentation for
used,expect,should_panic,cfg_attr, andpathusing the#[doc(attribute = "")]mechanismTested with: ./x test library/std --doc
r? @GuillaumeGomez
cc @traviscross @fmease