diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-07-18 23:17:22 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-07-23 14:20:20 +0200 |
| commit | ec005ccf84e470a70f8bb8b5347ab8e793fb30a3 (patch) | |
| tree | 6c134a0e23961d1ae512404ea93be21f53ea4264 /src | |
| parent | 87e729f58a440c2b384f4871fb68f07afdbd3ba6 (diff) | |
| download | rust-ec005ccf84e470a70f8bb8b5347ab8e793fb30a3.tar.gz rust-ec005ccf84e470a70f8bb8b5347ab8e793fb30a3.zip | |
Separate the construction of a generic bound failure from its emission.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/infer/error_reporting/mod.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 1ec9c9489e9..4ad60f2f85e 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -1086,6 +1086,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { bound_kind: GenericKind<'tcx>, sub: Region<'tcx>, ) { + self.construct_generic_bound_failure(region_scope_tree, + span, + origin, + bound_kind, + sub) + .emit() + } + + pub fn construct_generic_bound_failure( + &self, + region_scope_tree: ®ion::ScopeTree, + span: Span, + origin: Option<SubregionOrigin<'tcx>>, + bound_kind: GenericKind<'tcx>, + sub: Region<'tcx>, + ) -> DiagnosticBuilder<'a> + { // Attempt to obtain the span of the parameter so we can // suggest adding an explicit lifetime bound to it. let type_param_span = match (self.in_progress_tables, bound_kind) { @@ -1139,14 +1156,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trait_item_def_id, }) = origin { - self.report_extra_impl_obligation( + return self.report_extra_impl_obligation( span, item_name, impl_item_def_id, trait_item_def_id, &format!("`{}: {}`", bound_kind, sub), - ).emit(); - return; + ); } fn binding_suggestion<'tcx, S: fmt::Display>( @@ -1229,7 +1245,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let Some(origin) = origin { self.note_region_origin(&mut err, &origin); } - err.emit(); + err } fn report_sub_sup_conflict( |
