rust/crates/rust-analyzer/src
bors a0be16b0b2 Auto merge of #14040 - HKalbasi:mir, r=HKalbasi
Beginning of MIR

This pull request introduces the initial implementation of MIR lowering and interpreting in Rust Analyzer.

The implementation of MIR has potential to bring several benefits:
- Executing a unit test without compiling it: This is my main goal. It can be useful for quickly testing code changes and print-debugging unit tests without the need for a full compilation (ideally in almost zero time, similar to languages like python and js). There is a probability that it goes nowhere, it might become slower than rustc, or it might need some unreasonable amount of memory, or we may fail to support a common pattern/function that make it unusable for most of the codes.
- Constant evaluation: MIR allows for easier and more correct constant evaluation, on par with rustc. If r-a wants to fully support the type system, it needs full const eval, which means arbitrary code execution, which needs MIR or something similar.
- Supporting more diagnostics: MIR can be used to detect errors, most famously borrow checker and lifetime errors,  but also mutability errors and uninitialized variables, which can be difficult/impossible to detect in HIR.
- Lowering closures: With MIR we can find out closure capture modes, which is useful in detecting if a closure implements the `FnMut` or `Fn` traits, and calculating its size and data layout.

But the current PR implements no diagnostics and doesn't support closures. About const eval, I removed the old const eval code and it now uses the mir interpreter. Everything that is supported in stable rustc is either implemented or is super easy to implement. About interpreting unit tests, I added an experimental config, disabled by default, that shows a `pass` or `fail` on hover of unit tests (ideally it should be a button similar to `Run test` button, but I didn't figured out how to add them). Currently, no real world test works, due to missing features including closures, heap allocation, `dyn Trait` and ... so at this point it is only useful for me selecting what to implement next.

The implementation of MIR is based on the design of rustc, the data structures are almost copy paste (so it should be easy to migrate it to a possible future stable-mir), but the lowering and interpreting code is from me.
2023-02-28 09:12:19 +00:00
..
bin Support DidChangeWorkspaceFolders capability 2023-02-07 22:40:40 +01:00
cli Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
config Fix checkOnSave to check config patching not always working 2023-01-18 20:29:55 +01:00
diagnostics Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
caps.rs Bump lsp-types 2023-02-14 14:59:50 +01:00
cargo_target_spec.rs ⬆️ rust-analyzer 2022-11-23 17:24:03 +02:00
cli.rs Inline all format arguments where possible 2022-12-24 14:36:10 -05:00
config.rs Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
diagnostics.rs remove useless conversions 2023-01-02 15:02:54 +00:00
diff.rs
dispatch.rs Inline all format arguments where possible 2022-12-24 14:36:10 -05:00
from_proto.rs Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
global_state.rs Tweak change collapsing 2023-01-29 17:20:22 +02:00
handlers.rs Fix markdown removal in hover handling whitespace weirdly 2023-01-20 14:29:12 +01:00
integrated_benchmarks.rs Auto merge of #14100 - Veykril:load_cargo-proc-macro-srv-config, r=Veykril 2023-02-08 10:12:31 +00:00
lib.rs Inline all format arguments where possible 2022-12-24 14:36:10 -05:00
line_index.rs Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
lsp_ext.rs Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
lsp_utils.rs Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
main_loop.rs Support UTF-32 position encoding 2023-02-14 01:09:50 +00:00
markdown.rs
mem_docs.rs ⬆️ rust-analyzer 2022-11-23 17:24:03 +02:00
op_queue.rs
reload.rs Bump lsp-types 2023-02-14 14:59:50 +01:00
semantic_tokens.rs remove useless casts 2023-01-02 15:02:54 +00:00
task_pool.rs Add numThreads in config to avoid spawning lots of threads every time 2022-12-09 21:35:06 +08:00
to_proto.rs internal: Make CompletionItem more POD-like 2023-02-16 09:29:55 +01:00
version.rs