Skip to content

Commit fc9bfd6

Browse files
committed
Modify SubtypeFormat
1 parent 0570158 commit fc9bfd6

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub mod on_unimplemented_format;
77
mod overflow;
88
pub mod suggestions;
99

10-
use std::cmp::Reverse;
1110
use std::{fmt, iter};
1211

1312
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
@@ -139,7 +138,7 @@ pub enum DefIdOrName {
139138

140139
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
141140
enum ErrorSortKey {
142-
SubtypeFormat(Reverse<(usize, usize)>),
141+
SubtypeFormat(usize, usize),
143142
OtherKind,
144143
SizedTrait,
145144
MetaSizedTrait,
@@ -199,7 +198,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
199198
|| self.tcx.is_diagnostic_item(sym::format_args_macro, def_id))
200199
&& span_file.src_hash == source_file.src_hash =>
201200
{
202-
ErrorSortKey::SubtypeFormat(Reverse((row, col)))
201+
ErrorSortKey::SubtypeFormat(row, col)
203202
}
204203
_ if maybe_sizedness_did == self.tcx.lang_items().sized_trait() => ErrorSortKey::SizedTrait,
205204
_ if maybe_sizedness_did == self.tcx.lang_items().meta_sized_trait() => ErrorSortKey::MetaSizedTrait,

tests/ui/errors/span-format_args-issue-140578.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn check_unformatted() {
2424
{a}
2525
{a:?}",
2626
[],
27+
//~^ ERROR type annotations needed
2728
[],
28-
//~^ ERROR type annotations needed
2929
a = 1 + 1);
3030
}
3131

tests/ui/errors/span-format_args-issue-140578.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ LL | println!("{:?} {a} {a:?}", [], a = 1 + 1);
1515
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
1616

1717
error[E0282]: type annotations needed
18-
--> $DIR/span-format_args-issue-140578.rs:12:39
18+
--> $DIR/span-format_args-issue-140578.rs:12:35
1919
|
2020
LL | println!("{:?} {:?} {a} {a:?}", [], [], a = 1 + 1);
21-
| ^^ cannot infer type
21+
| ^^ cannot infer type
2222
|
2323
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
2424

2525
error[E0282]: type annotations needed
26-
--> $DIR/span-format_args-issue-140578.rs:17:64
26+
--> $DIR/span-format_args-issue-140578.rs:17:41
2727
|
2828
LL | println!("{:?} {:?} {a} {a:?} {b:?}", [], [], a = 1 + 1, b = []);
29-
| ^^ cannot infer type
29+
| ^^ cannot infer type
3030
|
3131
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
3232

3333
error[E0282]: type annotations needed
34-
--> $DIR/span-format_args-issue-140578.rs:27:2
34+
--> $DIR/span-format_args-issue-140578.rs:26:9
3535
|
36-
LL | [],
37-
| ^^ cannot infer type
36+
LL | [],
37+
| ^^ cannot infer type
3838
|
3939
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
4040

0 commit comments

Comments
 (0)