rust/src/test/ui/codemap_tests
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
..
bad-format-args.rs Be accurate on format! parse error expectations 2019-09-01 15:10:30 -07:00
bad-format-args.stderr rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
coherence-overlapping-inherent-impl-trait.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
coherence-overlapping-inherent-impl-trait.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
empty_span.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
empty_span.stderr Update tests 2019-03-11 23:10:26 +03:00
huge_multispan_highlight.rs Remove licenses 2018-12-25 21:08:33 -07:00
huge_multispan_highlight.stderr update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
issue-11715.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-11715.stderr update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
issue-28308.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-28308.stderr rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
one_line.rs Remove licenses 2018-12-25 21:08:33 -07:00
one_line.stderr update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
overlapping_inherent_impls.rs Remove licenses 2018-12-25 21:08:33 -07:00
overlapping_inherent_impls.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
tab.rs Remove licenses 2018-12-25 21:08:33 -07:00
tab.stderr Surround types with backticks in type errors 2019-11-18 11:03:04 -08:00
tab_2.rs Remove licenses 2018-12-25 21:08:33 -07:00
tab_2.stderr Update UI tests 2020-06-21 16:40:36 +02:00
tab_3.rs update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
tab_3.stderr mv std libs to library/ 2020-07-27 19:51:13 -05:00
two_files.rs Remove licenses 2018-12-25 21:08:33 -07:00
two_files.stderr Tweak some suggestions in rustc_resolve 2020-04-26 11:43:43 -07:00
two_files_data.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
unicode.rs Remove licenses 2018-12-25 21:08:33 -07:00
unicode.stderr [AVR] Add required references for AVR to the parser test suites 2020-06-09 17:35:48 +12:00
unicode_2.rs Remove licenses 2018-12-25 21:08:33 -07:00
unicode_2.stderr Add a test and bless existing test case. 2019-12-26 13:13:01 +08:00
unicode_3.rs Moving more build-pass tests to check-pass 2020-04-23 20:21:38 -07:00
unicode_3.stderr rustc: Add a warning count upon completion 2020-04-11 16:15:24 +02:00