Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Miri failure with -Zmiri-tag-raw-pointers
Before this commit, running `MIRIFLAGS="-Zmiri-tag-raw-pointers" cargo miri test test_map_axis` caused Miri to report undefined behavior in the `test_map_axis` test. This commit fixes the underlying issue. Basically, Miri doesn't like us using a reference to an element to access other elements. Here's some sample code to illustrate the issue: ```rust let a: Vec<i32> = vec![5, 6]; let first_elt: &i32 = &a[0]; let ptr: *const i32 = first_elt as *const i32; // Okay: the data is contained in the data referenced by `first_elt`. let a0 = unsafe { &*ptr.offset(0) }; assert_eq!(*a0, 5); // Not okay: the data is not contained in the data referenced by `first_elt`. let a1 = unsafe { &*ptr.offset(1) }; assert_eq!(*a1, 6); ``` Before this commit, we were using `self.index_axis(axis, 0).map(|first_elt| ...)` to create views of the lanes, from references to the first elements in the lanes. Accessing elements within those views (other than the first element) led to the Miri error, since the view's pointer was derived from a reference to a single element. Thanks to @5225225 for reporting the issue. (This commit fixes #1137.)
- Loading branch information