@@ -3,7 +3,7 @@ use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed
33use rustc_macros:: { LintDiagnostic , SessionDiagnostic , SessionSubdiagnostic } ;
44use rustc_middle:: ty:: Ty ;
55use rustc_session:: SessionDiagnostic ;
6- use rustc_span:: { symbol:: Ident , Span , Symbol } ;
6+ use rustc_span:: { symbol:: Ident , Span , Symbol , source_map :: SourceMap } ;
77
88#[ derive( SessionDiagnostic ) ]
99#[ diag( typeck:: field_multiply_specified_in_initializer, code = "E0062" ) ]
@@ -241,15 +241,16 @@ pub struct UnconstrainedOpaqueType {
241241 pub name : Symbol ,
242242}
243243
244- pub struct MissingTypeParams {
244+ pub struct MissingTypeParams < ' a > {
245245 pub span : Span ,
246246 pub def_span : Span ,
247247 pub missing_type_params : Vec < Symbol > ,
248248 pub empty_generic_args : bool ,
249+ pub source_map : & ' a SourceMap ,
249250}
250251
251252// Manual implementation of `SessionDiagnostic` to be able to call `span_to_snippet`.
252- impl < ' a > SessionDiagnostic < ' a > for MissingTypeParams {
253+ impl < ' a > SessionDiagnostic < ' a > for MissingTypeParams < ' a > {
253254 fn into_diagnostic ( self , handler : & ' a Handler ) -> DiagnosticBuilder < ' a , ErrorGuaranteed > {
254255 let mut err = handler. struct_span_err_with_code (
255256 self . span ,
@@ -269,8 +270,8 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
269270 err. span_label ( self . def_span , rustc_errors:: fluent:: typeck:: label) ;
270271
271272 let mut suggested = false ;
272- if let ( Some ( Ok ( snippet) ) , true ) = (
273- handler . span_to_snippet_from_emitter ( self . span ) ,
273+ if let ( Ok ( snippet) , true ) = (
274+ self . source_map . span_to_snippet ( self . span ) ,
274275 // Don't suggest setting the type params if there are some already: the order is
275276 // tricky to get right and the user will already know what the syntax is.
276277 self . empty_generic_args ,
0 commit comments