about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAndrew Cann <shum@canndrew.org>2018-03-14 12:03:33 +0800
committerAndrew Cann <shum@canndrew.org>2018-03-14 12:44:52 +0800
commit00a52a2be36fd80e8430a524e8c0dad7b249af41 (patch)
tree187342c4be9058d92e05e83535b69f6c818574bd /src
parent5b32211e620a47b2c14dd313f0c3aa91e78f7361 (diff)
downloadrust-00a52a2be36fd80e8430a524e8c0dad7b249af41.tar.gz
rust-00a52a2be36fd80e8430a524e8c0dad7b249af41.zip
Fix fallback note
Diffstat (limited to 'src')
-rw-r--r--src/librustc/traits/error_reporting.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs
index b19935b8c4f..206a4bf6689 100644
--- a/src/librustc/traits/error_reporting.rs
+++ b/src/librustc/traits/error_reporting.rs
@@ -539,7 +539,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                                   fallback_has_occurred: bool)
     {
         let span = obligation.cause.span;
-        let _ = fallback_has_occurred;
 
         let mut err = match *error {
             SelectionError::Unimplemented => {
@@ -623,9 +622,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                             self.report_similar_impl_candidates(impl_candidates, &mut err);
                         }
 
-                        // If this error is due to `!: !Trait` but `(): Trait` then add a note
-                        // about the fallback behaviour change.
-                        if trait_predicate.skip_binder().self_ty().is_never() {
+                        // If this error is due to `!: Trait` not implemented but `(): Trait` is
+                        // implemented, and fallback has occured, then it could be due to a
+                        // variable that used to fallback to `()` now falling back to `!`. Issue a
+                        // note informing about the change in behaviour.
+                        if trait_predicate.skip_binder().self_ty().is_never()
+                            && fallback_has_occurred
+                        {
                             let predicate = trait_predicate.map_bound(|mut trait_pred| {
                                 {
                                     let trait_ref = &mut trait_pred.trait_ref;
@@ -638,13 +641,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                                 trait_pred
                             });
                             let unit_obligation = Obligation {
-                                cause: obligation.cause.clone(),
-                                param_env: obligation.param_env,
-                                recursion_depth: obligation.recursion_depth,
-                                predicate,
+                                predicate: ty::Predicate::Trait(predicate),
+                                .. obligation.clone()
                             };
                             let mut selcx = SelectionContext::new(self);
-                            if let Ok(Some(..)) = selcx.select(&unit_obligation) {
+                            if selcx.evaluate_obligation(&unit_obligation) {
                                 err.note("the trait is implemented for `()`. \
                                          Possibly this error has been caused by changes to \
                                          Rust's type-inference algorithm \