Commit Graph

14 Commits

Author SHA1 Message Date
Aaron Hill
e3cd43eb00
Use smaller def span for functions
Currently, the def span of a funtion encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.
* The 'unconditional recursion' lint uses the full span to show
  additional context for the recursive call.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
2020-08-22 18:41:49 -04:00
Esteban Küber
d0d30b0a3e fix rebase 2020-05-27 16:28:20 -07:00
Esteban Küber
3fea832fd7 Fix spacing of expected/found notes without a label 2020-05-27 16:27:15 -07:00
Esteban Küber
fca5c64abd Point at arguments or output when fn obligations come from them, or ident when they don't 2020-02-02 11:52:33 -08:00
Vadim Petrochenkov
642669c74d Update tests 2020-01-09 21:23:12 +03:00
Aaron Hill
168e35d569
Include a span in more expected...found notes
In most places, we use a span when emitting `expected...found` errors.
However, there were a couple of places where we didn't use any span,
resulting in hard-to-interpret error messages.

This commit attaches the relevant span to these notes, and additionally
switches over to using `note_expected_found` instead of manually
formatting the message
2019-12-03 23:13:10 -05:00
Yuki Okushi
2ae5e3421d Print lifetimes with backticks 2019-10-11 16:08:53 +09:00
Guillaume Gomez
96efaad342 update ui tests 2019-10-07 17:12:54 +02:00
memoryruins
eb4580a570 Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
Andy Russell
b6f148c8bd
hide --explain hint if error has no extended info 2019-04-18 13:29:28 -04:00
Eduard-Mihai Burtescu
4deaa69b42 rustc: print elided regions as '_ instead of nothing, and use a separate check when optional. 2019-03-15 13:25:10 +02:00
Vadim Petrochenkov
fa72a81bea Update tests 2019-03-11 23:10:26 +03:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
David Wood
3fc7ab2373
Merged migrated compile-fail tests and ui tests. Fixes #46841. 2018-08-14 11:12:09 +02:00