Skip to content

Commit 91b9ffe

Browse files
committed
Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed` and coercion errors to the end of the list. The pre-existing deduplication logic eliminates redundant errors better that way, keeping the resulting output with fewer errors than before, while also having more detail.
1 parent 2817ece commit 91b9ffe

File tree

76 files changed

+309
-403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+309
-403
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn check_opaque_type_well_formed<'tcx>(
368368
if errors.is_empty() {
369369
Ok(definition_ty)
370370
} else {
371-
Err(infcx.err_ctxt().report_fulfillment_errors(&errors))
371+
Err(infcx.err_ctxt().report_fulfillment_errors(errors))
372372
}
373373
}
374374

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
743743

744744
let errors = ocx.select_all_or_error();
745745
if !errors.is_empty() {
746-
infcx.err_ctxt().report_fulfillment_errors(&errors);
746+
infcx.err_ctxt().report_fulfillment_errors(errors);
747747
}
748748

749749
// Attempting to call a trait method?

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ fn check_opaque_meets_bounds<'tcx>(
327327
// version.
328328
let errors = ocx.select_all_or_error();
329329
if !errors.is_empty() {
330-
let guar = infcx.err_ctxt().report_fulfillment_errors(&errors);
330+
let guar = infcx.err_ctxt().report_fulfillment_errors(errors);
331331
return Err(guar);
332332
}
333333
match origin {
@@ -1512,6 +1512,6 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
15121512
let errors = fulfillment_cx.select_all_or_error(&infcx);
15131513
debug!(?errors);
15141514
if !errors.is_empty() {
1515-
infcx.err_ctxt().report_fulfillment_errors(&errors);
1515+
infcx.err_ctxt().report_fulfillment_errors(errors);
15161516
}
15171517
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn compare_method_predicate_entailment<'tcx>(
323323
// FIXME(-Ztrait-solver=next): Not needed when the hack below is removed.
324324
let errors = ocx.select_where_possible();
325325
if !errors.is_empty() {
326-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
326+
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
327327
return Err(reported);
328328
}
329329

@@ -394,7 +394,7 @@ fn compare_method_predicate_entailment<'tcx>(
394394
});
395395
}
396396
CheckImpliedWfMode::Skip => {
397-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
397+
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
398398
return Err(reported);
399399
}
400400
}
@@ -874,7 +874,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
874874
// RPITs.
875875
let errors = ocx.select_all_or_error();
876876
if !errors.is_empty() {
877-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
877+
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
878878
return Err(reported);
879879
}
880880

@@ -2050,7 +2050,7 @@ fn compare_const_predicate_entailment<'tcx>(
20502050
// version.
20512051
let errors = ocx.select_all_or_error();
20522052
if !errors.is_empty() {
2053-
return Err(infcx.err_ctxt().report_fulfillment_errors(&errors));
2053+
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
20542054
}
20552055

20562056
let outlives_env = OutlivesEnvironment::new(param_env);
@@ -2143,7 +2143,7 @@ fn compare_type_predicate_entailment<'tcx>(
21432143
// version.
21442144
let errors = ocx.select_all_or_error();
21452145
if !errors.is_empty() {
2146-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
2146+
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
21472147
return Err(reported);
21482148
}
21492149

@@ -2358,7 +2358,7 @@ pub(super) fn check_type_bounds<'tcx>(
23582358
// version.
23592359
let errors = ocx.select_all_or_error();
23602360
if !errors.is_empty() {
2361-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
2361+
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
23622362
return Err(reported);
23632363
}
23642364

compiler/rustc_hir_analysis/src/check/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
158158
ocx.register_bound(cause, param_env, norm_return_ty, term_did);
159159
let errors = ocx.select_all_or_error();
160160
if !errors.is_empty() {
161-
infcx.err_ctxt().report_fulfillment_errors(&errors);
161+
infcx.err_ctxt().report_fulfillment_errors(errors);
162162
error = true;
163163
}
164164
// now we can take the return type of the given main function

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ pub fn check_function_signature<'tcx>(
588588
Ok(()) => {
589589
let errors = ocx.select_all_or_error();
590590
if !errors.is_empty() {
591-
infcx.err_ctxt().report_fulfillment_errors(&errors);
591+
infcx.err_ctxt().report_fulfillment_errors(errors);
592592
return;
593593
}
594594
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
116116

117117
let errors = wfcx.select_all_or_error();
118118
if !errors.is_empty() {
119-
infcx.err_ctxt().report_fulfillment_errors(&errors);
119+
infcx.err_ctxt().report_fulfillment_errors(errors);
120120
return;
121121
}
122122

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
261261
}
262262
let errors = ocx.select_all_or_error();
263263
if !errors.is_empty() {
264-
infcx.err_ctxt().report_fulfillment_errors(&errors);
264+
infcx.err_ctxt().report_fulfillment_errors(errors);
265265
}
266266

267267
// Finally, resolve all regions.
@@ -470,7 +470,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
470470
ocx.register_obligation(obligation);
471471
let errors = ocx.select_all_or_error();
472472
if !errors.is_empty() {
473-
infcx.err_ctxt().report_fulfillment_errors(&errors);
473+
infcx.err_ctxt().report_fulfillment_errors(errors);
474474
}
475475

476476
// Finally, resolve all regions.

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn get_impl_args(
196196

197197
let errors = ocx.select_all_or_error();
198198
if !errors.is_empty() {
199-
let guar = ocx.infcx.err_ctxt().report_fulfillment_errors(&errors);
199+
let guar = ocx.infcx.err_ctxt().report_fulfillment_errors(errors);
200200
return Err(guar);
201201
}
202202

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30103010
// There should be at least one error reported. If not, we
30113011
// will still delay a span bug in `report_fulfillment_errors`.
30123012
Ok::<_, NoSolution>((
3013-
self.err_ctxt().report_fulfillment_errors(&errors),
3013+
self.err_ctxt().report_fulfillment_errors(errors),
30143014
impl_trait_ref.args.type_at(1),
30153015
element_ty,
30163016
))

0 commit comments

Comments
 (0)