diff --git a/chalk-integration/src/lowering.rs b/chalk-integration/src/lowering.rs index f4c81f51eaa..b7932672a68 100644 --- a/chalk-integration/src/lowering.rs +++ b/chalk-integration/src/lowering.rs @@ -1001,6 +1001,7 @@ impl LowerAdtDefn for StructDefn { let flags = rust_ir::AdtFlags { upstream: self.flags.upstream, fundamental: self.flags.fundamental, + phantom_data: self.flags.phantom_data, }; Ok(rust_ir::AdtDatum { diff --git a/chalk-parse/src/ast.rs b/chalk-parse/src/ast.rs index 62ec229cad7..a64a2379dc9 100644 --- a/chalk-parse/src/ast.rs +++ b/chalk-parse/src/ast.rs @@ -41,6 +41,7 @@ pub struct StructDefn { pub struct StructFlags { pub upstream: bool, pub fundamental: bool, + pub phantom_data: bool, } #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/chalk-parse/src/parser.lalrpop b/chalk-parse/src/parser.lalrpop index 6e7756b72a5..b8486620ea3 100644 --- a/chalk-parse/src/parser.lalrpop +++ b/chalk-parse/src/parser.lalrpop @@ -45,6 +45,7 @@ FundamentalKeyword: () = "#" "[" "fundamental" "]"; NonEnumerableKeyword: () = "#" "[" "non_enumerable" "]"; CoinductiveKeyword: () = "#" "[" "coinductive" "]"; ObjectSafeKeyword: () = "#" "[" "object_safe" "]"; +PhantomDataKeyword: () = "#" "[" "phantom_data" "]"; WellKnownTrait: WellKnownTrait = { "#" "[" "lang" "(" "sized" ")" "]" => WellKnownTrait::Sized, @@ -57,7 +58,8 @@ WellKnownTrait: WellKnownTrait = { }; StructDefn: StructDefn = { - "struct" > + + "struct" > "{" "}" => StructDefn { name: n, @@ -67,6 +69,7 @@ StructDefn: StructDefn = { flags: StructFlags { upstream: upstream.is_some(), fundamental: fundamental.is_some(), + phantom_data: phantom_data.is_some(), }, } }; diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index 63865a6f499..9f3f9e9d891 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -101,6 +101,7 @@ pub struct AdtDatumBound { pub struct AdtFlags { pub upstream: bool, pub fundamental: bool, + pub phantom_data: bool, } #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/tests/lowering/mod.rs b/tests/lowering/mod.rs index 408fa851453..a903625a4ff 100644 --- a/tests/lowering/mod.rs +++ b/tests/lowering/mod.rs @@ -686,3 +686,13 @@ fn lifetime_outlives() { } } } + +#[test] +fn phantom_data() { + lowering_success! { + program { + #[phantom_data] + struct PhantomData {} + } + } +}