rust/compiler/rustc_errors/src
Matthias Krüger 2066002b86
Rollup merge of #128852 - folkertdev:multipart-suggestion-stable-sort, r=compiler-errors
use stable sort to sort multipart diagnostics

I think a stable sort should be used to sort the different parts of a multipart selection. The current unstable sort uses the text of the suggestion as a tie-breaker. That just doesn't seem right, and the order of the input is a better choice I think, because it gives the diagnostic author more control.

This came up when I was building a suggestion where

```rust
fn foo() {}
```

must be turned into an unsafe function, and an attribute must be added

```rust
#[target_feature(enable = "...")]
unsafe fn foo() {}
```

In this example, the two suggestions occur at the same position, but the order is extremely important: unsafe must come after the attribute. But the situation changes if there is a pub/pub(crate), and if the unsafe is already present. It just out that because of the suggestion text, there is no way for me to order the suggestions correctly.

This change probably should be tested, but are there tests of the diagnostics code itself in the tests?

r? ```@estebank```
2024-08-09 18:24:58 +02:00
..
json Split ColorConfig off of HumanReadableErrorType 2024-08-08 14:41:33 +00:00
markdown Reformat use declarations. 2024-07-29 08:26:52 +10:00
annotate_snippet_emitter_writer.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
codes.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
diagnostic.rs use stable sort to sort multipart diagnostics 2024-08-09 09:45:01 +02:00
diagnostic_impls.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
emitter.rs Rollup merge of #128806 - estebank:color-config, r=jieyouxu 2024-08-09 00:03:36 +02:00
error.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
json.rs review comments 2024-08-08 14:58:52 +00:00
lib.rs Do not underline suggestions for code that is already there 2024-08-01 18:53:42 +00:00
lock.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
registry.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
snippet.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
styled_buffer.rs Replace some _ == _ || _ == _s with matches!(_, _ | _)s 2023-01-30 12:26:26 +00:00
tests.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
translation.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00