about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2017-06-24 19:28:43 -0700
committerEsteban Küber <esteban@kuber.com.ar>2017-06-24 19:28:43 -0700
commitc13a913e5b4136ecb81ec835586e596ecef1a4b3 (patch)
tree1de1401a476465f5b081159f99f18a9dfd41de44 /src
parent27d4b314c5b663a8382a33bd69cb8b27134fb3f8 (diff)
downloadrust-c13a913e5b4136ecb81ec835586e596ecef1a4b3.tar.gz
rust-c13a913e5b4136ecb81ec835586e596ecef1a4b3.zip
Don't naively point to return type on type error
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/coercion.rs6
-rw-r--r--src/librustc_typeck/check/mod.rs22
-rw-r--r--src/test/ui/block-result/issue-13624.stderr2
-rw-r--r--src/test/ui/block-result/issue-20862.stderr5
-rw-r--r--src/test/ui/block-result/issue-22645.stderr3
-rw-r--r--src/test/ui/block-result/issue-3563.stderr5
-rw-r--r--src/test/ui/block-result/issue-5500.stderr2
-rw-r--r--src/test/ui/block-result/unexpected-return-on-unit.stderr2
-rw-r--r--src/test/ui/impl-trait/equality.stderr3
-rw-r--r--src/test/ui/mismatched_types/abridged.stderr12
-rw-r--r--src/test/ui/mismatched_types/issue-19109.stderr5
-rw-r--r--src/test/ui/resolve/token-error-correct-3.stderr3
12 files changed, 3 insertions, 67 deletions
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index 660f6c5a093..4b5d02f9995 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -1174,12 +1174,6 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
                                                              expected, found,
                                                              cause.span, blk_id);
                     }
-                    ObligationCauseCode::ReturnType(ret_id) => {
-                        db = fcx.report_mismatched_types(cause, expected, found, err);
-                        if let Some((fn_decl, _)) = fcx.get_fn_decl(ret_id) {
-                            fcx.point_to_type_requirement(&mut db, &fn_decl, expected);
-                        }
-                    }
                     _ => {
                         db = fcx.report_mismatched_types(cause, expected, found, err);
                     }
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 50e2e390d02..7c4b6a858d9 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -4261,7 +4261,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
         self.suggest_missing_semicolon(err, expression, expected, cause_span);
 
         if let Some((fn_decl, is_main)) = self.get_fn_decl(blk_id) {
-            self.point_to_type_requirement(err, &fn_decl, expected);
             // `fn main()` must return `()`, do not suggest changing return type
             if !is_main {
                 self.suggest_missing_return_type(err, &fn_decl, found);
@@ -4269,27 +4268,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
         }
     }
 
-    pub fn point_to_type_requirement(&self,
-                                 err: &mut DiagnosticBuilder<'tcx>,
-                                 fn_decl: &hir::FnDecl,
-                                 ty: Ty<'tcx>) {
-        let msg = if let &hir::FnDecl {
-            output: hir::FunctionRetTy::DefaultReturn(_), ..
-        } = fn_decl {
-            "default "
-        } else {
-            ""
-        };
-        let ty = self.resolve_type_vars_if_possible(&ty);
-        if ty.to_string().len() < 10 {
-            err.span_label(fn_decl.output.span(),
-                           format!("expected `{}` because of this {}return type", ty, msg));
-        } else {
-            err.span_label(fn_decl.output.span(),
-                           format!("expected because of this {}return type", msg));
-        }
-    }
-
     /// A common error is to forget to add a semicolon at the end of a block:
     ///
     /// ```
diff --git a/src/test/ui/block-result/issue-13624.stderr b/src/test/ui/block-result/issue-13624.stderr
index 69c6e647cfc..72ff859d7e9 100644
--- a/src/test/ui/block-result/issue-13624.stderr
+++ b/src/test/ui/block-result/issue-13624.stderr
@@ -1,8 +1,6 @@
 error[E0308]: mismatched types
   --> $DIR/issue-13624.rs:17:5
    |
-16 |   pub fn get_enum_struct_variant() -> () {
-   |                                       -- expected `()` because of this return type
 17 |     Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
    |
diff --git a/src/test/ui/block-result/issue-20862.stderr b/src/test/ui/block-result/issue-20862.stderr
index 57cee8f7aca..e4367f170ce 100644
--- a/src/test/ui/block-result/issue-20862.stderr
+++ b/src/test/ui/block-result/issue-20862.stderr
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-20862.rs:12:5
    |
 11 | fn foo(x: i32) {
-   |                -
-   |                |
-   |                possibly return type missing here?
-   |                expected `()` because of this default return type
+   |                - possibly return type missing here?
 12 |     |y| x + y
    |     ^^^^^^^^^ expected (), found closure
    |
diff --git a/src/test/ui/block-result/issue-22645.stderr b/src/test/ui/block-result/issue-22645.stderr
index 93da3c6a489..3921a301c92 100644
--- a/src/test/ui/block-result/issue-22645.stderr
+++ b/src/test/ui/block-result/issue-22645.stderr
@@ -11,9 +11,6 @@ error[E0277]: the trait bound `{integer}: Scalar` is not satisfied
 error[E0308]: mismatched types
   --> $DIR/issue-22645.rs:25:3
    |
-23 | fn main() {
-   |           - expected `()` because of this default return type
-24 |   let b = Bob + 3.5;
 25 |   b + 3 //~ ERROR E0277
    |   ^^^^^ expected (), found struct `Bob`
    |
diff --git a/src/test/ui/block-result/issue-3563.stderr b/src/test/ui/block-result/issue-3563.stderr
index d995dee3827..c6ab4cbb2a7 100644
--- a/src/test/ui/block-result/issue-3563.stderr
+++ b/src/test/ui/block-result/issue-3563.stderr
@@ -8,10 +8,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-3563.rs:13:9
    |
 12 |     fn a(&self) {
-   |                 -
-   |                 |
-   |                 possibly return type missing here?
-   |                 expected `()` because of this default return type
+   |                 - possibly return type missing here?
 13 |         || self.b()
    |         ^^^^^^^^^^^ expected (), found closure
    |
diff --git a/src/test/ui/block-result/issue-5500.stderr b/src/test/ui/block-result/issue-5500.stderr
index 6fda2aa00ff..bffe2a82ca8 100644
--- a/src/test/ui/block-result/issue-5500.stderr
+++ b/src/test/ui/block-result/issue-5500.stderr
@@ -1,8 +1,6 @@
 error[E0308]: mismatched types
   --> $DIR/issue-5500.rs:12:5
    |
-11 | fn main() {
-   |           - expected `()` because of this default return type
 12 |     &panic!()
    |     ^^^^^^^^^ expected (), found reference
    |
diff --git a/src/test/ui/block-result/unexpected-return-on-unit.stderr b/src/test/ui/block-result/unexpected-return-on-unit.stderr
index e5481ffd316..18d0cc48140 100644
--- a/src/test/ui/block-result/unexpected-return-on-unit.stderr
+++ b/src/test/ui/block-result/unexpected-return-on-unit.stderr
@@ -1,8 +1,6 @@
 error[E0308]: mismatched types
   --> $DIR/unexpected-return-on-unit.rs:19:5
    |
-18 | fn bar() {
-   |          - expected `()` because of this default return type
 19 |     foo()
    |     ^^^^^ expected (), found usize
    |
diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr
index ca37596f1b9..2206234b777 100644
--- a/src/test/ui/impl-trait/equality.stderr
+++ b/src/test/ui/impl-trait/equality.stderr
@@ -1,9 +1,6 @@
 error[E0308]: mismatched types
   --> $DIR/equality.rs:25:5
    |
-21 | fn two(x: bool) -> impl Foo {
-   |                    -------- expected `i32` because of this return type
-...
 25 |     0_u32
    |     ^^^^^ expected i32, found u32
    |
diff --git a/src/test/ui/mismatched_types/abridged.stderr b/src/test/ui/mismatched_types/abridged.stderr
index 6282541ba0e..78b5dcda1d9 100644
--- a/src/test/ui/mismatched_types/abridged.stderr
+++ b/src/test/ui/mismatched_types/abridged.stderr
@@ -1,8 +1,6 @@
 error[E0308]: mismatched types
   --> $DIR/abridged.rs:26:5
    |
-25 | fn a() -> Foo {
-   |           --- expected `Foo` because of this return type
 26 |     Some(Foo { bar: 1 })
    |     ^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::option::Option`
    |
@@ -12,8 +10,6 @@ error[E0308]: mismatched types
 error[E0308]: mismatched types
   --> $DIR/abridged.rs:30:5
    |
-29 | fn a2() -> Foo {
-   |            --- expected `Foo` because of this return type
 30 |     Ok(Foo { bar: 1})
    |     ^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::result::Result`
    |
@@ -23,8 +19,6 @@ error[E0308]: mismatched types
 error[E0308]: mismatched types
   --> $DIR/abridged.rs:34:5
    |
-33 | fn b() -> Option<Foo> {
-   |           ----------- expected because of this return type
 34 |     Foo { bar: 1 }
    |     ^^^^^^^^^^^^^^ expected enum `std::option::Option`, found struct `Foo`
    |
@@ -34,8 +28,6 @@ error[E0308]: mismatched types
 error[E0308]: mismatched types
   --> $DIR/abridged.rs:38:5
    |
-37 | fn c() -> Result<Foo, Bar> {
-   |           ---------------- expected because of this return type
 38 |     Foo { bar: 1 }
    |     ^^^^^^^^^^^^^^ expected enum `std::result::Result`, found struct `Foo`
    |
@@ -45,8 +37,6 @@ error[E0308]: mismatched types
 error[E0308]: mismatched types
   --> $DIR/abridged.rs:42:5
    |
-41 |   fn d() -> X<X<String, String>, String> {
-   |             ---------------------------- expected because of this return type
 42 | /     X {
 43 | |         x: X {
 44 | |             x: "".to_string(),
@@ -62,8 +52,6 @@ error[E0308]: mismatched types
 error[E0308]: mismatched types
   --> $DIR/abridged.rs:52:5
    |
-51 |   fn e() -> X<X<String, String>, String> {
-   |             ---------------------------- expected because of this return type
 52 | /     X {
 53 | |         x: X {
 54 | |             x: "".to_string(),
diff --git a/src/test/ui/mismatched_types/issue-19109.stderr b/src/test/ui/mismatched_types/issue-19109.stderr
index 5efa3fa6a1d..083c1f95333 100644
--- a/src/test/ui/mismatched_types/issue-19109.stderr
+++ b/src/test/ui/mismatched_types/issue-19109.stderr
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-19109.rs:14:5
    |
 13 | fn function(t: &mut Trait) {
-   |                            -
-   |                            |
-   |                            help: possibly return type missing here? `-> *mut Trait `
-   |                            expected `()` because of this default return type
+   |                            - help: possibly return type missing here? `-> *mut Trait `
 14 |     t as *mut Trait
    |     ^^^^^^^^^^^^^^^ expected (), found *-ptr
    |
diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr
index 2a50428dbb9..53e9cb21778 100644
--- a/src/test/ui/resolve/token-error-correct-3.stderr
+++ b/src/test/ui/resolve/token-error-correct-3.stderr
@@ -34,9 +34,6 @@ error[E0425]: cannot find function `is_directory` in this scope
 error[E0308]: mismatched types
   --> $DIR/token-error-correct-3.rs:25:13
    |
-20 |                                                                -> io::Result<bool> {
-   |                                                                   ---------------- expected `()` because of this return type
-...
 25 |             fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here? `;`
    |             |