-
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
Give compile_error macro examples #46512
Conversation
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/macros.rs
Outdated
/// compile_error!("This macro only accepts `foo` or `bar`"); | ||
/// } | ||
/// } | ||
/// ``` |
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 example is currently giving an unused_macros
warning. Please do use the macro e.g.
give_me_foo_or_bar!(neither);
// ^ will fail at compile time with message "This macro only accepts `foo` or `bar`"
LGTM minus Travis. cc @rust-lang/docs |
Literally took your two lines there and patched them into the example. |
src/libstd/macros.rs
Outdated
/// | ||
/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md | ||
/// # Examples | ||
/// Two such examples are macros and `#[cfg]` environments. |
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.
Please add an empty line before this one.
/// give_me_foo_or_bar!(neither); | ||
/// // ^ will fail at compile time with message "This macro only accepts `foo` or `bar`" | ||
/// ``` | ||
/// |
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.
Please add a sentence in here (no need for a big one!) so we don't just have two code blocks following each other.
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.
Done.
@bors r+ rollup |
📌 Commit aaaea2c has been approved by |
Give compile_error macro examples I cannot get Rust to build at all with it complaining about GCC not being a valid C compiler or something, so letting TravisCI be my tester... Fixes rust-lang#46171
I cannot get Rust to build at all with it complaining about GCC not being a valid C compiler or something, so letting TravisCI be my tester...
Fixes #46171