diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-11-01 16:00:24 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-12-20 11:37:15 +0100 |
| commit | b5686422e1a327a77bf9a43a91cb9b3a8d2a2637 (patch) | |
| tree | 41c8d05d3820b5afa189a877a3fd3ecb5bbf39d9 | |
| parent | eaa2ddb04f6f56e48af789dc757982cf99f8fe35 (diff) | |
improve suggestions output and add ui test
| -rw-r--r-- | src/librustc_typeck/check/demand.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/span/coerce-suggestions.rs (renamed from src/test/compile-fail/coerce_suggestions.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/span/coerce-suggestions.stderr | 52 |
3 files changed, 54 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 6246e95faeb..7eadc9efe6e 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -154,13 +154,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if no_argument_methods.len() > 0 { no_argument_methods.iter() .take(5) - .map(|method| format!("{}", method.name())) + .map(|method| format!(".{}()", method.name())) .collect::<Vec<String>>() .join("\n - ") } else { methods.iter() .take(5) - .map(|method| format!("{}", method.name())) + .map(|method| format!(".{}()", method.name())) .collect::<Vec<String>>() .join("\n - ") } diff --git a/src/test/compile-fail/coerce_suggestions.rs b/src/test/ui/span/coerce-suggestions.rs index 3177e858ff4..3177e858ff4 100644 --- a/src/test/compile-fail/coerce_suggestions.rs +++ b/src/test/ui/span/coerce-suggestions.rs diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr new file mode 100644 index 00000000000..36732283014 --- /dev/null +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -0,0 +1,52 @@ +error[E0308]: mismatched types + --> $DIR/coerce-suggestions.rs:17:20 + | +17 | let x: usize = String::new(); + | ^^^^^^^^^^^^^ expected usize, found struct `std::string::String` + | + = note: expected type `usize` + = note: found type `std::string::String` + = help: here are some functions which might fulfill your needs: + - .capacity() + - .len() + +error[E0308]: mismatched types + --> $DIR/coerce-suggestions.rs:23:19 + | +23 | let x: &str = String::new(); + | ^^^^^^^^^^^^^ expected &str, found struct `std::string::String` + | + = note: expected type `&str` + = note: found type `std::string::String` + = help: try with `&String::new()` + +error[E0308]: mismatched types + --> $DIR/coerce-suggestions.rs:30:10 + | +30 | test(&y); + | ^^ types differ in mutability + | + = note: expected type `&mut std::string::String` + = note: found type `&std::string::String` + = help: try with `&mut y` + +error[E0308]: mismatched types + --> $DIR/coerce-suggestions.rs:36:11 + | +36 | test2(&y); + | ^^ types differ in mutability + | + = note: expected type `&mut i32` + = note: found type `&std::string::String` + +error[E0308]: mismatched types + --> $DIR/coerce-suggestions.rs:42:9 + | +42 | f = box f; + | ^^^^^ cyclic type of infinite size + | + = note: expected type `_` + = note: found type `Box<_>` + +error: aborting due to 5 previous errors + |
