-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fmt: remove crash! macro #5589
Merged
Merged
fmt: remove crash! macro #5589
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d65a3f8
fmt: remove crash! macro
Arp-1 002e02f
Fix styling in fmt
Arp-1 6d3770c
Revert "Fix styling in fmt"
Arp-1 4c63ad9
Revert "fmt: remove crash! macro"
Arp-1 f07f58f
Replace crash! with unreachable! macro
Arp-1 c73238c
Remove crash! import
Arp-1 816b54c
Merge remote-tracking branch 'upstream/main' into fmt-remove-crash-macro
Arp-1 6ece056
Remove unreachable! from fmt
Arp-1 4ab393d
keep the helpful comment
Arp-1 40c70d7
Fix lint and format issues
Arp-1 ee19d9b
Merge remote-tracking branch 'upstream/main' into fmt-remove-crash-macro
Arp-1 5680fb9
Merge remote-tracking branch 'upstream/main' into fmt-remove-crash-macro
Arp-1 9a0d435
review fixes
Arp-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,8 +8,6 @@ | |||||
use std::io::{BufWriter, Stdout, Write}; | ||||||
use std::{cmp, i64, mem}; | ||||||
|
||||||
use uucore::crash; | ||||||
|
||||||
use crate::parasplit::{ParaWords, Paragraph, WordInfo}; | ||||||
use crate::FmtOptions; | ||||||
|
||||||
|
@@ -363,28 +361,27 @@ fn find_kp_breakpoints<'a, T: Iterator<Item = &'a WordInfo<'a>>>( | |||||
} | ||||||
|
||||||
fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> Vec<(&'a WordInfo<'a>, bool)> { | ||||||
let mut breakwords = vec![]; | ||||||
// of the active paths, we select the one with the fewest demerits | ||||||
let mut best_idx = match active.iter().min_by_key(|&&a| paths[a].demerits) { | ||||||
None => crash!( | ||||||
1, | ||||||
"Failed to find a k-p linebreak solution. This should never happen." | ||||||
), | ||||||
Some(&s) => s, | ||||||
}; | ||||||
|
||||||
// now, chase the pointers back through the break list, recording | ||||||
// the words at which we should break | ||||||
loop { | ||||||
let next_best = &paths[best_idx]; | ||||||
match next_best.linebreak { | ||||||
None => return breakwords, | ||||||
Some(prev) => { | ||||||
breakwords.push((prev, next_best.break_before)); | ||||||
best_idx = next_best.prev; | ||||||
active | ||||||
.iter() | ||||||
.min_by_key(|&&a| paths[a].demerits) | ||||||
.iter() | ||||||
.flat_map(|&&(mut best_idx)| { | ||||||
let mut breakwords = vec![]; | ||||||
// now, chase the pointers back through the break list, recording | ||||||
// the words at which we should break | ||||||
loop { | ||||||
let next_best = &paths[best_idx]; | ||||||
match next_best.linebreak { | ||||||
None => return breakwords, | ||||||
Some(prev) => { | ||||||
breakwords.push((prev, next_best.break_before)); | ||||||
best_idx = next_best.prev; | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
}) | ||||||
.collect() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||||||
} | ||||||
|
||||||
// "infinite" badness is more like (1+BAD_INFTY)^2 because of how demerits are computed | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!