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 warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
reservation-impls
trait-alias Tweak output of E0225 2020-08-14 12:08:49 -07:00
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 Point at type on E0275 instead of whole field 2020-07-14 10:50:24 -07:00
cycle-trait-type-trait.rs
default-method-supertrait-vtable.rs
dyn-trait.rs
fmt-pointer-trait.rs
impl_trait_as_trait_return_position.rs Add test for #59023 2020-04-03 18:31:04 +02:00
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 Fix debug assertion in typeck 2020-07-18 12:20:51 +09:00
issue-72410.stderr Fix debug assertion in typeck 2020-07-18 12:20:51 +09:00
kindck-owned-trait-contains-1.rs
multiple-trait-bounds.rs
object-one-type-two-traits.rs
overlap-not-permitted-for-builtin-trait.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
overlap-not-permitted-for-builtin-trait.stderr
overlap-permitted-for-marker-traits.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
parameterized-trait-with-bounds.rs
principal-less-trait-objects.rs
self-without-lifetime-constraint.rs Account for Self as a type param 2020-05-28 10:36:21 -07:00
self-without-lifetime-constraint.stderr Account for Self as a type param 2020-05-28 10:36:21 -07:00
supertrait-default-generics.rs
syntax-trait-polarity.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
trait-alias-ambiguous.rs
trait-alias-ambiguous.stderr Rename AssocKind::Method to AssocKind::Fn 2020-04-14 07:12:07 +08:00
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 Suggest borrowing in more unsized fn param cases 2020-07-14 10:50:24 -07:00
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 Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
trait-bounds-on-structs-and-enums-in-impls.rs
trait-bounds-on-structs-and-enums-in-impls.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
trait-bounds-on-structs-and-enums-locals.rs
trait-bounds-on-structs-and-enums-locals.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
trait-bounds-on-structs-and-enums-rpass.rs
trait-bounds-on-structs-and-enums-static.rs
trait-bounds-on-structs-and-enums-static.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
trait-bounds-on-structs-and-enums-xc1.rs
trait-bounds-on-structs-and-enums-xc1.stderr Use PredicateObligations instead of Predicates 2020-04-08 14:40:45 -07:00
trait-bounds-on-structs-and-enums-xc.rs
trait-bounds-on-structs-and-enums-xc.stderr Use PredicateObligations instead of Predicates 2020-04-08 14:40:45 -07:00
trait-bounds-on-structs-and-enums.rs
trait-bounds-on-structs-and-enums.stderr Suggest boxing or borrowing unsized fields 2020-07-14 10:50:24 -07:00
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 Tweak output for mismatched impl item 2020-05-27 16:28:20 -07:00
trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs
trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr Fix spacing of expected/found notes without a label 2020-05-27 16:27:15 -07:00
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 Only display other method receiver candidates if they actually apply 2020-06-15 15:15:35 -04:00
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 Tweak output for mismatched impl item 2020-05-27 16:28:20 -07:00
trait-param-without-lifetime-constraint.stderr review comments: change wording and visual output 2020-05-27 20:58:05 -07:00
trait-privacy.rs
trait-region-pointer-simple.rs
trait-resolution-in-overloaded-op.rs
trait-resolution-in-overloaded-op.stderr Suggest type param trait bound for binop only when appropriate 2020-06-24 16:17:04 -07:00
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 "cannot resolve" → "cannot satisfy" 2020-04-05 10:14:04 -07:00
trait-static-method-overwriting.rs
trait-suggest-deferences-issue-39029.fixed Try to suggest dereferences when trait selection failed. 2020-06-20 18:53:59 +08:00
trait-suggest-deferences-issue-39029.rs Try to suggest dereferences when trait selection failed. 2020-06-20 18:53:59 +08:00
trait-suggest-deferences-issue-39029.stderr mv std libs to library/ 2020-07-27 19:51:13 -05:00
trait-suggest-deferences-issue-62530.fixed Try to suggest dereferences when trait selection failed. 2020-06-20 18:53:59 +08:00
trait-suggest-deferences-issue-62530.rs Try to suggest dereferences when trait selection failed. 2020-06-20 18:53:59 +08:00
trait-suggest-deferences-issue-62530.stderr Try to suggest dereferences when trait selection failed. 2020-06-20 18:53:59 +08:00
trait-suggest-deferences-multiple-0.fixed Prevent incorrect help message for dereference suggestion 2020-06-20 20:00:36 +08:00
trait-suggest-deferences-multiple-0.rs Prevent incorrect help message for dereference suggestion 2020-06-20 20:00:36 +08:00
trait-suggest-deferences-multiple-0.stderr Prevent incorrect help message for dereference suggestion 2020-06-20 20:00:36 +08:00
trait-suggest-deferences-multiple-1.rs Prevent incorrect help message for dereference suggestion 2020-06-20 20:00:36 +08:00
trait-suggest-deferences-multiple-1.stderr Prevent incorrect help message for dereference suggestion 2020-06-20 20:00:36 +08:00
trait-suggest-where-clause.rs tests: remove ignore directives from tests that mention core/alloc/std spans. 2020-04-02 11:48:34 +03:00
trait-suggest-where-clause.stderr mv std libs to library/ 2020-07-27 19:51:13 -05:00
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 Remove AssocTypeBound and propagate bound Spans 2020-04-18 16:37:08 -07:00
traits-assoc-type-in-supertrait-bad.stderr Remove AssocTypeBound and propagate bound Spans 2020-04-18 16:37:08 -07:00
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 Unify region variables when projecting associated types 2020-06-17 19:46:15 +01:00
traits-inductive-overflow-lifetime.stderr Unify region variables when projecting associated types 2020-06-17 19:46:15 +01:00
traits-inductive-overflow-simultaneous.rs
traits-inductive-overflow-simultaneous.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
traits-inductive-overflow-supertrait-oibit.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
traits-inductive-overflow-supertrait-oibit.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
traits-inductive-overflow-supertrait.rs
traits-inductive-overflow-supertrait.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
traits-inductive-overflow-two-traits.rs
traits-inductive-overflow-two-traits.stderr Small tweaks to required bound span 2020-04-08 14:40:51 -07:00
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 Adding new test #71136 2020-05-03 11:11:23 +02:00
traits-issue-71136.stderr Adding new test #71136 2020-05-03 11:11:23 +02:00
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 Tweak suggest_constraining_type_param 2020-03-29 13:13:17 -07:00
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 Tweak output of E0225 2020-08-14 12:08:49 -07:00
wf-trait-object-only-maybe-bound.rs
wf-trait-object-only-maybe-bound.stderr
wf-trait-object-reverse-order.rs