@@ -3,7 +3,7 @@ use std::cmp;
33use crate :: ich:: StableHashingContext ;
44use rustc_data_structures:: fx:: FxHashMap ;
55use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6- use rustc_errors:: { pluralize , Applicability , DiagnosticBuilder , DiagnosticId } ;
6+ use rustc_errors:: { DiagnosticBuilder , DiagnosticId } ;
77use rustc_hir:: HirId ;
88use rustc_session:: lint:: { builtin, Level , Lint , LintId } ;
99use rustc_session:: { DiagnosticMessageId , Session } ;
@@ -350,45 +350,3 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
350350 ExpnKind :: Macro ( ..) => true , // definitely a plugin
351351 }
352352}
353-
354- pub fn add_elided_lifetime_in_path_suggestion (
355- sess : & Session ,
356- db : & mut DiagnosticBuilder < ' _ > ,
357- n : usize ,
358- path_span : Span ,
359- incl_angl_brckt : bool ,
360- insertion_span : Span ,
361- anon_lts : String ,
362- ) {
363- let ( replace_span, suggestion) = if incl_angl_brckt {
364- ( insertion_span, anon_lts)
365- } else {
366- // When possible, prefer a suggestion that replaces the whole
367- // `Path<T>` expression with `Path<'_, T>`, rather than inserting `'_, `
368- // at a point (which makes for an ugly/confusing label)
369- if let Ok ( snippet) = sess. source_map ( ) . span_to_snippet ( path_span) {
370- // But our spans can get out of whack due to macros; if the place we think
371- // we want to insert `'_` isn't even within the path expression's span, we
372- // should bail out of making any suggestion rather than panicking on a
373- // subtract-with-overflow or string-slice-out-out-bounds (!)
374- // FIXME: can we do better?
375- if insertion_span. lo ( ) . 0 < path_span. lo ( ) . 0 {
376- return ;
377- }
378- let insertion_index = ( insertion_span. lo ( ) . 0 - path_span. lo ( ) . 0 ) as usize ;
379- if insertion_index > snippet. len ( ) {
380- return ;
381- }
382- let ( before, after) = snippet. split_at ( insertion_index) ;
383- ( path_span, format ! ( "{}{}{}" , before, anon_lts, after) )
384- } else {
385- ( insertion_span, anon_lts)
386- }
387- } ;
388- db. span_suggestion (
389- replace_span,
390- & format ! ( "indicate the anonymous lifetime{}" , pluralize!( n) ) ,
391- suggestion,
392- Applicability :: MachineApplicable ,
393- ) ;
394- }
0 commit comments