Skip to content

Commit ec005cc

Browse files
committed
Separate the construction of a generic bound failure from its emission.
1 parent 87e729f commit ec005cc

File tree

1 file changed

+20
-4
lines changed
  • src/librustc/infer/error_reporting

1 file changed

+20
-4
lines changed

Diff for: src/librustc/infer/error_reporting/mod.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10861086
bound_kind: GenericKind<'tcx>,
10871087
sub: Region<'tcx>,
10881088
) {
1089+
self.construct_generic_bound_failure(region_scope_tree,
1090+
span,
1091+
origin,
1092+
bound_kind,
1093+
sub)
1094+
.emit()
1095+
}
1096+
1097+
pub fn construct_generic_bound_failure(
1098+
&self,
1099+
region_scope_tree: &region::ScopeTree,
1100+
span: Span,
1101+
origin: Option<SubregionOrigin<'tcx>>,
1102+
bound_kind: GenericKind<'tcx>,
1103+
sub: Region<'tcx>,
1104+
) -> DiagnosticBuilder<'a>
1105+
{
10891106
// Attempt to obtain the span of the parameter so we can
10901107
// suggest adding an explicit lifetime bound to it.
10911108
let type_param_span = match (self.in_progress_tables, bound_kind) {
@@ -1139,14 +1156,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11391156
trait_item_def_id,
11401157
}) = origin
11411158
{
1142-
self.report_extra_impl_obligation(
1159+
return self.report_extra_impl_obligation(
11431160
span,
11441161
item_name,
11451162
impl_item_def_id,
11461163
trait_item_def_id,
11471164
&format!("`{}: {}`", bound_kind, sub),
1148-
).emit();
1149-
return;
1165+
);
11501166
}
11511167

11521168
fn binding_suggestion<'tcx, S: fmt::Display>(
@@ -1229,7 +1245,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12291245
if let Some(origin) = origin {
12301246
self.note_region_origin(&mut err, &origin);
12311247
}
1232-
err.emit();
1248+
err
12331249
}
12341250

12351251
fn report_sub_sup_conflict(

0 commit comments

Comments
 (0)