about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2017-04-21 13:28:31 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2017-04-21 22:58:15 +0200
commit7ce1eb77c77ce0a56efc7d11ac8003e6a95208d0 (patch)
tree04f62abcf127f53f03f0c8e8df7739198ec74f9f
parent7d3284ebc18f3d4087d71352421726b2240a7c20 (diff)
downloadrust-7ce1eb77c77ce0a56efc7d11ac8003e6a95208d0.tar.gz
rust-7ce1eb77c77ce0a56efc7d11ac8003e6a95208d0.zip
Update ui test
-rw-r--r--src/librustc_typeck/check/coercion.rs23
-rw-r--r--src/librustc_typeck/check/demand.rs2
-rw-r--r--src/test/ui/span/coerce-suggestions.rs1
-rw-r--r--src/test/ui/span/coerce-suggestions.stderr14
4 files changed, 10 insertions, 30 deletions
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index a769b55c520..d21b5f739bd 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -65,8 +65,8 @@ use check::{Diverges, FnCtxt};
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc::infer::{Coercion, InferResult, InferOk, TypeTrace};
-use rustc::infer::type_variable::{TypeVariableOrigin};
-use rustc::traits::{self, /*FulfillmentContext,*/ ObligationCause, ObligationCauseCode};
+use rustc::infer::type_variable::TypeVariableOrigin;
+use rustc::traits::{self, ObligationCause, ObligationCauseCode};
 use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
 use rustc::ty::{self, LvaluePreference, TypeAndMut,
                 Ty, ClosureSubsts};
@@ -724,28 +724,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
     }
 
     /// Same as `try_coerce()`, but without side-effects.
-    pub fn can_coerce(&self,
-                      expr_ty: Ty<'tcx>,
-                      target: Ty<'tcx>)
-                      -> bool {
-        // FIXME: This is a hack, but coercion wasn't made to be run
-        // in a probe. It leaks obligations and bounds and things out
-        // into the environment. For now we just save-and-restore the
-        // fulfillment context.
-        /*let saved_fulfillment_cx =
-            mem::replace(
-                &mut *self.inh.fulfillment_cx.borrow_mut(),
-                FulfillmentContext::new());*/
+    pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
         let source = self.resolve_type_vars_with_obligations(expr_ty);
         debug!("coercion::can({:?} -> {:?})", source, target);
 
         let cause = self.cause(syntax_pos::DUMMY_SP, ObligationCauseCode::ExprAssignable);
         let coerce = Coerce::new(self, cause);
-        let result = self.probe(|_| coerce.coerce::<hir::Expr>(&[], source, target)).is_ok();
-
-        //*self.inh.fulfillment_cx.borrow_mut() = saved_fulfillment_cx;
-
-        result
+        self.probe(|_| coerce.coerce::<hir::Expr>(&[], source, target)).is_ok()
     }
 
     /// Given some expressions, their known unified type and another expression,
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index 0fd98232bec..4cc3f2dacdf 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -93,7 +93,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                                                              ast::DUMMY_NODE_ID);
                 if suggestions.len() > 0 {
                     err.help(&format!("here are some functions which \
-                                       might fulfill your needs:\n - {}",
+                                       might fulfill your needs:\n{}",
                                       self.get_best_match(&suggestions).join("\n")));
                 }
             }
diff --git a/src/test/ui/span/coerce-suggestions.rs b/src/test/ui/span/coerce-suggestions.rs
index 3177e858ff4..bc3122bf71c 100644
--- a/src/test/ui/span/coerce-suggestions.rs
+++ b/src/test/ui/span/coerce-suggestions.rs
@@ -32,7 +32,6 @@ fn main() {
     //~| NOTE types differ in mutability
     //~| NOTE expected type `&mut std::string::String`
     //~| NOTE found type `&std::string::String`
-    //~| HELP try with `&mut y`
     test2(&y);
     //~^ ERROR E0308
     //~| NOTE types differ in mutability
diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr
index 6a70b8ff851..220b2f471da 100644
--- a/src/test/ui/span/coerce-suggestions.stderr
+++ b/src/test/ui/span/coerce-suggestions.stderr
@@ -18,11 +18,7 @@ error[E0308]: mismatched types
    |
    = note: expected type `&str`
               found type `std::string::String`
-   = help: here are some functions which might fulfill your needs:
-           - .as_str()
-           - .trim()
-           - .trim_left()
-           - .trim_right()
+   = help: try with `&String::new()`
 
 error[E0308]: mismatched types
   --> $DIR/coerce-suggestions.rs:30:10
@@ -34,18 +30,18 @@ error[E0308]: mismatched types
               found type `&std::string::String`
 
 error[E0308]: mismatched types
-  --> $DIR/coerce-suggestions.rs:36:11
+  --> $DIR/coerce-suggestions.rs:35:11
    |
-36 |     test2(&y);
+35 |     test2(&y);
    |           ^^ types differ in mutability
    |
    = note: expected type `&mut i32`
               found type `&std::string::String`
 
 error[E0308]: mismatched types
-  --> $DIR/coerce-suggestions.rs:42:9
+  --> $DIR/coerce-suggestions.rs:41:9
    |
-42 |     f = box f;
+41 |     f = box f;
    |         ^^^^^ cyclic type of infinite size
    |
    = note: expected type `_`