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

Give compile_error macro examples #46512

Merged
merged 3 commits into from
Dec 6, 2017
Merged

Conversation

Havvy
Copy link
Contributor

@Havvy Havvy commented Dec 5, 2017

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

@rust-highfive
Copy link
Collaborator

r? @kennytm

(rust_highfive has picked a reviewer for you, use r? to override)

/// compile_error!("This macro only accepts `foo` or `bar`");
/// }
/// }
/// ```
Copy link
Member

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`"

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 5, 2017
@kennytm
Copy link
Member

kennytm commented Dec 5, 2017

LGTM minus Travis.

cc @rust-lang/docs

@Havvy
Copy link
Contributor Author

Havvy commented Dec 5, 2017

Literally took your two lines there and patched them into the example.

///
/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
/// # Examples
/// Two such examples are macros and `#[cfg]` environments.
Copy link
Member

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`"
/// ```
///
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@kennytm
Copy link
Member

kennytm commented Dec 6, 2017

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 6, 2017

📌 Commit aaaea2c has been approved by kennytm

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 6, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Dec 6, 2017
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
bors added a commit that referenced this pull request Dec 6, 2017
Rollup of 7 pull requests

- Successful merges: #46136, #46378, #46431, #46483, #46495, #46502, #46512
- Failed merges:
@bors bors merged commit aaaea2c into rust-lang:master Dec 6, 2017
@Havvy Havvy deleted the doc-compile_fail branch August 11, 2018 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants