|
16 | 16 |
|
17 | 17 | use self::TargetLint::*;
|
18 | 18 |
|
19 |
| -use crate::hir::map::definitions::{DefPathData, DisambiguatedDefPathData}; |
20 |
| -use crate::lint::passes::{EarlyLintPassObject, LateLintPassObject}; |
21 |
| -use crate::lint::LintLevelsBuilder; |
22 |
| -use crate::middle::privacy::AccessLevels; |
23 |
| -use crate::middle::stability; |
24 |
| -use crate::ty::layout::{LayoutError, LayoutOf, TyLayout}; |
25 |
| -use crate::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; |
| 19 | +use crate::levels::LintLevelsBuilder; |
| 20 | +use crate::passes::{EarlyLintPassObject, LateLintPassObject}; |
| 21 | +use rustc::hir::map::definitions::{DefPathData, DisambiguatedDefPathData}; |
| 22 | +use rustc::lint::add_elided_lifetime_in_path_suggestion; |
| 23 | +use rustc::middle::privacy::AccessLevels; |
| 24 | +use rustc::middle::stability; |
| 25 | +use rustc::ty::layout::{LayoutError, LayoutOf, TyLayout}; |
| 26 | +use rustc::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; |
26 | 27 | use rustc_data_structures::fx::FxHashMap;
|
27 | 28 | use rustc_data_structures::sync;
|
28 | 29 | use rustc_error_codes::*;
|
29 |
| -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; |
| 30 | +use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; |
30 | 31 | use rustc_hir as hir;
|
31 | 32 | use rustc_hir::def_id::{CrateNum, DefId};
|
32 | 33 | use rustc_session::lint::BuiltinLintDiagnostics;
|
@@ -467,48 +468,6 @@ impl LintPassObject for EarlyLintPassObject {}
|
467 | 468 |
|
468 | 469 | impl LintPassObject for LateLintPassObject {}
|
469 | 470 |
|
470 |
| -pub fn add_elided_lifetime_in_path_suggestion( |
471 |
| - sess: &Session, |
472 |
| - db: &mut DiagnosticBuilder<'_>, |
473 |
| - n: usize, |
474 |
| - path_span: Span, |
475 |
| - incl_angl_brckt: bool, |
476 |
| - insertion_span: Span, |
477 |
| - anon_lts: String, |
478 |
| -) { |
479 |
| - let (replace_span, suggestion) = if incl_angl_brckt { |
480 |
| - (insertion_span, anon_lts) |
481 |
| - } else { |
482 |
| - // When possible, prefer a suggestion that replaces the whole |
483 |
| - // `Path<T>` expression with `Path<'_, T>`, rather than inserting `'_, ` |
484 |
| - // at a point (which makes for an ugly/confusing label) |
485 |
| - if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) { |
486 |
| - // But our spans can get out of whack due to macros; if the place we think |
487 |
| - // we want to insert `'_` isn't even within the path expression's span, we |
488 |
| - // should bail out of making any suggestion rather than panicking on a |
489 |
| - // subtract-with-overflow or string-slice-out-out-bounds (!) |
490 |
| - // FIXME: can we do better? |
491 |
| - if insertion_span.lo().0 < path_span.lo().0 { |
492 |
| - return; |
493 |
| - } |
494 |
| - let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize; |
495 |
| - if insertion_index > snippet.len() { |
496 |
| - return; |
497 |
| - } |
498 |
| - let (before, after) = snippet.split_at(insertion_index); |
499 |
| - (path_span, format!("{}{}{}", before, anon_lts, after)) |
500 |
| - } else { |
501 |
| - (insertion_span, anon_lts) |
502 |
| - } |
503 |
| - }; |
504 |
| - db.span_suggestion( |
505 |
| - replace_span, |
506 |
| - &format!("indicate the anonymous lifetime{}", pluralize!(n)), |
507 |
| - suggestion, |
508 |
| - Applicability::MachineApplicable, |
509 |
| - ); |
510 |
| -} |
511 |
| - |
512 | 471 | pub trait LintContext: Sized {
|
513 | 472 | type PassObject: LintPassObject;
|
514 | 473 |
|
|
0 commit comments