File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
compiler/rustc_errors/src Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -630,18 +630,27 @@ impl Diagnostic {
630
630
style : SuggestionStyle ,
631
631
) -> & mut Self {
632
632
assert ! ( !suggestion. is_empty( ) ) ;
633
- debug_assert ! (
634
- !( suggestion. iter( ) . any( |( sp, text) | sp. is_empty( ) && text. is_empty( ) ) ) ,
635
- "Span must not be empty and have no suggestion"
633
+
634
+ let mut parts = suggestion
635
+ . into_iter ( )
636
+ . map ( |( span, snippet) | SubstitutionPart { snippet, span } )
637
+ . collect :: < Vec < _ > > ( ) ;
638
+
639
+ parts. sort_unstable_by_key ( |part| part. span ) ;
640
+
641
+ debug_assert_eq ! (
642
+ None ,
643
+ parts. iter( ) . find( |part| part. span. is_empty( ) && part. snippet. is_empty( ) ) ,
644
+ "Span must not be empty and have no suggestion" ,
645
+ ) ;
646
+ debug_assert_eq ! (
647
+ None ,
648
+ parts. array_windows( ) . find( |[ a, b] | a. span. overlaps( b. span) ) ,
649
+ "suggestion must not have overlapping parts" ,
636
650
) ;
637
651
638
652
self . push_suggestion ( CodeSuggestion {
639
- substitutions : vec ! [ Substitution {
640
- parts: suggestion
641
- . into_iter( )
642
- . map( |( span, snippet) | SubstitutionPart { snippet, span } )
643
- . collect( ) ,
644
- } ] ,
653
+ substitutions : vec ! [ Substitution { parts } ] ,
645
654
msg : self . subdiagnostic_message_to_diagnostic_message ( msg) ,
646
655
style,
647
656
applicability,
Original file line number Diff line number Diff line change 3
3
//! This module contains the code for creating and emitting diagnostics.
4
4
5
5
#![ doc( html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/" ) ]
6
+ #![ feature( array_windows) ]
6
7
#![ feature( drain_filter) ]
7
8
#![ feature( if_let_guard) ]
8
9
#![ feature( is_terminal) ]
You can’t perform that action at this time.
0 commit comments