Skip to content
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

Fix stacked-borrows violations in Vector #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CraftSpider
Copy link

Also adds annotations to make running miri test easier for vector. This doesn't yet add those annotations to other places in the codebase. The full_retain test is needed to ensure tests cover TreeFocusMut::get_many.

With these changes, miri reports no UB running the non-ignored parts of the test suite.

@CraftSpider
Copy link
Author

Depends on this: jneem/imbl-sized-chunks#8

@@ -936,6 +971,26 @@ where
Some(&mut self.get_focus()[target_phys_index])
}

pub fn get_many<const N: usize>(
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe call this get_many_mut to match the other one? Also, does it need to be pub? If so, I think it needs to be documented. If not, maybe you could even make all the internal functions unsafe and skip the index-checking. Because internally we're already checking indices in, e.g. triplet

Copy link
Author

Choose a reason for hiding this comment

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

I skipped the mut because the above get method also skips it, despite returning a mutable reference. In terms of needing to be pub, it doesn't really need to be, though it may be useful to users. To match the std pattern of such APIs, if it stays public, there should likely be an unsafe variant that skips the checks, then triplet can use it.

Copy link
Owner

Choose a reason for hiding this comment

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

Makes sense, thanks. I don't have a strong opinion about whether it should be pub or not, just that if it's pub then its documentation should be up to par with the documentation on other pub methods.

@@ -246,26 +246,31 @@ mod test {
use serde_json::{from_str, to_string};

proptest! {
#[cfg_attr(miri, ignore)]
Copy link
Owner

Choose a reason for hiding this comment

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

Could you explain in a comment somewhere the criterion for excluding a test from miri? Also, if you want to exclude a whole mod then maybe just #[cfg(not(miri))] at the top is easier instead of annotating every test.

Copy link
Author

Choose a reason for hiding this comment

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

The logic behind not using cfg(not(miri)) is that it causes a bunch of 'unused import' warnings, and with ignore it's possible to use --ignored to run it anyways, if you really want to try waiting for it to complete.

I'll add some documentation when I get a minute. For posterity, it's basically just 'takes more than ~30 seconds to run', and some tests may actually prefer running but with reduced iteration values. I just didn't want to take the time to track down why the specific iteration numbers were chosen for many of the issue tests, to find out whether they could be reduced and still have the test be meaningful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants