-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve assert_matches! documentation #121732
Improve assert_matches! documentation #121732
Conversation
This new documentation tries to avoid to limit the impact of the conceptual pitfall, that the if guard relaxes the constraint, when really it tightens it. This is achieved by changing the text and examples. The previous documentation also chose a rather weird and non-representative example for the if guard, that made it needlessly complicated to understand.
This comment has been minimized.
This comment has been minimized.
Not sure I understand the CI error:
It's the same module, and previously
worked, which is also in the same module. Is this a feature thing? |
Is it because of declarative macro definition rules? As in, declarative macro |
Indeed that's it. Didn't know the declaration order also matters for the doc comments. Here is small reproducer: macro_rules! start {
() => {};
}
/// [`start!`]
/// [`end!`]
macro_rules! mid {
() => {};
}
macro_rules! end {
() => {};
}
fn main() {}
Kind of sad, because it means there is no general way to cross link macros :/ I tried |
Maybe submit an enhancement request issue for this to the rustdoc team, because I feel like it probably should work? Although I can see not wanting to change the behavior to stay consistent with how name resolution works in rustc as well. |
FWIW, that does work if you add |
The stdlib |
Another way to make a macro an item (but not in the crate root) is this: macro_rules! end {
() => {};
}
use end; I'm not suggesting that for your PR; but that's what people should do in other crates where they want to have a macro be an item in the local module. |
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.
Looks good -- I just have some comma suggestions.
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.
You missed the commas that I removed, which do not belong before the preposition. Also, now that I look again, the phrase "meet expectations" should be plural, or else we could more directly say "did not match the pattern."
Co-authored-by: Josh Stone <cuviper@gmail.com>
Good catch. Should be fixed now. |
@bors r+ rollup |
Was the bot asleep? @bors r+ rollup |
@bors r+ |
…documentation, r=cuviper Improve assert_matches! documentation This new documentation tries to limit the impact of the conceptual pitfall, that the if guard relaxes the constraint, when really it tightens it. This is achieved by changing the text and examples. The previous documentation also chose a rather weird and non-representative example for the if guard, that made it needlessly complicated to understand.
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#120976 (constify a couple thread_local statics) - rust-lang#121683 (Fix LVI tests after frame pointers are enabled by default) - rust-lang#121703 (Add a way to add constructors for `rustc_type_ir` types) - rust-lang#121732 (Improve assert_matches! documentation) - rust-lang#121928 (Extract an arguments struct for `Builder::then_else_break`) - rust-lang#121939 (Small enhancement to description of From trait) - rust-lang#121968 (Don't run test_get_os_named_thread on win7) - rust-lang#121969 (`ParseSess` cleanups) - rust-lang#121977 (Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.) - rust-lang#121994 (Update platform-support.md with supported musl version) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#120976 (constify a couple thread_local statics) - rust-lang#121683 (Fix LVI tests after frame pointers are enabled by default) - rust-lang#121703 (Add a way to add constructors for `rustc_type_ir` types) - rust-lang#121732 (Improve assert_matches! documentation) - rust-lang#121928 (Extract an arguments struct for `Builder::then_else_break`) - rust-lang#121939 (Small enhancement to description of From trait) - rust-lang#121968 (Don't run test_get_os_named_thread on win7) - rust-lang#121969 (`ParseSess` cleanups) - rust-lang#121977 (Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.) - rust-lang#121994 (Update platform-support.md with supported musl version) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121732 - Voultapher:improve-assert_matches-documentation, r=cuviper Improve assert_matches! documentation This new documentation tries to limit the impact of the conceptual pitfall, that the if guard relaxes the constraint, when really it tightens it. This is achieved by changing the text and examples. The previous documentation also chose a rather weird and non-representative example for the if guard, that made it needlessly complicated to understand.
This new documentation tries to limit the impact of the conceptual pitfall, that the if guard relaxes the constraint, when really it tightens it. This is achieved by changing the text and examples. The previous documentation also chose a rather weird and non-representative example for the if guard, that made it needlessly complicated to understand.