-
Notifications
You must be signed in to change notification settings - Fork 340
Avoid doctest errors #677
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
Avoid doctest errors #677
Conversation
@kornelski in order to run the tests a few features need to be enabled: $ cargo test --all --features 'attributes,unstable' This is the way it's setup in our CI as well. Though as evidenced by this PR it's not discoverable, and we should at the very least document this in the README. I wish we could add this to profiles somehow, but I don't believe we can. [profiles.test]
features = [ "attributes", "unstable" ] |
That's unexpected indeed. Doctests are an odd case, but for tests in general I expect them to be gated by the same flags as the features implementations are, so that Maybe these doctests could be made conditional? This seems to be a supported syntax:
|
|
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.
Didn't know this was possible -- but this seems reasonable; thanks heaps!
Ah, it seems we're missing a |
Sorry, no. rustfmt doesn't understand this syntax and breaks Markdown in the comments. I'm incredibly disappointed that rustfmt missed the point of gofmt. It unconditionally overrides all human decisions, which makes it a dumb and destructive tool, unlike gofmt which more or less only cleans up known-bad formatting. Because of that I think unconditionally using rustfmt is a bad idea, and I'm not going to use rustfmt. |
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.
Thank you for a great hack!
Isn't this cause here?
Line 2 in 0eb5ca1
format_code_in_doc_comments = true |
I agree to remove rustfmt from CI if it gets in the way, but I think it would be better to remove the format_code_in_doc_comments
option and keep using it.
What do you think ❓
Yeah, rustfmt error is bug/limitation of unstable Removing usage of
fwiw: to keep using /// ```
/// # #[cfg(feature = "attributes")]
/// # fn dox() {
/// examples...
/// # }
/// ```
|
ping @kornelski |
Sorry, I don't like enforced rustfmt checks, and I'm not going to satify rustfmt's arbitrary requirements. |
It seems like proc macros don't work in doctests:
The problem is visible when running
cargo test --all
. Tested on Rust 1.40 and 1.42 nightly.