Rollup merge of #117416 - compiler-errors:tait-in-bad-body, r=oli-obk
Also consider TAIT to be uncomputable if the MIR body is tainted Not totally sure if this is the best solution. We could, alternatively, look at the hir typeck results and try to take a type from there instead of just falling back to type error, inferring `u8` instead of `{type error}`. Not certain it really matters, though. Happy to iterate on this. Fixes #117413 r? ``@oli-obk`` cc ``@Nadrieril``
This commit is contained in:
commit
8daa317a4b
3 changed files with 42 additions and 3 deletions
|
@ -183,9 +183,17 @@ impl TaitConstraintLocator<'_> {
|
|||
};
|
||||
|
||||
// Use borrowck to get the type with unerased regions.
|
||||
let concrete_opaque_types = &self.tcx.mir_borrowck(item_def_id).concrete_opaque_types;
|
||||
debug!(?concrete_opaque_types);
|
||||
if let Some(&concrete_type) = concrete_opaque_types.get(&self.def_id) {
|
||||
let borrowck_results = &self.tcx.mir_borrowck(item_def_id);
|
||||
|
||||
// If the body was tainted, then assume the opaque may have been constrained and just set it to error.
|
||||
if let Some(guar) = borrowck_results.tainted_by_errors {
|
||||
self.found =
|
||||
Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: Ty::new_error(self.tcx, guar) });
|
||||
return;
|
||||
}
|
||||
|
||||
debug!(?borrowck_results.concrete_opaque_types);
|
||||
if let Some(&concrete_type) = borrowck_results.concrete_opaque_types.get(&self.def_id) {
|
||||
debug!(?concrete_type, "found constraint");
|
||||
if let Some(prev) = &mut self.found {
|
||||
if concrete_type.ty != prev.ty && !(concrete_type, prev.ty).references_error() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue