Skip to content

Commit 80cbc6d

Browse files
authored
Rollup merge of #131753 - compiler-errors:swap-secondary, r=jieyouxu
Unify `secondary_span` and `swap_secondary_and_primary` args in `note_type_err` Tiny tweak b/c working w `note_type_err` is kinda a mess.
2 parents 3b8fd5f + 4886e9a commit 80cbc6d

File tree

6 files changed

+11
-22
lines changed

6 files changed

+11
-22
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,13 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
592592
&cause,
593593
hir.get_if_local(impl_m.def_id)
594594
.and_then(|node| node.fn_decl())
595-
.map(|decl| (decl.output.span(), Cow::from("return type in trait"))),
595+
.map(|decl| (decl.output.span(), Cow::from("return type in trait"), false)),
596596
Some(infer::ValuePairs::Terms(ExpectedFound {
597597
expected: trait_return_ty.into(),
598598
found: impl_return_ty.into(),
599599
})),
600600
terr,
601601
false,
602-
false,
603602
);
604603
return Err(diag.emit());
605604
}
@@ -1018,14 +1017,13 @@ fn report_trait_method_mismatch<'tcx>(
10181017
infcx.err_ctxt().note_type_err(
10191018
&mut diag,
10201019
&cause,
1021-
trait_err_span.map(|sp| (sp, Cow::from("type in trait"))),
1020+
trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)),
10221021
Some(infer::ValuePairs::PolySigs(ExpectedFound {
10231022
expected: ty::Binder::dummy(trait_sig),
10241023
found: ty::Binder::dummy(impl_sig),
10251024
})),
10261025
terr,
10271026
false,
1028-
false,
10291027
);
10301028

10311029
diag.emit()
@@ -1825,14 +1823,13 @@ fn compare_const_predicate_entailment<'tcx>(
18251823
infcx.err_ctxt().note_type_err(
18261824
&mut diag,
18271825
&cause,
1828-
trait_c_span.map(|span| (span, Cow::from("type in trait"))),
1826+
trait_c_span.map(|span| (span, Cow::from("type in trait"), false)),
18291827
Some(infer::ValuePairs::Terms(ExpectedFound {
18301828
expected: trait_ty.into(),
18311829
found: impl_ty.into(),
18321830
})),
18331831
terr,
18341832
false,
1835-
false,
18361833
);
18371834
return Err(diag.emit());
18381835
};

Diff for: compiler/rustc_hir_analysis/src/check/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,6 @@ pub fn check_function_signature<'tcx>(
652652
})),
653653
err,
654654
false,
655-
false,
656655
);
657656
return Err(diag.emit());
658657
}

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11141114
None,
11151115
Some(trace.values),
11161116
e,
1117-
false,
11181117
true,
11191118
);
11201119
}

Diff for: compiler/rustc_passes/src/check_attr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2302,7 +2302,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23022302
})),
23032303
terr,
23042304
false,
2305-
false,
23062305
);
23072306
diag.emit();
23082307
self.abort.set(true);

Diff for: compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -1127,18 +1127,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11271127
/// the message in `secondary_span` as the primary label, and apply the message that would
11281128
/// otherwise be used for the primary label on the `secondary_span` `Span`. This applies on
11291129
/// E0271, like `tests/ui/issues/issue-39970.stderr`.
1130-
#[instrument(
1131-
level = "debug",
1132-
skip(self, diag, secondary_span, swap_secondary_and_primary, prefer_label)
1133-
)]
1130+
#[instrument(level = "debug", skip(self, diag, secondary_span, prefer_label))]
11341131
pub fn note_type_err(
11351132
&self,
11361133
diag: &mut Diag<'_>,
11371134
cause: &ObligationCause<'tcx>,
1138-
secondary_span: Option<(Span, Cow<'static, str>)>,
1135+
secondary_span: Option<(Span, Cow<'static, str>, bool)>,
11391136
mut values: Option<ValuePairs<'tcx>>,
11401137
terr: TypeError<'tcx>,
1141-
swap_secondary_and_primary: bool,
11421138
prefer_label: bool,
11431139
) {
11441140
let span = cause.span();
@@ -1304,7 +1300,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13041300
diag.span_note(span, msg);
13051301
}
13061302
};
1307-
if let Some((sp, msg)) = secondary_span {
1303+
if let Some((secondary_span, secondary_msg, swap_secondary_and_primary)) = secondary_span {
13081304
if swap_secondary_and_primary {
13091305
let terr = if let Some(infer::ValuePairs::Terms(ExpectedFound {
13101306
expected, ..
@@ -1314,11 +1310,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13141310
} else {
13151311
terr.to_string(self.tcx)
13161312
};
1317-
label_or_note(sp, terr);
1318-
label_or_note(span, msg);
1313+
label_or_note(secondary_span, terr);
1314+
label_or_note(span, secondary_msg);
13191315
} else {
13201316
label_or_note(span, terr.to_string(self.tcx));
1321-
label_or_note(sp, msg);
1317+
label_or_note(secondary_span, secondary_msg);
13221318
}
13231319
} else if let Some(values) = values
13241320
&& let Some((e, f)) = values.ty()
@@ -1788,7 +1784,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17881784
self.type_error_additional_suggestions(&trace, terr),
17891785
);
17901786
let mut diag = self.dcx().create_err(failure_code);
1791-
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false, false);
1787+
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false);
17921788
diag
17931789
}
17941790

Diff for: compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
710710
None,
711711
TypeError::Sorts(ty::error::ExpectedFound::new(true, expected_ty, ct_ty)),
712712
false,
713-
false,
714713
);
715714
diag
716715
}
@@ -1435,6 +1434,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
14351434
cx.into_buffer()
14361435
}
14371436
))),
1437+
true,
14381438
)),
14391439
_ => None,
14401440
}
@@ -1452,7 +1452,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
14521452
))
14531453
}),
14541454
err,
1455-
true,
14561455
false,
14571456
);
14581457
self.note_obligation_cause(&mut diag, obligation);

0 commit comments

Comments
 (0)