Skip to content

Commit a508011

Browse files
Expect deep norm to fail if query norm failed
1 parent df1da67 commit a508011

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
621621
&ocx, op, span,
622622
) {
623623
Ok(_) => ocx.select_all_or_error(),
624-
Err(e) => {
625-
if e.is_empty() {
626-
ocx.select_all_or_error()
627-
} else {
628-
e
629-
}
630-
}
624+
Err(e) => e,
631625
};
632626

633627
// Could have no errors if a type lowering error, say, caused the query

compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,23 @@ where
204204
return Err(errors);
205205
}
206206

207-
ocx.deeply_normalize(&cause, param_env, ty)?;
208-
209-
let errors = ocx.select_where_possible();
210-
debug!("normalize errors: {ty} ~> {errors:#?}");
211-
return Err(errors);
207+
// When query normalization fails, we don't get back an interesting
208+
// reason that we could use to report an error in borrowck. In order to turn
209+
// this into a reportable error, we deeply normalize again. We don't expect
210+
// this to succeed, so delay a bug if it does.
211+
match ocx.deeply_normalize(&cause, param_env, ty) {
212+
Ok(_) => {
213+
tcx.dcx().span_delayed_bug(
214+
span,
215+
format!(
216+
"query normalize succeeded of {ty}, \
217+
but deep normalize failed",
218+
),
219+
);
220+
ty
221+
}
222+
Err(errors) => return Err(errors),
223+
}
212224
};
213225

214226
match ty.kind() {

0 commit comments

Comments
 (0)