rust/compiler
bors 0b7a598e12 Auto merge of #72603 - jsgf:extern-loc, r=nikomatsakis
Implement `--extern-location`

This PR implements `--extern-location` as a followup to #72342 as part of the implementation of #57274. The goal of this PR is to allow rustc, in coordination with the build system, to present a useful diagnostic about how to remove an unnecessary dependency from a dependency specification file (eg Cargo.toml).

EDIT: Updated to current PR state.

The location is specified for each named crate - that is, for a given `--extern foo[=path]` there can also be `--extern-location foo=<location>`. It supports ~~three~~ two styles of location:
~~1. `--extern-location foo=file:<path>:<line>` - a file path and line specification
1. `--extern-location foo=span:<path>:<start>:<end>` - a span specified as a file and start and end byte offsets~~
1. `--extern-location foo=raw:<anything>` - a raw string which is included in the output
1. `--extern-location foo=json:<anything>` - an arbitrary Json structure which is emitted via Json diagnostics in a `tool_metadata` field.

~~1 & 2 are turned into an internal `Span`, so long as the path exists and is readable, and the location is meaningful (within the file, etc). This is used as the `Span` for a fix suggestion which is reported like other fix suggestions.~~

`raw` and `json` are for the case where the location isn't best expressed as a file and location within that file. For example, it could be a rule name and the name of a dependency within that rule. `rustc` makes no attempt to parse the raw string, and simply includes it in the output diagnostic text. `json` is only included in json diagnostics. `raw` is emitted as text and also as a json string in `tool_metadata`.

If no `--extern-location` option is specified then it will emit a default json structure consisting of `{"name": name, "path": path}` corresponding to the name and path in `--extern name=path`.

This is a prototype/RFC to make some of the earlier conversations more concrete. It doesn't stand on its own - it's only useful if implemented by Cargo and other build systems. There's also a ton of implementation details which I'd appreciate a second eye on as well.

~~**NOTE** The first commit in this PR is #72342 and should be ignored for the purposes of review. The first commit is a very simplistic implementation which is basically raw-only, presented as a MVP. The second implements the full thing, and subsequent commits are incremental fixes.~~

cc `@ehuss` `@est31` `@petrochenkov` `@estebank`
2021-02-08 02:23:17 +00:00
..
rustc
rustc_apfloat
rustc_arena Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se 2021-01-31 01:47:25 +01:00
rustc_ast Rollup merge of #81645 - m-ou-se:panic-lint, r=estebank,flip1995 2021-02-04 21:10:36 +01:00
rustc_ast_lowering lowering of generic args in AssocTyConstraint 2021-02-04 16:20:58 +01:00
rustc_ast_passes Auto merge of #81346 - hug-dev:nonsecure-call-abi, r=jonas-schievink 2021-02-03 06:00:43 +00:00
rustc_ast_pretty Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
rustc_attr Never MIR inline functions with a different instruction set 2021-02-05 00:00:00 +00:00
rustc_builtin_macros expand/resolve: Turn #[derive] into a regular macro attribute 2021-02-07 20:08:45 +03:00
rustc_codegen_cranelift Add a new ABI to support cmse_nonsecure_call 2021-02-02 13:04:31 +00:00
rustc_codegen_llvm Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa 2021-02-07 22:25:14 +00:00
rustc_codegen_ssa rustc_codegen_ssa: tune codegen scheduling to reduce memory usage 2021-02-03 18:55:05 -08:00
rustc_data_structures Rollup merge of #81771 - tgnottingham:time-passes-rss-delta, r=oli-obk 2021-02-05 12:26:08 +01:00
rustc_driver Indicate both start and end of pass RSS in time-passes output 2021-01-29 12:46:29 -08:00
rustc_error_codes Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa 2021-02-07 22:25:14 +00:00
rustc_errors Make sure all fields are accounted for in encode_fields! 2021-02-07 14:54:22 -08:00
rustc_expand Address review comments 2021-02-07 20:08:45 +03:00
rustc_feature Feature gate macro attributes in #[derive] output 2021-02-07 20:08:45 +03:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #81680 - camsteffen:primty, r=oli-obk 2021-02-06 17:01:45 +01:00
rustc_hir_pretty hir pretty printing 2021-02-04 16:20:57 +01:00
rustc_incremental
rustc_index Auto merge of #81498 - thomaseizinger:ice-workaround-56935-rustc-index, r=matthewjasper 2021-02-07 08:09:58 +00:00
rustc_infer tidy: Run tidy style against markdown files. 2021-02-04 09:01:50 -08:00
rustc_interface Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
rustc_lexer
rustc_lint Add --extern-loc to augment unused crate dependency diagnostics 2021-02-07 14:54:20 -08:00
rustc_lint_defs Add --extern-loc to augment unused crate dependency diagnostics 2021-02-07 14:54:20 -08:00
rustc_llvm Add a new ABI to support cmse_nonsecure_call 2021-02-02 13:04:31 +00:00
rustc_macros Indent the code correctly again after removing the query categories. 2021-01-31 21:40:03 +01:00
rustc_metadata Add --extern-loc to augment unused crate dependency diagnostics 2021-02-07 14:54:20 -08:00
rustc_middle Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa 2021-02-07 22:25:14 +00:00
rustc_mir Never MIR inline functions with a different instruction set 2021-02-05 00:00:00 +00:00
rustc_mir_build Auto merge of #80632 - Nadrieril:fix-80501, r=varkor 2021-02-07 16:48:57 +00:00
rustc_parse expand/resolve: Turn #[derive] into a regular macro attribute 2021-02-07 20:08:45 +03:00
rustc_parse_format
rustc_passes Bump rustfmt version 2021-02-02 09:09:52 -05:00
rustc_plugin_impl
rustc_privacy more things are const evaluatable *sparkles* 2021-02-01 20:05:50 +00:00
rustc_query_system
rustc_resolve Feature gate macro attributes in #[derive] output 2021-02-07 20:08:45 +03:00
rustc_save_analysis
rustc_serialize Revert stabilizing integer::BITS. 2021-02-03 22:23:58 +01:00
rustc_session Add --extern-loc to augment unused crate dependency diagnostics 2021-02-07 14:54:20 -08:00
rustc_span Feature gate macro attributes in #[derive] output 2021-02-07 20:08:45 +03:00
rustc_symbol_mangling Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-se 2021-01-30 13:36:44 +09:00
rustc_target Auto merge of #81346 - hug-dev:nonsecure-call-abi, r=jonas-schievink 2021-02-03 06:00:43 +00:00
rustc_trait_selection Rollup merge of #81738 - camelid:misc-small-diag-cleanup, r=lcnr 2021-02-06 17:01:49 +01:00
rustc_traits Update Chalk 2021-02-02 12:37:22 -05:00
rustc_ty_utils
rustc_type_ir
rustc_typeck Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa 2021-02-07 22:25:14 +00:00