From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id EE6B23860C37; Tue, 16 Jan 2024 18:17:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE6B23860C37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705429067; bh=nMl6LPbRWBi8yNSWdOzRDzEtmycKnLrvogQ10B1PJz4=; h=From:To:Subject:Date:From; b=uvIDT7btTOujCsRSG7MxTfEMQaN68wffM7Lyx4WOfkkKiFvLtcOP5MyCl/5C9QIaA kYRSVScUvsXgdrb/FM5g/81oU5Lh5XWpMNlpPh8j7xJKzJIf7PpNOCj0CbR1LSSdtq UeqgCyzWBvvTGd+f9S9qx1FtjLDdM59OrgxhsneU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8090] gccrs: borrowck: Dev notes X-Act-Checkin: gcc X-Git-Author: Jakub Dupak X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 20d6f6015552fcb89ea39ca016df4aa08f46f306 X-Git-Newrev: ea90f52b9a373fcab8accc2ef7a49d089dcc4aea Message-Id: <20240116181747.EE6B23860C37@sourceware.org> Date: Tue, 16 Jan 2024 18:17:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ea90f52b9a373fcab8accc2ef7a49d089dcc4aea commit r14-8090-gea90f52b9a373fcab8accc2ef7a49d089dcc4aea Author: Jakub Dupak Date: Tue Oct 24 08:32:20 2023 +0200 gccrs: borrowck: Dev notes gcc/rust/ChangeLog: * checks/errors/borrowck/dev-notes.md: New file. Signed-off-by: Jakub Dupak Diff: --- gcc/rust/checks/errors/borrowck/dev-notes.md | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gcc/rust/checks/errors/borrowck/dev-notes.md b/gcc/rust/checks/errors/borrowck/dev-notes.md new file mode 100644 index 00000000000..2e170e76102 --- /dev/null +++ b/gcc/rust/checks/errors/borrowck/dev-notes.md @@ -0,0 +1,40 @@ +# Borrow-checker Development Notes + +## Testing BIR building + +There is no way to test BIR building directly, since it is a dead branch of the compilation pipeline. +The only way to verify its generations is through manual inspection. +The best way to inspect the BIR is to compare it with rustc's MIR. + +The following command will compile a rust file into a library and dump its MIR: + +```shell +rustc --crate-type=lib -A dead_code -A unused -Z dump-mir="" +``` + +The MIR dump directory `mir_dump` contains a dump before and after each MIR pass. +We are interested in the one used for borrow-checking, which is called `..002-000.analysis.after.mir`. + +BIR dump is emitted to a `bir_dump` directory. With the following naming scheme: `..bir.dump`. + +At this point, MIR dump contains helper constructions that BIR does not contain yet (like storage live/dead annotations). To remove them from the MIR dump, run the following command: + +```shell +awk -i inplace '!/^\s*(\/\/|StorageLive|StorageDead|FakeRead)/' mir_dump/* +``` + +To get the BIR dump into a similar format, run the following command: + +```shell +./crab1 -frust-incomplete-and-experimental-compiler-do-not-use -frust-borrowcheck -frust-dump-bir -frust-compile-until=compilation +``` + + +## TODO + +- scope handling, cleanup +- switch coercions to adjustments from typechecking +- operator overloading +- match selection +- let without an initializer +- lifetime parameters \ No newline at end of file