Skip to content

Revise generate function to return Result #4430

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Owen-CH-Leung
Copy link

@Owen-CH-Leung Owen-CH-Leung commented Apr 26, 2025

Description

As per #4369 , the generate function should return a Result instead of returning nothing.

This PR is a continuation of #4424 which was closed due to bad rebase.

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot
Copy link
Collaborator

rustbot commented Apr 26, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added ctest Issues relating to the ctest crate S-waiting-on-review labels Apr 26, 2025
@Owen-CH-Leung Owen-CH-Leung marked this pull request as ready for review April 27, 2025 00:39
ctest/src/lib.rs Outdated
use std::collections::{HashMap, HashSet};
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufWriter;
use std::panic::{catch_unwind, AssertUnwindSafe};
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately we can't use catch_unwind; if somebody has panic = abort in their Cargo.toml or if run on a target/backend that doesn't support unwinding, the program will stop and catch_unwind won't actually catch anything. All functions that may return an error need to change their signature then update .unwrap() / .expect() to ?.

Everything else looks pretty good to me, but I'll re-review after the changes.

(basically my same comment from #4424 (comment))

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. I've removed the remaining catch_unwind logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctest Issues relating to the ctest crate S-waiting-on-author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants