diff options
| author | bors <bors@rust-lang.org> | 2021-01-15 09:27:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-15 09:27:21 +0000 |
| commit | 4e208f6a3afb42528878b0f3464e337c4bf3bbc8 (patch) | |
| tree | 21529ff86f6f364980511a8cb4cb7a0001ae29c0 /compiler/rustc_span/src | |
| parent | dcf622eb70aebe16d40c5f88fa2a41fa7019541c (diff) | |
| parent | 7286be15fa3f18ea4bd5b6ce481426f7d78e4a57 (diff) | |
| download | rust-4e208f6a3afb42528878b0f3464e337c4bf3bbc8.tar.gz rust-4e208f6a3afb42528878b0f3464e337c4bf3bbc8.zip | |
Auto merge of #81035 - JohnTitor:rollup-9m03awf, r=JohnTitor
Rollup of 5 pull requests
Successful merges:
- #80254 (Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv`)
- #80834 (Remove unreachable panics from VecDeque::{front/back}[_mut])
- #80944 (Use Option::map_or instead of `.map(..).unwrap_or(..)`)
- #81008 (Don't ICE when computing a layout of a generator tainted by errors)
- #81023 (Remove doctree::Variant)
Failed merges:
- #81033 (Remove useless `clean::Variant` struct)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/source_map.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_span/src/source_map/tests.rs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 842ccda6ea8..4e0ce0d344d 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -539,7 +539,7 @@ impl SourceMap { pub fn is_line_before_span_empty(&self, sp: Span) -> bool { match self.span_to_prev_source(sp) { - Ok(s) => s.split('\n').last().map(|l| l.trim_start().is_empty()).unwrap_or(false), + Ok(s) => s.split('\n').last().map_or(false, |l| l.trim_start().is_empty()), Err(_) => false, } } @@ -568,7 +568,7 @@ impl SourceMap { // asserting that the line numbers here are all indeed 1-based. let hi_line = hi.line.saturating_sub(1); for line_index in lo.line.saturating_sub(1)..hi_line { - let line_len = lo.file.get_line(line_index).map(|s| s.chars().count()).unwrap_or(0); + let line_len = lo.file.get_line(line_index).map_or(0, |s| s.chars().count()); lines.push(LineInfo { line_index, start_col, end_col: CharPos::from_usize(line_len) }); start_col = CharPos::from_usize(0); } diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs index b8459eee4ec..3f22829b049 100644 --- a/compiler/rustc_span/src/source_map/tests.rs +++ b/compiler/rustc_span/src/source_map/tests.rs @@ -107,7 +107,7 @@ fn t7() { fn span_from_selection(input: &str, selection: &str) -> Span { assert_eq!(input.len(), selection.len()); let left_index = selection.find('~').unwrap() as u32; - let right_index = selection.rfind('~').map(|x| x as u32).unwrap_or(left_index); + let right_index = selection.rfind('~').map_or(left_index, |x| x as u32); Span::with_root_ctxt(BytePos(left_index), BytePos(right_index + 1)) } |
