-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
iwls-0.0.2 fails its test suite in Rust 1.15 beta #38685
Comments
Minimized: use std::cmp;
type ChannelLoad = (ChannelId, f64);
type ChannelsLoad = Vec<ChannelLoad>;
type ChannelId = u8;
const MAX_SUGGESTIONS: usize = 5;
fn least_intersected(id: ChannelId) -> bool {
for &i in &[1, 6, 11, 14] {
if i == id {
return true;
}
}
false
}
fn compute_suggestion() -> Vec<ChannelId> {
let mut channels_load: ChannelsLoad = vec![
(1, 0.0),
(2, 0.0),
(3, 0.0),
(4, 0.0),
(5, 0.0),
(6, 0.0),
(7, 0.0),
(8, 0.0),
(9, 0.0),
(10, 0.0),
(11, 0.0),
(12, 0.0),
(13, 0.0),
(14, 0.0),
];
channels_load.sort_by(|a, _b| {
if least_intersected(a.0) {
cmp::Ordering::Less
} else {
cmp::Ordering::Equal
}
});
channels_load.iter()
.take(MAX_SUGGESTIONS)
.map(|&(id, _)| id)
.collect()
}
fn main() {
assert_eq!(&[14, 11, 6, 1, 2], compute_suggestion().as_slice());
} The cause I would guess is #38192 (cc @stjepang, @bluss) and it looks like it's just relying on particulars of our sorting algorithm. I would hazard a guess that this isn't really a regression. |
I don't see anything obvious in the reduced case that would be perturbed by an algorithm change. |
Oh, the comparison function is very weird here, depending on only one of its arguments. I'm not sure what it's trying to capture but it's definitely capturing effects from the algorithm. |
This seems to be the original sort closure https://github.com/alopatindev/iwls/blob/7316d2125f848914e90b26d532dc2165db4054bf/src/lib.rs#L224-L230 I think they can use Edit: That solution was not tested, and it fails because float are not Ord! So that explains why using |
According to the comparison function, these two statements are true at the same time:
Therefore, the function is nonsensical. There is no correct sorted order here. :) This is definitely not a regression and can be closed. |
Regression from 1.14.
https://github.com/alopatindev/iwls commit 7316d2125f848914e90b26d532dc2165db4054bf
cc @alopatindev
The text was updated successfully, but these errors were encountered: