-
Notifications
You must be signed in to change notification settings - Fork 56
Migrate to Rust 2024 Edition #254
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
base: master
Are you sure you want to change the base?
Conversation
fae8f42 to
8450bcd
Compare
micprog
left a comment
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.
Some comments to help my understanding of the changes.
| eprintln!("{}", e); | ||
| std::process::exit(1); |
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.
Is this part needed?
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 still need to return a a non-zero exit code somehow. You could also return a result instead, which will actually do the same thing:
fn main() -> Result<(), Box<dyn std::error::Error>> {
bender::cli::main()?;
Ok(())
}However, the error will be debug formatted which is a bit uglz
| @@ -5,8 +5,6 @@ | |||
| //! | |||
| //! This module implements the subcommands of the command line tool. | |||
| #![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.
Do we need to remove this? Documentation is good to have...
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.
Actually no, I will revert this
| /// The currently picked version. | ||
| pick: Option<usize>, | ||
| /// The available version options. These are indices into `versions`. | ||
| options: Option<IndexSet<usize>>, | ||
| } | ||
|
|
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.
Do I understand correctly these fields are not used anywhere?
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.
Yes, exactly. clippy returns a warning in the new edition
| } | ||
| }); | ||
| dep_refs_and_revs.and_then(move |(refs, revs)| { | ||
| dep_refs_and_revs.map(move |(refs, revs)| { |
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'm not entirely sure this is the correct way to handle this... There may be a simpler way.
| ) | ||
| .await | ||
| .and_then(move |path| { | ||
| .inspect(move |&path| { |
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'm not sure this is the correct way to handle this. If I'm not mistaken, this is a remnant from the original futures implementation, that was updated with async/await, but can probably be simplified now.
| } | ||
| }) | ||
| .and_then(move |manifest| { | ||
| .inspect(move |&manifest| { |
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.
See above comments.
bin: Rename `main.rs` to `bender.rs` Otherwise, the executable is called `main`
8450bcd to
3655b98
Compare
Bumps the Rust edition from 2018 to 2024, and modernizes the project structure in the following way:
lib.rsfile collects all the modules (previously done inmain.rs), which is the new entry point of bender. This technically means that bender can now also be used as a library crate and not only a binary crate.main.rsis moved tobin/bender.rsand calls the bender library now (with thebender::prefix)extern crateare removed (not required anymore since the 2018 edition).cmd/mod.rsis replaced withcmd.rs, which collects all modules incmdFurthermore, new Rust editions typically change some formatting rules and some new clippy warnings surfaced (e.g. unused functions), which were fixed.