Skip to content

Commit ed5b8a2

Browse files
authored
Merge pull request #502 from Areredify/phantom_data
add phantom_data adt flag
2 parents 13aa9d3 + 17957d5 commit ed5b8a2

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

chalk-integration/src/lowering.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ impl LowerAdtDefn for StructDefn {
10011001
let flags = rust_ir::AdtFlags {
10021002
upstream: self.flags.upstream,
10031003
fundamental: self.flags.fundamental,
1004+
phantom_data: self.flags.phantom_data,
10041005
};
10051006

10061007
Ok(rust_ir::AdtDatum {

chalk-parse/src/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub struct StructDefn {
4141
pub struct StructFlags {
4242
pub upstream: bool,
4343
pub fundamental: bool,
44+
pub phantom_data: bool,
4445
}
4546

4647
#[derive(Clone, PartialEq, Eq, Debug)]

chalk-parse/src/parser.lalrpop

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ FundamentalKeyword: () = "#" "[" "fundamental" "]";
4545
NonEnumerableKeyword: () = "#" "[" "non_enumerable" "]";
4646
CoinductiveKeyword: () = "#" "[" "coinductive" "]";
4747
ObjectSafeKeyword: () = "#" "[" "object_safe" "]";
48+
PhantomDataKeyword: () = "#" "[" "phantom_data" "]";
4849

4950
WellKnownTrait: WellKnownTrait = {
5051
"#" "[" "lang" "(" "sized" ")" "]" => WellKnownTrait::Sized,
@@ -57,7 +58,8 @@ WellKnownTrait: WellKnownTrait = {
5758
};
5859

5960
StructDefn: StructDefn = {
60-
<upstream:UpstreamKeyword?> <fundamental:FundamentalKeyword?> "struct" <n:Id><p:Angle<VariableKind>>
61+
<upstream:UpstreamKeyword?> <fundamental:FundamentalKeyword?> <phantom_data:PhantomDataKeyword?>
62+
"struct" <n:Id><p:Angle<VariableKind>>
6163
<w:QuantifiedWhereClauses> "{" <f:Fields> "}" => StructDefn
6264
{
6365
name: n,
@@ -67,6 +69,7 @@ StructDefn: StructDefn = {
6769
flags: StructFlags {
6870
upstream: upstream.is_some(),
6971
fundamental: fundamental.is_some(),
72+
phantom_data: phantom_data.is_some(),
7073
},
7174
}
7275
};

chalk-solve/src/rust_ir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub struct AdtDatumBound<I: Interner> {
101101
pub struct AdtFlags {
102102
pub upstream: bool,
103103
pub fundamental: bool,
104+
pub phantom_data: bool,
104105
}
105106

106107
#[derive(Clone, Debug, PartialEq, Eq, Hash)]

tests/lowering/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,3 +686,13 @@ fn lifetime_outlives() {
686686
}
687687
}
688688
}
689+
690+
#[test]
691+
fn phantom_data() {
692+
lowering_success! {
693+
program {
694+
#[phantom_data]
695+
struct PhantomData<T> {}
696+
}
697+
}
698+
}

0 commit comments

Comments
 (0)