wbcx.typeck_results.treat_byte_string_as_slice =
mem::take(&mut self.typeck_results.borrow_mut().treat_byte_string_as_slice);
- if self.is_tainted_by_errors() {
- // FIXME(eddyb) keep track of `ErrorGuaranteed` from where the error was emitted.
- wbcx.typeck_results.tainted_by_errors =
- Some(ErrorGuaranteed::unchecked_claim_error_was_emitted());
+ if let Some(e) = self.tainted_by_errors() {
+ wbcx.typeck_results.tainted_by_errors = Some(e);
}
debug!("writeback: typeck results for {:?} are {:#?}", item_def_id, wbcx.typeck_results);
// We may have introduced e.g. `ty::Error`, if inference failed, make sure
// to mark the `TypeckResults` as tainted in that case, so that downstream
// users of the typeck results don't produce extra errors, or worse, ICEs.
- if resolver.replaced_with_error {
- // FIXME(eddyb) keep track of `ErrorGuaranteed` from where the error was emitted.
- self.typeck_results.tainted_by_errors =
- Some(ErrorGuaranteed::unchecked_claim_error_was_emitted());
+ if let Some(e) = resolver.replaced_with_error {
+ self.typeck_results.tainted_by_errors = Some(e);
}
x
span: &'cx dyn Locatable,
body: &'tcx hir::Body<'tcx>,
- /// Set to `true` if any `Ty` or `ty::Const` had to be replaced with an `Error`.
- replaced_with_error: bool,
+ /// Set to `Some` if any `Ty` or `ty::Const` had to be replaced with an `Error`.
+ replaced_with_error: Option<ErrorGuaranteed>,
}
impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
span: &'cx dyn Locatable,
body: &'tcx hir::Body<'tcx>,
) -> Resolver<'cx, 'tcx> {
- Resolver { tcx: fcx.tcx, infcx: fcx, span, body, replaced_with_error: false }
+ Resolver { tcx: fcx.tcx, infcx: fcx, span, body, replaced_with_error: None }
}
- fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) {
- if !self.tcx.sess.has_errors().is_some() {
- self.infcx
+ fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
+ match self.tcx.sess.has_errors() {
+ Some(e) => e,
+ None => self
+ .infcx
.err_ctxt()
.emit_inference_failure_err(
Some(self.body.id()),
E0282,
false,
)
- .emit();
+ .emit(),
}
}
}
}
Err(_) => {
debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t);
- self.report_error(t);
- self.replaced_with_error = true;
- self.tcx().ty_error()
+ let e = self.report_error(t);
+ self.replaced_with_error = Some(e);
+ self.tcx().ty_error_with_guaranteed(e)
}
}
}
Ok(ct) => self.tcx.erase_regions(ct),
Err(_) => {
debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct);
- self.report_error(ct);
- self.replaced_with_error = true;
- self.tcx().const_error(ct.ty())
+ let e = self.report_error(ct);
+ self.replaced_with_error = Some(e);
+ self.tcx().const_error_with_guaranteed(ct.ty(), e)
}
}
}