sugg.msg.split_whitespace().count() < 10 &&
// don't display multiline suggestions as labels
!sugg.substitutions[0].parts[0].snippet.contains('\n') {
- let substitution = &sugg.substitutions[0].parts[0].snippet;
+ let substitution = &sugg.substitutions[0].parts[0].snippet.trim();
let msg = if substitution.len() == 0 || !sugg.show_code_when_inline {
// This substitution is only removal or we explicitly don't want to show the
// code inline, don't show it
(&hir::FunctionRetTy::DefaultReturn(span), true, true) => {
err.span_suggestion(span,
"try adding a return type",
- format!("-> {} ", found));
+ format!("-> {} ",
+ self.resolve_type_vars_with_obligations(found)));
}
(&hir::FunctionRetTy::DefaultReturn(span), false, true) => {
err.span_label(span, "possibly return type missing here?");
--> $DIR/tab.rs:18:2
|
17 | fn foo() {
- | - help: try adding a return type: `-> &'static str `
+ | - help: try adding a return type: `-> &'static str`
18 | "bar boo" //~ ERROR mismatched types
| ^^^^^^^^^^^^^^^^^^^^ expected (), found reference
|
426 | #[no_mangle = "3500"] fn f() { }
| -^^^^^^^^^
| |
- | help: try making it public: `pub `
+ | help: try making it public: `pub`
|
= note: #[warn(private_no_mangle_fns)] on by default
14 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub`
| -^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
- | help: try making it public: `pub `
+ | help: try making it public: `pub`
|
= note: #[warn(private_no_mangle_statics)] on by default
24 | fn rio_grande() {} // should suggest `pub`
| -^^^^^^^^^^^^^^^^^
| |
- | help: try making it public: `pub `
+ | help: try making it public: `pub`
|
= note: #[warn(private_no_mangle_fns)] on by default
--> $DIR/issue-19109.rs:14:5
|
13 | fn function(t: &mut Trait) {
- | - help: try adding a return type: `-> *mut Trait `
+ | - help: try adding a return type: `-> *mut Trait`
14 | t as *mut Trait
| ^^^^^^^^^^^^^^^ expected (), found *-ptr
|
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct S<T> {
+ t: T,
+}
+
+fn foo<T>(x: T) -> S<T> {
+ S { t: x }
+}
+
+fn bar() {
+ foo(4 as usize)
+ //~^ ERROR mismatched types
+}
+
+fn main() {}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/return-type.rs:20:5
+ |
+20 | foo(4 as usize)
+ | ^^^^^^^^^^^^^^^ expected (), found struct `S`
+ |
+ = note: expected type `()`
+ found type `S<usize>`
+help: try adding a semicolon
+ |
+20 | foo(4 as usize);
+ | ^
+help: try adding a return type
+ |
+19 | fn bar() -> S<usize> {
+ | ^^^^^^^^^^^
+
+error: aborting due to previous error
+