move ribs out

This commit is contained in:
sfja 2025-01-28 23:15:59 +01:00
parent 493a11a93b
commit 188c2d806d
2 changed files with 33 additions and 32 deletions

View File

@ -91,35 +91,3 @@ export class AstLowerer {
return todo();
}
}
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/struct.Rib.html
type Rib = {
kind: RibKind;
bindings: Map<IdentId, Res>;
};
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/enum.RibKind.html
type RibKind =
| { tag: "normal" }
| { tag: "fn" }
| { tag: "item"; defKind: DefKind }
| { tag: "mod" };
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/enum.RibKind.html
type Res =
| { tag: "error" }
| { tag: "def"; kind: DefKind; id: DefId }
| { tag: "local"; id: DefId };
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def/enum.DefKind.html
type DefKind =
| { type: "mod" }
| { type: "struct" }
| { type: "enum" }
| { type: "variant" }
| { type: "ty_alias" }
| { type: "ty_param" }
| { type: "fn" }
| { type: "ctor" }
| { type: "use" }
| { type: "field" };

33
compiler/middle/rib.ts Normal file
View File

@ -0,0 +1,33 @@
import { DefId, IdentId } from "../ctx.ts";
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/struct.Rib.html
export type Rib = {
kind: RibKind;
bindings: Map<IdentId, Res>;
};
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/enum.RibKind.html
export type RibKind =
| { tag: "normal" }
| { tag: "fn" }
| { tag: "item"; defKind: DefKind }
| { tag: "mod" };
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/enum.RibKind.html
export type Res =
| { tag: "error" }
| { tag: "def"; kind: DefKind; id: DefId }
| { tag: "local"; id: DefId };
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def/enum.DefKind.html
export type DefKind =
| { type: "mod" }
| { type: "struct" }
| { type: "enum" }
| { type: "variant" }
| { type: "ty_alias" }
| { type: "ty_param" }
| { type: "fn" }
| { type: "ctor" }
| { type: "use" }
| { type: "field" };