@@ -539,7 +539,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
539
539
fallback_has_occurred: bool)
540
540
{
541
541
let span = obligation.cause.span;
542
- let _ = fallback_has_occurred;
543
542
544
543
let mut err = match *error {
545
544
SelectionError::Unimplemented => {
@@ -623,9 +622,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
623
622
self.report_similar_impl_candidates(impl_candidates, &mut err);
624
623
}
625
624
626
- // If this error is due to `!: !Trait` but `(): Trait` then add a note
627
- // about the fallback behaviour change.
628
- if trait_predicate.skip_binder().self_ty().is_never() {
625
+ // If this error is due to `!: Trait` not implemented but `(): Trait` is
626
+ // implemented, and fallback has occured, then it could be due to a
627
+ // variable that used to fallback to `()` now falling back to `!`. Issue a
628
+ // note informing about the change in behaviour.
629
+ if trait_predicate.skip_binder().self_ty().is_never()
630
+ && fallback_has_occurred
631
+ {
629
632
let predicate = trait_predicate.map_bound(|mut trait_pred| {
630
633
{
631
634
let trait_ref = &mut trait_pred.trait_ref;
@@ -638,13 +641,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
638
641
trait_pred
639
642
});
640
643
let unit_obligation = Obligation {
641
- cause: obligation.cause.clone(),
642
- param_env: obligation.param_env,
643
- recursion_depth: obligation.recursion_depth,
644
- predicate,
644
+ predicate: ty::Predicate::Trait(predicate),
645
+ .. obligation.clone()
645
646
};
646
647
let mut selcx = SelectionContext::new(self);
647
- if let Ok(Some(..)) = selcx.select (&unit_obligation) {
648
+ if selcx.evaluate_obligation (&unit_obligation) {
648
649
err.note("the trait is implemented for `()`. \
649
650
Possibly this error has been caused by changes to \
650
651
Rust's type-inference algorithm \
0 commit comments