1
1
use hir:: GenericParamKind ;
2
2
use rustc_errors:: {
3
- fluent, AddSubdiagnostic , Applicability , DiagnosticMessage , DiagnosticStyledString ,
3
+ fluent, AddSubdiagnostic , Applicability , DiagnosticMessage , DiagnosticStyledString , MultiSpan ,
4
4
} ;
5
5
use rustc_hir as hir;
6
6
use rustc_hir:: { FnRetTy , Ty } ;
@@ -273,8 +273,8 @@ pub enum LifetimeMismatchLabels {
273
273
ty_sup : Span ,
274
274
ty_sub : Span ,
275
275
span : Span ,
276
- label_var1 : Option < Ident > ,
277
- label_var2 : Option < Ident > ,
276
+ sup : Option < Ident > ,
277
+ sub : Option < Ident > ,
278
278
} ,
279
279
}
280
280
@@ -293,8 +293,8 @@ impl AddSubdiagnostic for LifetimeMismatchLabels {
293
293
ty_sup,
294
294
ty_sub,
295
295
span,
296
- label_var1,
297
- label_var2,
296
+ sup : label_var1,
297
+ sub : label_var2,
298
298
} => {
299
299
if hir_equal {
300
300
diag. span_label ( ty_sup, fluent:: infer:: declared_multiple) ;
@@ -422,68 +422,57 @@ pub struct LifetimeMismatch<'a> {
422
422
pub suggestion : AddLifetimeParamsSuggestion < ' a > ,
423
423
}
424
424
425
- pub mod mismatched_static_lifetime {
426
- use rustc_errors:: { self , fluent, AddSubdiagnostic , MultiSpan } ;
427
- use rustc_span:: Span ;
428
-
429
- use super :: note_and_explain;
430
-
431
- pub struct LabeledMultiSpan {
432
- pub multi_span : MultiSpan ,
433
- pub binding_span : Span ,
434
- }
435
-
436
- impl AddSubdiagnostic for LabeledMultiSpan {
437
- fn add_to_diagnostic ( mut self , diag : & mut rustc_errors:: Diagnostic ) {
438
- self . multi_span
439
- . push_span_label ( self . binding_span , fluent:: infer:: msl_introduces_static) ;
440
- diag. span_note ( self . multi_span , fluent:: infer:: msl_unmet_req) ;
441
- }
442
- }
425
+ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
426
+ pub unmet_requirements : MultiSpan ,
427
+ pub binding_span : Span ,
428
+ }
443
429
444
- pub struct ImplNote {
445
- pub impl_span : Option < Span > ,
430
+ impl AddSubdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
431
+ fn add_to_diagnostic ( mut self , diag : & mut rustc_errors:: Diagnostic ) {
432
+ self . unmet_requirements
433
+ . push_span_label ( self . binding_span , fluent:: infer:: msl_introduces_static) ;
434
+ diag. span_note ( self . unmet_requirements , fluent:: infer:: msl_unmet_req) ;
446
435
}
436
+ }
447
437
448
- impl AddSubdiagnostic for ImplNote {
449
- fn add_to_diagnostic ( self , diag : & mut rustc_errors:: Diagnostic ) {
450
- match self . impl_span {
451
- Some ( span) => diag. span_note ( span, fluent:: infer:: msl_impl_note) ,
452
- None => diag. note ( fluent:: infer:: msl_impl_note) ,
453
- } ;
454
- }
455
- }
438
+ pub struct ImplNote {
439
+ pub impl_span : Option < Span > ,
440
+ }
456
441
457
- #[ derive( SessionSubdiagnostic ) ]
458
- pub enum TraitSubdiag {
459
- #[ note( infer:: msl_trait_note) ]
460
- Note {
461
- #[ primary_span]
462
- span : Span ,
463
- } ,
464
- #[ suggestion_verbose(
465
- infer:: msl_trait_sugg,
466
- code = " + '_" ,
467
- applicability = "maybe-incorrect"
468
- ) ]
469
- Sugg {
470
- #[ primary_span]
471
- span : Span ,
472
- } ,
442
+ impl AddSubdiagnostic for ImplNote {
443
+ fn add_to_diagnostic ( self , diag : & mut rustc_errors:: Diagnostic ) {
444
+ match self . impl_span {
445
+ Some ( span) => diag. span_note ( span, fluent:: infer:: msl_impl_note) ,
446
+ None => diag. note ( fluent:: infer:: msl_impl_note) ,
447
+ } ;
473
448
}
449
+ }
474
450
475
- #[ derive( SessionDiagnostic ) ]
476
- #[ diag( infer:: mismatched_static_lifetime) ]
477
- pub struct MismatchedStaticLifetime < ' a > {
451
+ #[ derive( SessionSubdiagnostic ) ]
452
+ pub enum TraitSubdiag {
453
+ #[ note( infer:: msl_trait_note) ]
454
+ Note {
478
455
#[ primary_span]
479
- pub cause_span : Span ,
480
- #[ subdiagnostic]
481
- pub multispan_subdiag : LabeledMultiSpan ,
482
- #[ subdiagnostic]
483
- pub expl : Option < note_and_explain:: RegionExplanation < ' a > > ,
484
- #[ subdiagnostic]
485
- pub impl_note : ImplNote ,
486
- #[ subdiagnostic]
487
- pub trait_subdiags : Vec < TraitSubdiag > ,
488
- }
456
+ span : Span ,
457
+ } ,
458
+ #[ suggestion_verbose( infer:: msl_trait_sugg, code = " + '_" , applicability = "maybe-incorrect" ) ]
459
+ Sugg {
460
+ #[ primary_span]
461
+ span : Span ,
462
+ } ,
463
+ }
464
+
465
+ #[ derive( SessionDiagnostic ) ]
466
+ #[ diag( infer:: mismatched_static_lifetime) ]
467
+ pub struct MismatchedStaticLifetime < ' a > {
468
+ #[ primary_span]
469
+ pub cause_span : Span ,
470
+ #[ subdiagnostic]
471
+ pub unmet_lifetime_reqs : IntroducesStaticBecauseUnmetLifetimeReq ,
472
+ #[ subdiagnostic]
473
+ pub expl : Option < note_and_explain:: RegionExplanation < ' a > > ,
474
+ #[ subdiagnostic]
475
+ pub impl_note : ImplNote ,
476
+ #[ subdiagnostic]
477
+ pub trait_subdiags : Vec < TraitSubdiag > ,
489
478
}
0 commit comments