Skip to content

Commit 47f418f

Browse files
authored
Merge pull request #134 from spastorino/smir-to-formality
Smir to formality basic set-up
2 parents 40b25d5 + aed2999 commit 47f418f

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ formality-types = { version = "0.1.0", path = "crates/formality-types" }
2323
formality-check = { version = "0.1.0", path = "crates/formality-check" }
2424
formality-prove = { version = "0.1.0", path = "crates/formality-prove" }
2525
formality-core = { version = "0.1.0", path = "crates/formality-core" }
26+
formality-smir = { version = "0.1.0", path = "crates/formality-smir" }
2627
ui_test = "0.12"
2728

2829
[workspace]
@@ -33,6 +34,7 @@ members = [
3334
"crates/formality-check",
3435
"crates/formality-rust",
3536
"crates/formality-prove",
37+
"crates/formality-smir",
3638
]
3739

3840
[[test]]

crates/formality-smir/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "formality-smir"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
formality-types = { path = "../formality-types" }

crates/formality-smir/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(rustc_private)]
2+
3+
extern crate rustc_driver;
4+
extern crate rustc_smir;
5+
6+
use rustc_smir::stable_mir;
7+
8+
/// Trait used to convert from Stable MIR to Formality types.
9+
pub trait ToFormality {
10+
/// The formality representation of the stable MIR type implementing ToFormality.
11+
type T;
12+
/// Converts an object to the equivalent Formality representation.
13+
fn formality(&self) -> Self::T;
14+
}
15+
16+
impl ToFormality for stable_mir::ty::GenericParamDefKind {
17+
type T = formality_types::derive_links::ParameterKind;
18+
19+
fn formality(&self) -> Self::T {
20+
use formality_types::derive_links::ParameterKind;
21+
22+
match self {
23+
stable_mir::ty::GenericParamDefKind::Lifetime => ParameterKind::Lt,
24+
stable_mir::ty::GenericParamDefKind::Type { .. } => ParameterKind::Ty,
25+
stable_mir::ty::GenericParamDefKind::Const { .. } => ParameterKind::Const,
26+
}
27+
}
28+
}

rust-toolchain

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[toolchain]
2-
channel = "stable"
2+
channel = "nightly"
3+
components = [ "rustc-dev", "llvm-tools" ]

0 commit comments

Comments
 (0)