diff options
| author | bors <bors@rust-lang.org> | 2021-01-10 08:01:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-10 08:01:12 +0000 |
| commit | 34628e5b533d35840b61c5db0665cf7633ed3c5a (patch) | |
| tree | bbdf4e4be0d4a44f172cf0528b45025d73300281 /compiler/rustc_span | |
| parent | 7a193921a024e910262ff90bfb028074fddf20d0 (diff) | |
| parent | 19b8c65e4e0af841a9ecaa99b5e1ae3c73ff9c7f (diff) | |
Auto merge of #80867 - JohnTitor:rollup-tvqw555, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #79502 (Implement From<char> for u64 and u128.) - #79968 (Improve core::ptr::drop_in_place debuginfo) - #80774 (Fix safety comment) - #80801 (Use correct span for structured suggestion) - #80803 (Remove useless `fill_in` function) - #80820 (Support `download-ci-llvm` on NixOS) - #80825 (Remove under-used ImplPolarity enum) - #80850 (Allow #[rustc_builtin_macro = "name"]) - #80857 (Add comment to `Vec::truncate` explaining `>` vs `>=`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_span')
| -rw-r--r-- | compiler/rustc_span/src/source_map.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index fefc0cb48dd..6635d44496c 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -671,7 +671,9 @@ impl SourceMap { let pat = pat.to_owned() + ws; if let Ok(prev_source) = self.span_to_prev_source(sp) { let prev_source = prev_source.rsplit(&pat).next().unwrap_or("").trim_start(); - if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) { + if prev_source.is_empty() && sp.lo().0 != 0 { + return sp.with_lo(BytePos(sp.lo().0 - 1)); + } else if !prev_source.contains('\n') || accept_newlines { return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32)); } } |
