rust-analyzer/crates
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
..
base-db ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
cfg ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
flycheck ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
hir Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
hir-def Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
hir-expand beginning of MIR 2023-02-27 23:45:54 +03:30
hir-ty Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
ide Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
ide-assists Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
ide-completion Simplify 2023-02-27 15:51:45 +01:00
ide-db Simplify 2023-02-27 15:51:45 +01:00
ide-diagnostics ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
ide-ssr ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
intern ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
limit ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
mbe internal: Enable smallvec's union feature 2023-02-14 17:01:01 +01:00
parser Add check for extra path segments after an angled one 2023-02-25 16:16:49 +01:00
paths ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
proc-macro-api Cargo fmt 2023-02-14 14:45:05 -05:00
proc-macro-srv fix: Fix proc-macro-server incorrectly stripping delimiters 2023-02-13 12:07:31 +01:00
proc-macro-srv-cli ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
proc-macro-test ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
profile ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
project-model ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
rust-analyzer Auto merge of #14040 - HKalbasi:mir, r=HKalbasi 2023-02-28 09:12:19 +00:00
sourcegen ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
stdx Fix a pair of typos 2023-02-15 14:11:11 +02:00
syntax minor: import Either from either 2023-02-25 21:55:11 +09:00
test-utils beginning of MIR 2023-02-27 23:45:54 +03:30
text-edit ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
toolchain Respect $CARGO_HOME when looking up toolchains. 2023-02-26 15:37:04 +09:00
tt ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
vfs ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
vfs-notify ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00