diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-21 12:31:48 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-21 12:31:48 +0000 |
| commit | e0a2e2d892252ed6e6264ce5cc8dae3dd2800f4a (patch) | |
| tree | 63dd0711721d0f198d972d86c22e6b5777118804 /compiler | |
| parent | 1de00d1ac5247a02184ef7ad044f6521ade7e0cc (diff) | |
| download | rust-e0a2e2d892252ed6e6264ce5cc8dae3dd2800f4a.tar.gz rust-e0a2e2d892252ed6e6264ce5cc8dae3dd2800f4a.zip | |
Deduplicate two functions that would soon have been three
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/writeback.rs | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index 9ecf34e9ad3..680dbf7037f 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -717,27 +717,13 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { Resolver { tcx: fcx.tcx, infcx: fcx, span, body, replaced_with_error: false } } - fn report_type_error(&self, t: Ty<'tcx>) { + fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) { if !self.tcx.sess.has_errors().is_some() { self.infcx .emit_inference_failure_err( Some(self.body.id()), self.span.to_span(self.tcx), - t.into(), - E0282, - false, - ) - .emit(); - } - } - - fn report_const_error(&self, c: ty::Const<'tcx>) { - if self.tcx.sess.has_errors().is_none() { - self.infcx - .emit_inference_failure_err( - Some(self.body.id()), - self.span.to_span(self.tcx), - c.into(), + p.into(), E0282, false, ) @@ -782,7 +768,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { } Err(_) => { debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t); - self.report_type_error(t); + self.report_error(t); self.replaced_with_error = true; self.tcx().ty_error() } @@ -799,7 +785,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { Ok(ct) => self.tcx.erase_regions(ct), Err(_) => { debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct); - self.report_const_error(ct); + self.report_error(ct); self.replaced_with_error = true; self.tcx().const_error(ct.ty()) } |
