|
8 | 8 | //! Thank you! |
9 | 9 | //! ~The `INTERNAL_METADATA_COLLECTOR` lint |
10 | 10 |
|
11 | | -use rustc_errors::{emitter::MAX_SUGGESTION_HIGHLIGHT_LINES, Applicability, Diagnostic}; |
| 11 | +use rustc_errors::{emitter::MAX_SUGGESTION_HIGHLIGHT_LINES, Applicability, Diagnostic, MultiSpan}; |
12 | 12 | use rustc_hir::HirId; |
13 | 13 | use rustc_lint::{LateContext, Lint, LintContext}; |
14 | | -use rustc_span::source_map::{MultiSpan, Span}; |
| 14 | +use rustc_span::source_map::Span; |
15 | 15 | use std::env; |
16 | 16 |
|
17 | 17 | fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) { |
@@ -155,7 +155,13 @@ where |
155 | 155 | }); |
156 | 156 | } |
157 | 157 |
|
158 | | -pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: &str) { |
| 158 | +pub fn span_lint_hir( |
| 159 | + cx: &LateContext<'_>, |
| 160 | + lint: &'static Lint, |
| 161 | + hir_id: HirId, |
| 162 | + sp: Span, |
| 163 | + msg: &str, |
| 164 | +) { |
159 | 165 | cx.tcx.struct_span_lint_hir(lint, hir_id, sp, |diag| { |
160 | 166 | let mut diag = diag.build(msg); |
161 | 167 | docs_link(&mut diag, lint); |
@@ -272,9 +278,14 @@ pub fn span_lint_and_sugg_for_edges( |
272 | 278 | let sugg_lines_count = sugg.lines().count(); |
273 | 279 | if sugg_lines_count > MAX_SUGGESTION_HIGHLIGHT_LINES { |
274 | 280 | let sm = cx.sess().source_map(); |
275 | | - if let (Ok(line_upper), Ok(line_bottom)) = (sm.lookup_line(sp.lo()), sm.lookup_line(sp.hi())) { |
| 281 | + if let (Ok(line_upper), Ok(line_bottom)) = |
| 282 | + (sm.lookup_line(sp.lo()), sm.lookup_line(sp.hi())) |
| 283 | + { |
276 | 284 | let split_idx = MAX_SUGGESTION_HIGHLIGHT_LINES / 2; |
277 | | - let span_upper = sm.span_until_char(sp.with_hi(line_upper.sf.lines[line_upper.line + split_idx]), '\n'); |
| 285 | + let span_upper = sm.span_until_char( |
| 286 | + sp.with_hi(line_upper.sf.lines[line_upper.line + split_idx]), |
| 287 | + '\n', |
| 288 | + ); |
278 | 289 | let span_bottom = sp.with_lo(line_bottom.sf.lines[line_bottom.line - split_idx]); |
279 | 290 |
|
280 | 291 | let sugg_lines_vec = sugg.lines().collect::<Vec<&str>>(); |
|
0 commit comments