This outputs some duration counts for various parts of the extraction
process in the database in the form of telemetry diagnostics.
The diagnostics format was preferred to putting things in the relational
database as that will scale better to code scanning and is more flexible
as for the data we can put into it without passing through the dbscheme.
Also, although it's not the case yet, it will be possible to output
diagnostics even if creation of the database fails.
This allows to tweak via extractor options some aspects of the cargo
configuration:
* the target architecture
* features (including `*` for all, which we must understand whether to
set by default)
* cfg overrides
Integration tests will be added in a follow-up commit.
If:
* the text for a file_id is not found (likely non-utf data in file)
* path does not appear in Vfs, in which case we fall back on loading the file from disk with no "semantics" available
Files were reloaded to handle cases were there was no content
for a file_id, causing a panic. Missing contents was caused by
files that did not contain valid UTF-8 data. These are skipped
by rust-analyzer when it is loading data into the RootDatabase.
This avoids problems with files containing invalid utf-8 data, which may cause
panic's like:
```
thread 'main' panicked at external/rules_rust~~_crate~ql~~r~r__ra_ap_salsa-0.0.232/src/input.rs:91:32:
no value set for CompressedFileTextQuery(FileId(2429))
stack backtrace:
0: rust_begin_unwind
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
2: <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::fetch
3: <DB as ra_ap_base_db::SourceDatabase>::compressed_file_text::__shim
4: <ra_ap_base_db::FileTextQuery as salsa::plumbing::QueryFunction>::execute
5: salsa::Cycle::catch
6: salsa::derived_lru::slot::Slot<Q,MP>::execute
7: salsa::derived_lru::slot::Slot<Q,MP>::read
8: <salsa::derived_lru::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
9: <DB as ra_ap_base_db::SourceDatabase>::file_text::__shim
10: <DB as ra_ap_base_db::SourceDatabase>::file_text
11: <ra_ap_base_db::ParseQuery as salsa::plumbing::QueryFunction>::execute
12: salsa::Cycle::catch
13: salsa::derived_lru::slot::Slot<Q,MP>::execute
14: salsa::derived_lru::slot::Slot<Q,MP>::read
15: <salsa::derived_lru::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
16: <DB as ra_ap_base_db::SourceDatabase>::parse::__shim
17: <DB as ra_ap_base_db::SourceDatabase>::parse
18: ra_ap_hir::semantics::SemanticsImpl::parse
19: single_arch_extractor::main
```