Skip to content

Commit f0b79e3

Browse files
committed
trait_sel: re-order host effect evaluations
When evaluating a host effect predicate on an opaque in `addr2line`, running `evaluate_host_effect_from_bounds` first would create an opaque type which wouldn't be removed from opaque type storage and that would cause a delayed bug - creating a small reproduction of this has been tricky but if `builtin_impls` checking is moved below `evaluate_host_effect_from_item_bounds` then it will trigger. The correct fix is probably to work out why the opaque type is created and then not used, but this was particularly tricky. Given that this root cause wasn't identified, writing a test case proved difficult.
1 parent b0cca58 commit f0b79e3

File tree

1 file changed

+9
-3
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+9
-3
lines changed

compiler/rustc_trait_selection/src/traits/effects.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,25 @@ pub fn evaluate_host_effect_obligation<'tcx>(
3838
return Err(EvaluationFailure::Ambiguous);
3939
}
4040

41-
match evaluate_host_effect_from_bounds(selcx, obligation) {
41+
// FIXME: during implementation of `#![feature(sized_hierarchy)]`, when evaluating a host
42+
// effect predicate on an opaque in addr2line, running `evaluate_host_effect_from_bounds` first
43+
// would create an opaque type which wouldn't be removed from opaque type storage and that
44+
// would cause a delayed bug - creating a small reproduction of this has been tricky but if
45+
// `builtin_impls` checking is moved below `evaluate_host_effect_from_item_bounds` then it will
46+
// trigger.
47+
match evaluate_host_effect_from_builtin_impls(selcx, obligation) {
4248
Ok(result) => return Ok(result),
4349
Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous),
4450
Err(EvaluationFailure::NoSolution) => {}
4551
}
4652

47-
match evaluate_host_effect_from_item_bounds(selcx, obligation) {
53+
match evaluate_host_effect_from_bounds(selcx, obligation) {
4854
Ok(result) => return Ok(result),
4955
Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous),
5056
Err(EvaluationFailure::NoSolution) => {}
5157
}
5258

53-
match evaluate_host_effect_from_builtin_impls(selcx, obligation) {
59+
match evaluate_host_effect_from_item_bounds(selcx, obligation) {
5460
Ok(result) => return Ok(result),
5561
Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous),
5662
Err(EvaluationFailure::NoSolution) => {}

0 commit comments

Comments
 (0)