-
Notifications
You must be signed in to change notification settings - Fork 60
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
Stable and slim #1
Conversation
Also adds a nightly feature flag that will automatically be picked up by docs.rs to build nice docs.
You can run `cargo clippy` locally to get the same effect. I've also taken the liberty to nail down the rustfmt version to use, so we can update it explicitly. (This is the same CI setup that assert_cli uses.)
Improves compile times
This should make it compatible with windows consoles.
(wrote this as a comment to prevent it from becoming part of the merge commit message) Checklist
|
@killercup niceee! Some quick notes:
Overall really liking it! |
|
||
use console::style; | ||
use failure::Error; | ||
#![cfg_attr(feature = "nightly", deny(missing_docs))] |
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 should be enabled on every channel I reckon
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.
I can't enable missing_docs on stable because then it'll complain about missing module docs! (As loading the Readme is only done in nightly.)
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.
Ahaha, yeah alright - fair enough! There's hacks we could do, but let's not do them.
|
||
/// Catch any error handlers that occur, and | ||
// Cargo env vars available: | ||
// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates | ||
pub fn catch_unwind<F: FnOnce() -> Result<(), Error>>(f: F) { | ||
pub fn catch_unwind<F: FnOnce() -> Result<(), Box<Error>>>(f: F) { |
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.
Curious: why did you opt to replace failure::Error
with Box<Error>
? The former should guarantee we always get a stack trace, which I figured would be useful for the reporting.
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.
Oh, is this why you used failure? I'm not sure that's what's happening: Failure will only give you stack traces for errors that occur in the catch_unwind
code -- everything else is part of the panic_info
, right?
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.
yeah, that's totally true! - the way I'm envisioning this though is that this would run in the outer most scope of fn main()
to catch everything that happens inside of it. And then like with quicli
it also handles errors that have been returned. Does that make sense?
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.
Hmmm. I see what you mean, but I don't think this is how it works. Failure's backtrace will only collect traces when an error is actually propagated -- but when you panic!
, that doesn't happen (instead, Rust will unwind the stack; unless you set `panic = "abort").
I'm not an authority on how to really solve this, though!
I can change it to always install the latest version on the latest nightly and make this an allowed failure on Travis if you want. (I'd personally prefer the stability because allowed failures tend to go unnoticed.)
You can do |
Haha, yeah - but I reallllly just want to run it whenever The less work there is in a toolchain, the better 😁 |
I'd love to have that as well! Alas, that is in stark conflict with "this still compiles in a year" right now :( It's a trade-off. Just tell me what you want to have and I'll implement it. |
I recommend pinning clippy in the CI. I have found that contributors get frustrated when a CI arbitrarily breaks on them and pinning as a big help for this. Pinning also makes it possible to cache your clippy install to reduce CI times and load on these CI servers that are gifted to us. For more, see https://crate-ci.github.io/pr/clippy.html |
.travis.yml
Outdated
- rust: nightly-2018-04-13 | ||
env: CLIPPY_VERS="0.0.193" | ||
before_script: | | ||
[[ "$(cargo +nightly-2018-04-13 clippy --version)" != "$CLIPPY_VERS" ]] && \ |
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 actually isn't needed. I know I recommended it in the past for assert_cli but have learned more about travis as part of documenting it for crate-ci.
Travis will ignore the caches on environment variable changes and since the version is kept in an environment variable, it will auto-clear.
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.
Oh, interesting! Should be depend on Travis' behavior here, though? At least this way it should also work for other CI systems, right?
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.
Except the file is travis specific. As we document other CIs, we can note the special things that might need to be done in them. Overall, I like Travis' approach; I wish I had that on Jenkins at work.
@killercup sure, let's go with what you proposed - it seems most folks in this thread seem in favor of that, so good with me! |
and choose a nightly that actually exists.
f43e9a5
to
9f79f96
Compare
Yay, CI works! |
Fixed the clippy issue. Let me know what else you need me to change. |
This commit cleans up the code quite significantly and gates certain features behind `nightly` macros to still allow complication on stable Rust.
chore(deps): update msrv to v1.65.0
This is a pretty general refactoring of the code.
The goal of this PR is to make this a crate that is useful in more general contexts. For this, I've:
For more information, see the individual commit messages.
Semver Changes
This does not change observable behavior.