-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
core::hint::unreachable_unchecked()
is marked as uncovered.
#185
Comments
|
hmm unreachable should be ignored.. I'll look into it. And also cover the unreachable_unchecked |
@jonhoo your unreachable was because I wasn't going down into closures during source analysis. working on both of these things today 👍 |
Right both of these issues are now sorted in the source_analysis module with accompanying tests and merged into the develop branch.
|
So playing around with it a bit I encountered some weird behaviour, some sample code incoming: pub unsafe fn test() -> bool {
let var1 = if std::env::args_os().count() > 0 {
Some(())
} else {
None
};
if let Some(..) = var1 {
true
} else {
core::hint::unreachable_unchecked()
}
}
pub trait UncheckedUnwrap<T> {
unsafe fn unchecked_unwrap(self) -> T;
}
impl<T, E: core::fmt::Debug> UncheckedUnwrap<T> for Result<T, E> {
unsafe fn unchecked_unwrap(self) -> T {
if let Ok(value) = self {
value
} else {
core::hint::unreachable_unchecked()
}
}
} tests/test.rs use test_tarpaulin::UncheckedUnwrap;
#[test]
fn test() {
unsafe { test_tarpaulin::test() };
}
#[test]
fn result_unwrap_success() {
let result: Result<_, ()> = Ok(0);
assert_eq!(unsafe { result.unchecked_unwrap() }, 0);
}
|
The |
|
I'm going to close this as the core issue is solved and the remaining issues have been noted in other issues. Some progress but still figuring out a way to solve this that doesn't add any regressions in |
Thanks for your hard work! |
Sample report: codecov link
Lines with
core::hint::unreachable_unchecked()
are marked as untested.The text was updated successfully, but these errors were encountered: