From d96f9d47ac35b637906edb1d5d112549164e096c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 25 Jul 2017 22:01:31 -0700 Subject: [PATCH 1/3] Point at return type always when type mismatch against it Before this, the diagnostic errors would only point at the return type when changing it would be a possible solution to a type error. Add a label to the return type without a suggestion to change in order to make the source of the expected type obvious. Follow up to #42850, fixes #25133, fixes #41897. --- src/librustc/hir/map/mod.rs | 2 +- src/librustc/ty/mod.rs | 1 + src/librustc_typeck/check/mod.rs | 53 ++++++++++++------- .../struct-path-self-type-mismatch.rs | 12 ++--- .../block-must-not-have-result-res.stderr | 2 + src/test/ui/block-result/issue-13624.stderr | 2 + src/test/ui/block-result/issue-22645.stderr | 3 ++ src/test/ui/block-result/issue-5500.stderr | 2 + src/test/ui/impl-trait/equality.stderr | 3 ++ src/test/ui/mismatched_types/abridged.stderr | 14 +++++ 10 files changed, 68 insertions(+), 26 deletions(-) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 3fdd9c34f46d9..5cec697c6bbd9 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -664,7 +664,7 @@ impl<'hir> Map<'hir> { match *node { NodeExpr(ref expr) => { match expr.node { - ExprWhile(..) | ExprLoop(..) => true, + ExprWhile(..) | ExprLoop(..) | ExprIf(..) => true, _ => false, } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2a11b19f85561..0f152d999df59 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -488,6 +488,7 @@ impl<'tcx> TyS<'tcx> { TypeVariants::TyFnPtr(..) | TypeVariants::TyDynamic(..) | TypeVariants::TyClosure(..) | + TypeVariants::TyInfer(..) | TypeVariants::TyProjection(..) => false, _ => true, } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 3c570d85147fa..73aa5ac5a0f0a 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4187,8 +4187,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty } - /// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether it is - /// `fn main` if it is a method, `None` otherwise. + /// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a + /// suggetion can be made, `None` otherwise. pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> { // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or // `while` before reaching it, as block tail returns are not available in them. @@ -4199,14 +4199,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { name, node: hir::ItemFn(ref decl, ..), .. }) = parent { decl.clone().and_then(|decl| { - // This is less than ideal, it will not present the return type span on any - // method called `main`, regardless of whether it is actually the entry point. - Some((decl, name == Symbol::intern("main"))) + // This is less than ideal, it will not suggest a return type span on any + // method called `main`, regardless of whether it is actually the entry point, + // but it will still present it as the reason for the expected type. + Some((decl, name != Symbol::intern("main"))) }) } else if let Node::NodeTraitItem(&hir::TraitItem { node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, ..), .. + }) = parent { + decl.clone().and_then(|decl| { + Some((decl, true)) + }) + } else if let Node::NodeImplItem(&hir::ImplItem { + node: hir::ImplItemKind::Method(hir::MethodSig { + ref decl, .. + }, ..), .. }) = parent { decl.clone().and_then(|decl| { Some((decl, false)) @@ -4233,11 +4242,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { blk_id: ast::NodeId) { self.suggest_missing_semicolon(err, expression, expected, cause_span); - if let Some((fn_decl, is_main)) = self.get_fn_decl(blk_id) { - // `fn main()` must return `()`, do not suggest changing return type - if !is_main { - self.suggest_missing_return_type(err, &fn_decl, found); - } + if let Some((fn_decl, can_suggest)) = self.get_fn_decl(blk_id) { + self.suggest_missing_return_type(err, &fn_decl, expected, found, can_suggest); } } @@ -4293,20 +4299,31 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn suggest_missing_return_type(&self, err: &mut DiagnosticBuilder<'tcx>, fn_decl: &hir::FnDecl, - ty: Ty<'tcx>) { + expected: Ty<'tcx>, + found: Ty<'tcx>, + can_suggest: bool) { - // Only recommend changing the return type for methods that + // Only suggest changing the return type for methods that // haven't set a return type at all (and aren't `fn main()` or an impl). - if let &hir::FnDecl { - output: hir::FunctionRetTy::DefaultReturn(span), .. - } = fn_decl { - if ty.is_suggestable() { + match (&fn_decl.output, found.is_suggestable(), can_suggest) { + (&hir::FunctionRetTy::DefaultReturn(span), true, true) => { err.span_suggestion(span, "try adding a return type", - format!("-> {} ", ty)); - } else { + format!("-> {} ", found)); + } + (&hir::FunctionRetTy::DefaultReturn(span), false, true) => { err.span_label(span, "possibly return type missing here?"); } + (&hir::FunctionRetTy::DefaultReturn(span), _, _) => { + // `fn main()` must return `()`, do not suggest changing return type + err.span_label(span, "expected `()` because of default return type"); + } + (&hir::FunctionRetTy::Return(ref ty), _, _) => { + // Only point to return type if the expected type is the return type, as if they + // are not, the expectation must have been caused by something else. + err.span_label(ty.span, + format!("expected `{}` because of return type", expected)); + } } } diff --git a/src/test/compile-fail/struct-path-self-type-mismatch.rs b/src/test/compile-fail/struct-path-self-type-mismatch.rs index f694e7d277c7f..ad568b41fcbf3 100644 --- a/src/test/compile-fail/struct-path-self-type-mismatch.rs +++ b/src/test/compile-fail/struct-path-self-type-mismatch.rs @@ -20,17 +20,15 @@ impl Bar for Foo { } impl Foo { - fn new(u: U) -> Foo { + fn new(u: U) -> Foo { //~ NOTE expected `Foo` because of return type Self { //~^ ERROR mismatched types - //~| expected type parameter, found a different type parameter - //~| expected type `Foo` - //~| found type `Foo` + //~| NOTE expected type parameter, found a different type parameter + //~| NOTE expected type `Foo` inner: u //~^ ERROR mismatched types - //~| expected type parameter, found a different type parameter - //~| expected type `T` - //~| found type `U` + //~| NOTE expected type parameter, found a different type parameter + //~| NOTE expected type `T` } } } diff --git a/src/test/ui/block-result/block-must-not-have-result-res.stderr b/src/test/ui/block-result/block-must-not-have-result-res.stderr index f60a0c2e5f6e0..20c7dc416f3bb 100644 --- a/src/test/ui/block-result/block-must-not-have-result-res.stderr +++ b/src/test/ui/block-result/block-must-not-have-result-res.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/block-must-not-have-result-res.rs:15:9 | +14 | fn drop(&mut self) { + | - expected `()` because of default return type 15 | true //~ ERROR mismatched types | ^^^^ expected (), found bool | diff --git a/src/test/ui/block-result/issue-13624.stderr b/src/test/ui/block-result/issue-13624.stderr index 41113eb7a573e..cd8c28cd2cfa8 100644 --- a/src/test/ui/block-result/issue-13624.stderr +++ b/src/test/ui/block-result/issue-13624.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/issue-13624.rs:17:5 | +16 | pub fn get_enum_struct_variant() -> () { + | -- expected `()` because of 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-22645.stderr b/src/test/ui/block-result/issue-22645.stderr index a9bcc8bea94cc..c6113ae0c9f60 100644 --- a/src/test/ui/block-result/issue-22645.stderr +++ b/src/test/ui/block-result/issue-22645.stderr @@ -11,6 +11,9 @@ 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 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-5500.stderr b/src/test/ui/block-result/issue-5500.stderr index bd670a14f247e..29dbd5a8cf599 100644 --- a/src/test/ui/block-result/issue-5500.stderr +++ b/src/test/ui/block-result/issue-5500.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/issue-5500.rs:12:5 | +11 | fn main() { + | - expected `()` because of default return type 12 | &panic!() | ^^^^^^^^^ expected (), found reference | diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 3fc08a0900fb9..791ce4860d0cd 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -1,6 +1,9 @@ error[E0308]: mismatched types --> $DIR/equality.rs:25:5 | +21 | fn two(x: bool) -> impl Foo { + | -------- expected `_` because of 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 d40bc3b333903..8c63d7d6f91c5 100644 --- a/src/test/ui/mismatched_types/abridged.stderr +++ b/src/test/ui/mismatched_types/abridged.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/abridged.rs:26:5 | +25 | fn a() -> Foo { + | --- expected `Foo` because of return type 26 | Some(Foo { bar: 1 }) | ^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::option::Option` | @@ -10,6 +12,8 @@ error[E0308]: mismatched types error[E0308]: mismatched types --> $DIR/abridged.rs:30:5 | +29 | fn a2() -> Foo { + | --- expected `Foo` because of return type 30 | Ok(Foo { bar: 1}) | ^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::result::Result` | @@ -19,6 +23,8 @@ error[E0308]: mismatched types error[E0308]: mismatched types --> $DIR/abridged.rs:34:5 | +33 | fn b() -> Option { + | ----------- expected `std::option::Option` because of return type 34 | Foo { bar: 1 } | ^^^^^^^^^^^^^^ expected enum `std::option::Option`, found struct `Foo` | @@ -28,6 +34,8 @@ error[E0308]: mismatched types error[E0308]: mismatched types --> $DIR/abridged.rs:38:5 | +37 | fn c() -> Result { + | ---------------- expected `std::result::Result` because of return type 38 | Foo { bar: 1 } | ^^^^^^^^^^^^^^ expected enum `std::result::Result`, found struct `Foo` | @@ -37,6 +45,9 @@ error[E0308]: mismatched types error[E0308]: mismatched types --> $DIR/abridged.rs:49:5 | +41 | fn d() -> X, String> { + | ---------------------------- expected `X, std::string::String>` because of return type +... 49 | x | ^ expected struct `std::string::String`, found integral variable | @@ -46,6 +57,9 @@ error[E0308]: mismatched types error[E0308]: mismatched types --> $DIR/abridged.rs:60:5 | +52 | fn e() -> X, String> { + | ---------------------------- expected `X, std::string::String>` because of return type +... 60 | x | ^ expected struct `std::string::String`, found integral variable | From 3fcdb8ba723a46a1c036c99c6a503f39a0667156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 8 Aug 2017 18:20:36 -0700 Subject: [PATCH 2/3] Only refer to return type when it matches --- src/librustc/hir/map/mod.rs | 2 +- src/librustc_typeck/check/mod.rs | 27 +++++++++++++++---- .../block-must-not-have-result-res.stderr | 2 +- src/test/ui/block-result/issue-13624.stderr | 2 +- src/test/ui/block-result/issue-22645.stderr | 2 +- src/test/ui/block-result/issue-5500.stderr | 2 +- src/test/ui/impl-trait/equality.stderr | 3 --- 7 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 5cec697c6bbd9..3fdd9c34f46d9 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -664,7 +664,7 @@ impl<'hir> Map<'hir> { match *node { NodeExpr(ref expr) => { match expr.node { - ExprWhile(..) | ExprLoop(..) | ExprIf(..) => true, + ExprWhile(..) | ExprLoop(..) => true, _ => false, } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 73aa5ac5a0f0a..7c8eb77380f02 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -95,7 +95,7 @@ use rustc::middle::region::CodeExtent; use rustc::ty::subst::{Kind, Subst, Substs}; use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode}; use rustc::ty::{ParamTy, LvaluePreference, NoPreference, PreferMutLvalue}; -use rustc::ty::{self, Ty, TyCtxt, Visibility}; +use rustc::ty::{self, Ty, TyCtxt, Visibility, TypeVariants}; use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; use rustc::ty::fold::{BottomUpFolder, TypeFoldable}; use rustc::ty::maps::Providers; @@ -4302,7 +4302,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected: Ty<'tcx>, found: Ty<'tcx>, can_suggest: bool) { - // Only suggest changing the return type for methods that // haven't set a return type at all (and aren't `fn main()` or an impl). match (&fn_decl.output, found.is_suggestable(), can_suggest) { @@ -4316,13 +4315,31 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } (&hir::FunctionRetTy::DefaultReturn(span), _, _) => { // `fn main()` must return `()`, do not suggest changing return type - err.span_label(span, "expected `()` because of default return type"); + err.span_label(span, "expected () because of default return type"); } (&hir::FunctionRetTy::Return(ref ty), _, _) => { // Only point to return type if the expected type is the return type, as if they // are not, the expectation must have been caused by something else. - err.span_label(ty.span, - format!("expected `{}` because of return type", expected)); + debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.node); + let sp = ty.span; + let ty = AstConv::ast_ty_to_ty(self, ty); + debug!("suggest_missing_return_type: return type sty {:?}", ty.sty); + debug!("suggest_missing_return_type: expected type sty {:?}", ty.sty); + if ty.sty == expected.sty { + let quote = if let TypeVariants::TyTuple(ref slice, _) = expected.sty { + if slice.len() == 0 { // don't use backtics for () + "" + } else { + "`" + } + } else { + "`" + }; + err.span_label(sp, format!("expected {}{}{} because of return type", + quote, + expected, + quote)); + } } } } diff --git a/src/test/ui/block-result/block-must-not-have-result-res.stderr b/src/test/ui/block-result/block-must-not-have-result-res.stderr index 20c7dc416f3bb..6432375fe709b 100644 --- a/src/test/ui/block-result/block-must-not-have-result-res.stderr +++ b/src/test/ui/block-result/block-must-not-have-result-res.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/block-must-not-have-result-res.rs:15:9 | 14 | fn drop(&mut self) { - | - expected `()` because of default return type + | - expected () because of default return type 15 | true //~ ERROR mismatched types | ^^^^ expected (), found bool | diff --git a/src/test/ui/block-result/issue-13624.stderr b/src/test/ui/block-result/issue-13624.stderr index cd8c28cd2cfa8..8fe4a51257410 100644 --- a/src/test/ui/block-result/issue-13624.stderr +++ b/src/test/ui/block-result/issue-13624.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-13624.rs:17:5 | 16 | pub fn get_enum_struct_variant() -> () { - | -- expected `()` because of return type + | -- expected () because of 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-22645.stderr b/src/test/ui/block-result/issue-22645.stderr index c6113ae0c9f60..ad39e38cab63f 100644 --- a/src/test/ui/block-result/issue-22645.stderr +++ b/src/test/ui/block-result/issue-22645.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types --> $DIR/issue-22645.rs:25:3 | 23 | fn main() { - | - expected `()` because of default return type + | - expected () because of 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-5500.stderr b/src/test/ui/block-result/issue-5500.stderr index 29dbd5a8cf599..944391c1719cf 100644 --- a/src/test/ui/block-result/issue-5500.stderr +++ b/src/test/ui/block-result/issue-5500.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-5500.rs:12:5 | 11 | fn main() { - | - expected `()` because of default return type + | - expected () because of default return type 12 | &panic!() | ^^^^^^^^^ expected (), found reference | diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 791ce4860d0cd..3fc08a0900fb9 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 `_` because of return type -... 25 | 0_u32 | ^^^^^ expected i32, found u32 | From 9bd62a4691346a30f7aa26cf3b6d726695cf7eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 9 Aug 2017 09:57:28 -0700 Subject: [PATCH 3/3] Readd backticks around () --- src/librustc_typeck/check/mod.rs | 19 ++++--------------- .../block-must-not-have-result-res.stderr | 2 +- src/test/ui/block-result/issue-13624.stderr | 2 +- src/test/ui/block-result/issue-22645.stderr | 2 +- src/test/ui/block-result/issue-5500.stderr | 2 +- 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 7c8eb77380f02..8e363eee24d45 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -95,7 +95,7 @@ use rustc::middle::region::CodeExtent; use rustc::ty::subst::{Kind, Subst, Substs}; use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode}; use rustc::ty::{ParamTy, LvaluePreference, NoPreference, PreferMutLvalue}; -use rustc::ty::{self, Ty, TyCtxt, Visibility, TypeVariants}; +use rustc::ty::{self, Ty, TyCtxt, Visibility}; use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; use rustc::ty::fold::{BottomUpFolder, TypeFoldable}; use rustc::ty::maps::Providers; @@ -4315,7 +4315,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } (&hir::FunctionRetTy::DefaultReturn(span), _, _) => { // `fn main()` must return `()`, do not suggest changing return type - err.span_label(span, "expected () because of default return type"); + err.span_label(span, "expected `()` because of default return type"); } (&hir::FunctionRetTy::Return(ref ty), _, _) => { // Only point to return type if the expected type is the return type, as if they @@ -4326,19 +4326,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { debug!("suggest_missing_return_type: return type sty {:?}", ty.sty); debug!("suggest_missing_return_type: expected type sty {:?}", ty.sty); if ty.sty == expected.sty { - let quote = if let TypeVariants::TyTuple(ref slice, _) = expected.sty { - if slice.len() == 0 { // don't use backtics for () - "" - } else { - "`" - } - } else { - "`" - }; - err.span_label(sp, format!("expected {}{}{} because of return type", - quote, - expected, - quote)); + err.span_label(sp, format!("expected `{}` because of return type", + expected)); } } } diff --git a/src/test/ui/block-result/block-must-not-have-result-res.stderr b/src/test/ui/block-result/block-must-not-have-result-res.stderr index 6432375fe709b..20c7dc416f3bb 100644 --- a/src/test/ui/block-result/block-must-not-have-result-res.stderr +++ b/src/test/ui/block-result/block-must-not-have-result-res.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/block-must-not-have-result-res.rs:15:9 | 14 | fn drop(&mut self) { - | - expected () because of default return type + | - expected `()` because of default return type 15 | true //~ ERROR mismatched types | ^^^^ expected (), found bool | diff --git a/src/test/ui/block-result/issue-13624.stderr b/src/test/ui/block-result/issue-13624.stderr index 8fe4a51257410..cd8c28cd2cfa8 100644 --- a/src/test/ui/block-result/issue-13624.stderr +++ b/src/test/ui/block-result/issue-13624.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-13624.rs:17:5 | 16 | pub fn get_enum_struct_variant() -> () { - | -- expected () because of return type + | -- expected `()` because of 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-22645.stderr b/src/test/ui/block-result/issue-22645.stderr index ad39e38cab63f..c6113ae0c9f60 100644 --- a/src/test/ui/block-result/issue-22645.stderr +++ b/src/test/ui/block-result/issue-22645.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types --> $DIR/issue-22645.rs:25:3 | 23 | fn main() { - | - expected () because of default return type + | - expected `()` because of 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-5500.stderr b/src/test/ui/block-result/issue-5500.stderr index 944391c1719cf..29dbd5a8cf599 100644 --- a/src/test/ui/block-result/issue-5500.stderr +++ b/src/test/ui/block-result/issue-5500.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-5500.rs:12:5 | 11 | fn main() { - | - expected () because of default return type + | - expected `()` because of default return type 12 | &panic!() | ^^^^^^^^^ expected (), found reference |