rust/src/librustc_errors
bors 0418fa9d38 Auto merge of #42362 - estebank:type, r=arielb1
Show trait method signature when impl differs

When the trait's span is available, it is already being used, add a
`note` for the cases where the span isn't available:

<pre>
error[E0053]: <b>method `fmt` has an incompatible type for trait</b>
  --> $DIR/trait_type.rs:17:4
   |
17 |    fn fmt(&self, x: &str) -> () { }
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
   |
   = note: expected type `<b>fn(&MyType, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error></b>`
              found type `<b>fn(&MyType, &str)</b>`

error[E0050]: <b>method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2</b>
  --> $DIR/trait_type.rs:21:11
   |
21 |    fn fmt(&self) -> () { }
   |           ^^^^^ expected 2 parameters, found 1
   |
   = note: `fmt` from trait: `<b>fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error></b>`

error[E0186]: <b>method `fmt` has a `&self` declaration in the trait, but not in the impl</b>
  --> $DIR/trait_type.rs:25:4
   |
25 |    fn fmt() -> () { }
   |    ^^^^^^^^^^^^^^^^^^ expected `&self` in impl
   |
   = note: `fmt` from trait: `<b>fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error></b>`

error[E0046]: <b>not all trait items implemented, missing: `fmt`</b>
  --> $DIR/trait_type.rs:28:1
   |
28 | impl std::fmt::Display for MyType4 {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
   |
   = note: `fmt` from trait: `<b>fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error></b>`
</code></pre>

Fix #28011.
2017-06-04 20:16:09 +00:00
..
Cargo.toml store typeck lints in the `TypeckTables` 2017-02-02 20:38:16 -05:00
diagnostic.rs Show trait method signature when impl differs 2017-06-04 12:52:55 -07:00
diagnostic_builder.rs fix some clippy warnings in librustc_errors 2017-05-19 01:20:48 +02:00
emitter.rs Use callsite's span for macro calls on suggestion 2017-05-31 23:48:19 -07:00
lib.rs Use callsite's span for macro calls on suggestion 2017-05-31 23:48:19 -07:00
lock.rs run rustfmt on librustc_errors folder 2016-10-18 23:13:02 +05:30
registry.rs run rustfmt on librustc_errors folder 2016-10-18 23:13:02 +05:30
snippet.rs Reduce visual clutter of multiline start when possible 2017-04-20 17:31:20 -07:00
styled_buffer.rs run rustfmt on librustc_errors folder 2016-10-18 23:13:02 +05:30