Skip to content

Commit

Permalink
Create OngoingRelease status for preview features, set diamond trait …
Browse files Browse the repository at this point in the history
…reuse to ongoingrelase

Summary:
This diff adds a new OngoingRelease enum in preview features that turns on unstable feature checking in rust_parser_errors for the runtime but not the typechecker.

Once you have a feature in this state, the typechecker will still enforce it. After HHVM is released, you can then remove any use of `check_can_use_feature` for your feature. This will turn off typechecker enforcement.

After that, be warned that there may still be file attributes left in www from previewing. Feature implementers will need to clean those up in www first before removing their feature from the UnstableFeatures enum altogether.

Reviewed By: francesco-zappa-nardelli

Differential Revision: D40182173

fbshipit-source-id: cbdeaa9aefde948d78054d461192ac40712bd25d
  • Loading branch information
jamesjwu authored and facebook-github-bot committed Oct 8, 2022
1 parent 7e52b43 commit dcfea5c
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 14 deletions.
10 changes: 8 additions & 2 deletions hphp/hack/src/parser/rust_parser_errors.rs
Expand Up @@ -73,6 +73,7 @@ enum FeatureStatus {
Preview,
Migration,
Deprecated,
OngoingRelease,
// TODO: add other modes like "Advanced" or "Deprecated" if necessary.
// Those are just variants of "Preview" for the runtime's sake, though,
// and likely only need to be distinguished in the lint rule rather than here
Expand Down Expand Up @@ -121,7 +122,7 @@ impl UnstableFeatures {
UnstableFeatures::TypeConstSuperBound => Unstable,
UnstableFeatures::ClassConstDefault => Migration,
UnstableFeatures::TypeRefinements => Unstable,
UnstableFeatures::MethodTraitDiamond => Preview,
UnstableFeatures::MethodTraitDiamond => OngoingRelease,
UnstableFeatures::UpcastExpression => Unstable,
UnstableFeatures::RequireClass => Preview,
UnstableFeatures::EnumClassTypeConstants => Unstable,
Expand Down Expand Up @@ -1251,7 +1252,12 @@ impl<'a, State: 'a + Clone> ParserErrors<'a, State> {
}

_ => false,
} || self.env.context.active_unstable_features.contains(feature);
} || self.env.context.active_unstable_features.contains(feature)
// Preview features with an ongoing release should be allowed by the
// runtime, but not the typechecker
|| (feature.get_feature_status() == FeatureStatus::OngoingRelease
&& self.env.codegen);

if !enabled {
self.errors.push(make_error_from_node(
node,
Expand Down
@@ -0,0 +1,2 @@
File "trait_diamond_no_attribute.php", line 15, characters 1-30:
Cannot use unstable feature: `method_trait_diamond` (Parsing[1002])
@@ -0,0 +1,20 @@
<?hh
<<file:__EnableUnstableFeatures('method_trait_diamond')>>

trait MyTrait1 {
public function testFun(): void {}
}
trait MyTrait2 {
use MyTrait1;
}

<<__EnableMethodTraitDiamond>>
class MyClass {
use MyTrait1;
use MyTrait2;
}

<<__EntryPoint>>
function foo(): void {
echo "Done!\n";
}
@@ -0,0 +1 @@
Done!
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use1.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use2.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use3.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use4.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use5.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use6.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use7.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use_const.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


class C {
const int X = 1;
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use_final1.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public final function foo() : void {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use_final2.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public final function foo() : void {
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion hphp/test/slow/traits/diamond_use/diamond_use_static1.php
@@ -1,7 +1,7 @@
<?hh
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

<<file:__EnableUnstableFeatures('method_trait_diamond')>>


trait T {
public static function foo() : void {
Expand Down

0 comments on commit dcfea5c

Please sign in to comment.