@@ -163,17 +163,26 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
163
163
// Ensure `T: Sized` and `T: WF` obligations come last. This lets us display diagnostics
164
164
// with more relevant type information and hide redundant E0282 errors.
165
165
errors. sort_by_key ( |e| match e. obligation . predicate . kind ( ) . skip_binder ( ) {
166
- ty:: PredicateKind :: Subtype ( _) => {
167
- ( -1 , e. obligation . cause . span . len ( ) , -( e. obligation . cause . span . index ( ) as i32 ) )
166
+ ty:: PredicateKind :: Subtype ( _)
167
+ if e. obligation . cause . span . macro_backtrace ( ) . next ( ) . is_some_and (
168
+ |trace| match trace. kind {
169
+ ExpnKind :: Macro ( _, name) => {
170
+ name. as_str ( ) . rsplit ( "::" ) . next ( ) == Some ( "format_args_nl" )
171
+ }
172
+ _ => false ,
173
+ } ,
174
+ ) =>
175
+ {
176
+ ( -1 , e. obligation . cause . span . index ( ) )
168
177
}
169
178
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( pred) )
170
179
if self . tcx . is_lang_item ( pred. def_id ( ) , LangItem :: Sized ) =>
171
180
{
172
- ( 1 , 0 , 0 )
181
+ ( 1 , 0 )
173
182
}
174
- ty:: PredicateKind :: Coerce ( _) => ( 2 , 0 , 0 ) ,
175
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( _) ) => ( 3 , 0 , 0 ) ,
176
- _ => ( 0 , 0 , 0 ) ,
183
+ ty:: PredicateKind :: Coerce ( _) => ( 2 , 0 ) ,
184
+ ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( _) ) => ( 3 , 0 ) ,
185
+ _ => ( 0 , 0 ) ,
177
186
} ) ;
178
187
179
188
for ( index, error) in errors. iter ( ) . enumerate ( ) {
0 commit comments