]> git.lizzy.rs Git - rust.git/commitdiff
Update ui test
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 21 Apr 2017 11:28:31 +0000 (13:28 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 21 Apr 2017 20:58:15 +0000 (22:58 +0200)
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/demand.rs
src/test/ui/span/coerce-suggestions.rs
src/test/ui/span/coerce-suggestions.stderr

index a769b55c520baa159af2e5330d4f48ea12f93626..d21b5f739bd7b5510712cc7eac3c43c44cfdf034 100644 (file)
@@ -65,8 +65,8 @@
 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 @@ pub fn try_coerce(&self,
     }
 
     /// 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,
index 0fd98232becfa03f7722b14628050b6936d19b69..4cc3f2dacdfe996a77e4fc4c641595ce49109871 100644 (file)
@@ -93,7 +93,7 @@ pub fn demand_coerce(&self,
                                                              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")));
                 }
             }
index 3177e858ff4fd3b89ada820f849ce3a9889ffc66..bc3122bf71c0e21056a40d31e75e4a41f6e032ed 100644 (file)
@@ -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
index 6a70b8ff851d7aecf1d7eb82380e4113d9e905f4..220b2f471da9ad7aef33e4d22a67ab811adbb778 100644 (file)
@@ -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 `_`