rust/src/test/ui/privacy
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 tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
pub-priv-dep Use smaller def span for functions 2020-08-22 18:41:49 -04:00
restricted Use smaller def span for functions 2020-08-22 18:41:49 -04:00
associated-item-privacy-inherent.rs rustc: pass Option<&Substs> and Namespace around in ty::item_path. 2019-03-15 13:25:10 +02:00
associated-item-privacy-inherent.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
associated-item-privacy-trait.rs rustc_typeck: remove rustc_hir_pretty usage 2020-03-24 08:38:32 +01:00
associated-item-privacy-trait.stderr rustc_typeck: remove rustc_hir_pretty usage 2020-03-24 08:38:32 +01:00
associated-item-privacy-type-binding.rs use dyn Trait more in tests 2020-02-10 17:42:09 +01:00
associated-item-privacy-type-binding.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
decl-macro.rs
decl-macro.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
issue-57264-1.rs Apply review suggestions 2019-11-06 00:00:00 +00:00
issue-57264-2.rs Apply review suggestions 2019-11-06 00:00:00 +00:00
issue-75062-fieldless-tuple-struct.rs Handle fieldless tuple structs in diagnostic code 2020-08-05 07:59:26 -04:00
issue-75062-fieldless-tuple-struct.stderr Handle fieldless tuple structs in diagnostic code 2020-08-05 07:59:26 -04:00
legacy-ctor-visibility.rs legacy_ctor_visibility -> error 2019-11-06 11:08:23 +01:00
legacy-ctor-visibility.stderr Do not suggest similarly named enclosing item 2020-08-10 12:04:10 -07:00
priv-impl-prim-ty.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
privacy-in-paths.rs
privacy-in-paths.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
privacy-ns.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
privacy-ns1.rs test: Update tests with fallout of changes 2019-11-18 17:23:22 -05:00
privacy-ns1.stderr Prefer accessible paths in 'use' suggestions 2020-06-21 18:49:39 +03:00
privacy-ns2.rs test: Update tests with fallout of changes 2019-11-18 17:23:22 -05:00
privacy-ns2.stderr Prefer accessible paths in 'use' suggestions 2020-06-21 18:49:39 +03:00
privacy-reexport.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
privacy-sanity.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
privacy-sanity.stderr Update tests 2019-03-11 23:10:26 +03:00
privacy-ufcs.rs
privacy-ufcs.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
privacy1-rpass.rs tests: Move run-pass tests with naming conflicts to ui 2019-07-27 18:56:17 +03:00
privacy1.rs update tests 2020-03-12 15:47:36 -05:00
privacy1.stderr Use more targetted span for error label 2020-03-22 16:09:42 -07:00
privacy2.rs
privacy2.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
privacy3.rs
privacy3.stderr
privacy4.rs
privacy4.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
privacy5.rs resolve: fix error title regarding private constructors 2019-10-11 18:09:23 +03:00
privacy5.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-class-field.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
private-impl-method.rs update tests 2020-03-12 15:47:36 -05:00
private-impl-method.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-in-public-assoc-ty.rs Stop special casing top level TAIT 2020-06-11 16:24:01 +01:00
private-in-public-assoc-ty.stderr Stop special casing top level TAIT 2020-06-11 16:24:01 +01:00
private-in-public-expr-pat.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
private-in-public-ill-formed.rs
private-in-public-ill-formed.stderr Update tests 2019-03-11 23:10:26 +03:00
private-in-public-lint.rs
private-in-public-lint.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
private-in-public-non-principal-2.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
private-in-public-non-principal-2.stderr introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
private-in-public-non-principal.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
private-in-public-non-principal.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
private-in-public-type-alias-impl-trait.rs Replace "existential" by "opaque" 2019-08-02 02:44:36 +01:00
private-in-public-warn.rs Move privacy checking later in the pipeline and make some passes run in parallel 2019-01-30 21:19:02 +01:00
private-in-public-warn.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
private-in-public.rs
private-in-public.stderr Use smaller def span for functions 2020-08-22 18:41:49 -04:00
private-inferred-type-1.rs
private-inferred-type-1.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-inferred-type-2.rs
private-inferred-type-2.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-inferred-type-3.rs rustc: pass Option<&Substs> and Namespace around in ty::item_path. 2019-03-15 13:25:10 +02:00
private-inferred-type-3.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-inferred-type.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
private-inferred-type.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-item-simple.rs
private-item-simple.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-method-cross-crate.rs update tests 2020-03-12 15:47:36 -05:00
private-method-cross-crate.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-method-inherited.rs update tests 2020-03-12 15:47:36 -05:00
private-method-inherited.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-method-rpass.rs tests: Move run-pass tests with naming conflicts to ui 2019-07-27 18:56:17 +03:00
private-method.rs update tests 2020-03-12 15:47:36 -05:00
private-method.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-struct-field-cross-crate.rs
private-struct-field-cross-crate.stderr Add span label to primary error span 2020-03-22 11:18:06 -07:00
private-struct-field-ctor.rs
private-struct-field-ctor.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-struct-field-pattern.rs
private-struct-field-pattern.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-struct-field.rs
private-struct-field.stderr Add span label to primary error span 2020-03-22 11:18:06 -07:00
private-type-in-interface.rs
private-type-in-interface.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
private-variant-reexport.rs
private-variant-reexport.stderr Update tests 2019-03-11 23:10:26 +03:00
pub-extern-privacy.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
pub-use-xcrate.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
pub_use_mods_xcrate_exe.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
union-field-privacy-1.rs
union-field-privacy-1.stderr Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
union-field-privacy-2.rs Fix test. 2019-08-30 00:57:20 +05:30
union-field-privacy-2.stderr Add span label to primary error span 2020-03-22 11:18:06 -07:00