@@ -1086,6 +1086,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
1086
1086
bound_kind : GenericKind < ' tcx > ,
1087
1087
sub : Region < ' tcx > ,
1088
1088
) {
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
+ {
1089
1106
// Attempt to obtain the span of the parameter so we can
1090
1107
// suggest adding an explicit lifetime bound to it.
1091
1108
let type_param_span = match ( self . in_progress_tables , bound_kind) {
@@ -1139,14 +1156,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
1139
1156
trait_item_def_id,
1140
1157
} ) = origin
1141
1158
{
1142
- self . report_extra_impl_obligation (
1159
+ return self . report_extra_impl_obligation (
1143
1160
span,
1144
1161
item_name,
1145
1162
impl_item_def_id,
1146
1163
trait_item_def_id,
1147
1164
& format ! ( "`{}: {}`" , bound_kind, sub) ,
1148
- ) . emit ( ) ;
1149
- return ;
1165
+ ) ;
1150
1166
}
1151
1167
1152
1168
fn binding_suggestion < ' tcx , S : fmt:: Display > (
@@ -1229,7 +1245,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
1229
1245
if let Some ( origin) = origin {
1230
1246
self . note_region_origin ( & mut err, & origin) ;
1231
1247
}
1232
- err. emit ( ) ;
1248
+ err
1233
1249
}
1234
1250
1235
1251
fn report_sub_sup_conflict (
0 commit comments