rust/src/test/ui/traits
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
..
auxiliary
negative-impls
reservation-impls
trait-alias
anon_trait_static_method_exe.rs
anon-trait-static-method.rs
assignability-trait.rs
astconv-cycle-between-trait-and-type.rs
augmented-assignments-trait.rs
conservative_impl_trait.rs
cycle-cache-err-60010.rs
cycle-cache-err-60010.stderr
cycle-trait-type-trait.rs
default-method-supertrait-vtable.rs
dyn-trait.rs
fmt-pointer-trait.rs
impl_trait_as_trait_return_position.rs
impl-implicit-trait.rs
impl-inherent-prefer-over-trait.rs
infer-from-object-trait-issue-26952.rs
inherent-trait-method-order.rs
issue-72410.rs
issue-72410.stderr
kindck-owned-trait-contains-1.rs
multiple-trait-bounds.rs
object-one-type-two-traits.rs
overlap-not-permitted-for-builtin-trait.rs
overlap-not-permitted-for-builtin-trait.stderr
overlap-permitted-for-marker-traits.rs
parameterized-trait-with-bounds.rs
principal-less-trait-objects.rs
self-without-lifetime-constraint.rs
self-without-lifetime-constraint.stderr
supertrait-default-generics.rs
syntax-trait-polarity.rs
trait-alias-ambiguous.rs
trait-alias-ambiguous.stderr
trait-alias-import-cross-crate.rs
trait-alias-import.rs
trait-as-struct-constructor.rs
trait-as-struct-constructor.stderr
trait-bounds-basic.rs
trait-bounds-impl-comparison-duplicates.rs
trait-bounds-in-arc.rs
trait-bounds-not-on-bare-trait.rs
trait-bounds-not-on-bare-trait.stderr
trait-bounds-not-on-struct.rs
trait-bounds-not-on-struct.stderr
trait-bounds-on-structs-and-enums-in-fns.rs
trait-bounds-on-structs-and-enums-in-fns.stderr
trait-bounds-on-structs-and-enums-in-impls.rs
trait-bounds-on-structs-and-enums-in-impls.stderr
trait-bounds-on-structs-and-enums-locals.rs
trait-bounds-on-structs-and-enums-locals.stderr
trait-bounds-on-structs-and-enums-rpass.rs
trait-bounds-on-structs-and-enums-static.rs
trait-bounds-on-structs-and-enums-static.stderr
trait-bounds-on-structs-and-enums-xc1.rs
trait-bounds-on-structs-and-enums-xc1.stderr
trait-bounds-on-structs-and-enums-xc.rs
trait-bounds-on-structs-and-enums-xc.stderr
trait-bounds-on-structs-and-enums.rs
trait-bounds-on-structs-and-enums.stderr
trait-bounds-recursion.rs
trait-bounds-same-crate-name.rs
trait-bounds-same-crate-name.stderr
trait-bounds-sugar.rs
trait-bounds-sugar.stderr
trait-bounds.rs
trait-cache-issue-18209.rs
trait-coercion-generic-bad.rs
trait-coercion-generic-bad.stderr
trait-coercion-generic-regions.rs
trait-coercion-generic-regions.stderr
trait-coercion-generic.rs
trait-coercion.rs
trait-composition-trivial.rs
trait-copy-guessing.rs
trait-default-method-bound-subst2.rs
trait-default-method-bound-subst3.rs
trait-default-method-bound-subst4.rs
trait-default-method-bound-subst.rs
trait-default-method-bound.rs
trait-default-method-xc-2.rs
trait-default-method-xc.rs
trait-duplicate-methods.rs
trait-duplicate-methods.stderr
trait-false-ambiguity-where-clause-builtin-bound.rs
trait-generic.rs
trait-impl-1.rs
trait-impl-1.stderr
trait-impl-2.rs
trait-impl-can-not-have-untraitful-items.rs
trait-impl-can-not-have-untraitful-items.stderr
trait-impl-different-num-params.rs
trait-impl-different-num-params.stderr
trait-impl-for-module.rs
trait-impl-for-module.stderr
trait-impl-method-mismatch.rs
trait-impl-method-mismatch.stderr
trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs
trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr
trait-impl.rs
trait-inheritance2.rs
trait-inheritance-auto-xc-2.rs
trait-inheritance-auto-xc.rs
trait-inheritance-auto.rs
trait-inheritance-call-bound-inherited2.rs
trait-inheritance-call-bound-inherited.rs
trait-inheritance-cast-without-call-to-supertrait.rs
trait-inheritance-cast.rs
trait-inheritance-cross-trait-call-xc.rs
trait-inheritance-cross-trait-call.rs
trait-inheritance-diamond.rs
trait-inheritance-multiple-inheritors.rs
trait-inheritance-multiple-params.rs
trait-inheritance-num0.rs
trait-inheritance-num1.rs
trait-inheritance-num2.rs
trait-inheritance-num3.rs
trait-inheritance-num5.rs
trait-inheritance-num.rs
trait-inheritance-overloading-simple.rs
trait-inheritance-overloading-xc-exe.rs
trait-inheritance-overloading.rs
trait-inheritance-self-in-supertype.rs
trait-inheritance-self.rs
trait-inheritance-simple.rs
trait-inheritance-static2.rs
trait-inheritance-static.rs
trait-inheritance-subst2.rs
trait-inheritance-subst.rs
trait-inheritance-visibility.rs
trait-item-inside-macro.rs
trait-item-privacy.rs
trait-item-privacy.stderr
trait-matching-lifetimes.rs
trait-matching-lifetimes.stderr
trait-method-private.rs
trait-method-private.stderr
trait-object-auto-dedup-in-impl.rs
trait-object-auto-dedup-in-impl.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
trait-object-auto-dedup.rs
trait-object-exclusion.rs
trait-object-generics.rs
trait-object-lifetime-first.rs
trait-object-macro-matcher.rs
trait-object-macro-matcher.stderr
trait-object-safety.rs
trait-object-safety.stderr
trait-object-vs-lifetime-2.rs
trait-object-vs-lifetime-2.stderr
trait-object-vs-lifetime.rs
trait-object-vs-lifetime.stderr
trait-object-with-lifetime-bound.rs
trait-object-with-self-in-projection-output-bad.rs
trait-object-with-self-in-projection-output-bad.stderr
trait-object-with-self-in-projection-output-good.rs
trait-object-with-self-in-projection-output-repeated-supertrait.rs
trait-or-new-type-instead.rs
trait-or-new-type-instead.stderr
trait-param-without-lifetime-constraint.rs
trait-param-without-lifetime-constraint.stderr
trait-privacy.rs
trait-region-pointer-simple.rs
trait-resolution-in-overloaded-op.rs
trait-resolution-in-overloaded-op.stderr
trait-safety-fn-body.rs
trait-safety-fn-body.stderr
trait-safety-inherent-impl.rs
trait-safety-inherent-impl.stderr
trait-safety-ok-cc.rs
trait-safety-ok.rs
trait-safety-trait-impl-cc.rs
trait-safety-trait-impl-cc.stderr
trait-safety-trait-impl.rs
trait-safety-trait-impl.stderr
trait-static-method-generic-inference.rs
trait-static-method-generic-inference.stderr
trait-static-method-overwriting.rs
trait-suggest-deferences-issue-39029.fixed
trait-suggest-deferences-issue-39029.rs
trait-suggest-deferences-issue-39029.stderr
trait-suggest-deferences-issue-62530.fixed
trait-suggest-deferences-issue-62530.rs
trait-suggest-deferences-issue-62530.stderr
trait-suggest-deferences-multiple-0.fixed
trait-suggest-deferences-multiple-0.rs
trait-suggest-deferences-multiple-0.stderr
trait-suggest-deferences-multiple-1.rs
trait-suggest-deferences-multiple-1.stderr
trait-suggest-where-clause.rs
trait-suggest-where-clause.stderr
trait-test-2.rs
trait-test-2.stderr
trait-test.rs
trait-test.stderr
trait-to-str.rs
trait-where-clause-vs-impl.rs
trait-with-bounds-default.rs
trait-with-dst.rs
traits-assoc-type-in-supertrait-bad.rs
traits-assoc-type-in-supertrait-bad.stderr
traits-assoc-type-in-supertrait.rs
traits-conditional-dispatch.rs
traits-conditional-model-fn.rs
traits-default-method-macro.rs
traits-default-method-mut.rs
traits-default-method-self.rs
traits-default-method-trivial.rs
traits-elaborate-type-region.rs
traits-impl-object-overlap-issue-23853.rs
traits-inductive-overflow-lifetime.rs
traits-inductive-overflow-lifetime.stderr
traits-inductive-overflow-simultaneous.rs
traits-inductive-overflow-simultaneous.stderr
traits-inductive-overflow-supertrait-oibit.rs
traits-inductive-overflow-supertrait-oibit.stderr
traits-inductive-overflow-supertrait.rs
traits-inductive-overflow-supertrait.stderr
traits-inductive-overflow-two-traits.rs
traits-inductive-overflow-two-traits.stderr
traits-issue-22019.rs
traits-issue-22110.rs
traits-issue-22655.rs
traits-issue-23003-overflow.rs
traits-issue-23003.rs
traits-issue-26339.rs
traits-issue-71136.rs
traits-issue-71136.stderr
traits-multidispatch-bad.rs
traits-multidispatch-bad.stderr
traits-multidispatch-convert-ambig-dest.rs
traits-multidispatch-convert-ambig-dest.stderr
traits-multidispatch-infer-convert-target.rs
traits-repeated-supertrait-ambig.rs
traits-repeated-supertrait-ambig.stderr
traits-repeated-supertrait.rs
traits-static-outlives-a-where-clause.rs
ufcs-trait-object.rs
use-trait-before-def.rs
wf-trait-object-maybe-bound.rs
wf-trait-object-maybe-bound.stderr
wf-trait-object-no-duplicates.rs
wf-trait-object-no-duplicates.stderr
wf-trait-object-only-maybe-bound.rs
wf-trait-object-only-maybe-bound.stderr
wf-trait-object-reverse-order.rs