rust/src/test/ui/specialization
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 Deny specializing items not in the parent impl 2019-10-05 15:33:24 +02:00
defaultimpl bless all 2020-06-16 11:56:54 +02:00
min_specialization PredicateKint -> PredicateKind, the beginning of the end 2020-07-27 21:06:36 +02:00
soundness Remove some unsound specializations 2020-02-01 09:11:41 +00:00
assoc-ty-graph-cycle.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
assoc-ty-graph-cycle.stderr bless all 2020-06-16 11:56:54 +02:00
cross-crate-defaults.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
cross-crate-defaults.stderr bless all 2020-06-16 11:56:54 +02:00
deafult-associated-type-bound-1.rs Check associated type satisfy their bounds 2020-06-20 14:34:50 +01:00
deafult-associated-type-bound-1.stderr Move bounds on associated types to the type 2020-06-20 14:34:51 +01:00
deafult-associated-type-bound-2.rs Check associated type satisfy their bounds 2020-06-20 14:34:50 +01:00
deafult-associated-type-bound-2.stderr Move bounds on associated types to the type 2020-06-20 14:34:51 +01:00
deafult-generic-associated-type-bound.rs Check associated type satisfy their bounds 2020-06-20 14:34:50 +01:00
deafult-generic-associated-type-bound.stderr Remove redundant explanatory note for type parameters 2020-07-14 12:19:44 -07:00
issue-36804.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-36804.stderr bless all 2020-06-16 11:56:54 +02:00
issue-39448.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-39448.stderr bless all 2020-06-16 11:56:54 +02:00
issue-39618.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-39618.stderr bless all 2020-06-16 11:56:54 +02:00
issue-44861.rs Add test for issue-44861 2020-06-23 17:52:01 +09:00
issue-44861.stderr Add test for issue-44861 2020-06-23 17:52:01 +09:00
issue-50452.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-50452.stderr bless all 2020-06-16 11:56:54 +02:00
issue-52050.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-52050.stderr bless all 2020-06-16 11:56:54 +02:00
issue-59435.rs Add test for issue-59435 2020-06-23 17:52:42 +09:00
issue-59435.stderr Add test for issue-59435 2020-06-23 17:52:42 +09:00
issue-63716-parse-async.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-63716-parse-async.stderr bless all 2020-06-16 11:56:54 +02:00
issue-70442.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
issue-70442.stderr bless all 2020-06-16 11:56:54 +02:00
non-defaulted-item-fail.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
non-defaulted-item-fail.stderr bless all 2020-06-16 11:56:54 +02:00
README-rpass.md tests: Move run-pass tests with naming conflicts to ui 2019-07-27 18:56:17 +03:00
README.md Merged migrated compile-fail tests and ui tests. Fixes #46841. 2018-08-14 11:12:09 +02:00
specialization-allowed-cross-crate.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-allowed-cross-crate.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-assoc-fns.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-assoc-fns.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-basics.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-basics.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-cross-crate-no-gate.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
specialization-cross-crate.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-cross-crate.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-default-methods.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-default-methods.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-default-projection.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-default-projection.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-default-types.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-default-types.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-feature-gate-default.rs Remove licenses 2018-12-25 21:08:33 -07:00
specialization-feature-gate-default.stderr --bless --compare-mode=nll 2020-02-09 20:43:49 +01:00
specialization-feature-gate-overlap.rs Remove licenses 2018-12-25 21:08:33 -07:00
specialization-feature-gate-overlap.stderr Update tests 2019-03-11 23:10:26 +03:00
specialization-no-default.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-no-default.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-on-projection.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-on-projection.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-out-of-order.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-out-of-order.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-overlap-hygiene.rs hygiene: Fix identifier comparison in impl overlap check 2019-03-21 22:20:10 +03:00
specialization-overlap-hygiene.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
specialization-overlap-negative.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-overlap-negative.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-overlap-projection.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-overlap-projection.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-overlap.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-overlap.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-polarity.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-polarity.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-projection-alias.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-projection-alias.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-projection.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-projection.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-super-traits.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-super-traits.stderr warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-translate-projections-with-lifetimes.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-translate-projections-with-lifetimes.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-translate-projections-with-params.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-translate-projections-with-params.stderr bless all 2020-06-16 11:56:54 +02:00
specialization-translate-projections.rs warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
specialization-translate-projections.stderr bless all 2020-06-16 11:56:54 +02:00

This directory contains the test for incorrect usage of specialization that should lead to compile failure. Those tests break down into a few categories: