File tree Expand file tree Collapse file tree 5 files changed +29
-0
lines changed
compiler/base/modify-cargo-toml/src Expand file tree Collapse file tree 5 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ fn main() {
20
20
let mut cargo_toml: Value = toml:: from_str ( & input)
21
21
. unwrap_or_else ( |e| panic ! ( "Cannot parse {} as TOML: {}" , input_filename. display( ) , e) ) ;
22
22
23
+ if env:: var_os ( "PLAYGROUND_FEATURE_EDITION2021" ) . is_some ( ) {
24
+ cargo_toml = set_feature_edition2021 ( cargo_toml) ;
25
+ }
26
+
23
27
if let Ok ( edition) = env:: var ( "PLAYGROUND_EDITION" ) {
24
28
cargo_toml = set_edition ( cargo_toml, & edition) ;
25
29
}
@@ -62,6 +66,22 @@ fn ensure_string_in_vec(values: &mut Vec<String>, val: &str) {
62
66
}
63
67
}
64
68
69
+ fn set_feature_edition2021 ( cargo_toml : Value ) -> Value {
70
+ #[ derive( Debug , Serialize , Deserialize ) ]
71
+ #[ serde( rename_all = "kebab-case" ) ]
72
+ struct CargoToml {
73
+ #[ serde( default ) ]
74
+ cargo_features : Vec < String > ,
75
+ #[ serde( flatten) ]
76
+ other : Other ,
77
+ }
78
+
79
+ modify ( cargo_toml, |mut cargo_toml : CargoToml | {
80
+ ensure_string_in_vec ( & mut cargo_toml. cargo_features , "edition2021" ) ;
81
+ cargo_toml
82
+ } )
83
+ }
84
+
65
85
fn set_edition ( cargo_toml : Value , edition : & str ) -> Value {
66
86
#[ derive( Debug , Serialize , Deserialize ) ]
67
87
#[ serde( rename_all = "kebab-case" ) ]
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const AdvancedOptionsMenu: React.SFC = () => {
29
29
>
30
30
< option value = { Edition . Rust2015 } > 2015</ option >
31
31
< option value = { Edition . Rust2018 } > 2018</ option >
32
+ < option value = { Edition . Rust2021 } > 2021</ option >
32
33
</ SelectConfig >
33
34
34
35
< EitherConfig
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ export enum Mode {
96
96
export enum Edition {
97
97
Rust2015 = '2015' ,
98
98
Rust2018 = '2018' ,
99
+ Rust2021 = '2021' ,
99
100
}
100
101
101
102
export enum Backtrace {
Original file line number Diff line number Diff line change @@ -1480,6 +1480,7 @@ fn parse_edition(s: &str) -> Result<Option<sandbox::Edition>> {
1480
1480
"" => None ,
1481
1481
"2015" => Some ( sandbox:: Edition :: Rust2015 ) ,
1482
1482
"2018" => Some ( sandbox:: Edition :: Rust2018 ) ,
1483
+ "2021" => Some ( sandbox:: Edition :: Rust2021 ) ,
1483
1484
value => InvalidEdition { value } . fail ( ) ?,
1484
1485
} )
1485
1486
}
Original file line number Diff line number Diff line change @@ -681,6 +681,7 @@ pub enum Mode {
681
681
pub enum Edition {
682
682
Rust2015 ,
683
683
Rust2018 ,
684
+ Rust2021 , // TODO - add parallel tests for 2021
684
685
}
685
686
686
687
impl Edition {
@@ -690,6 +691,7 @@ impl Edition {
690
691
match * self {
691
692
Rust2015 => "2015" ,
692
693
Rust2018 => "2018" ,
694
+ Rust2021 => "2021" ,
693
695
}
694
696
}
695
697
}
@@ -751,6 +753,10 @@ impl DockerCommandExt for Command {
751
753
752
754
fn apply_edition ( & mut self , req : impl EditionRequest ) {
753
755
if let Some ( edition) = req. edition ( ) {
756
+ if edition == Edition :: Rust2021 {
757
+ self . args ( & [ "--env" , & format ! ( "PLAYGROUND_FEATURE_EDITION2021=true" ) ] ) ;
758
+ }
759
+
754
760
self . args ( & [ "--env" , & format ! ( "PLAYGROUND_EDITION={}" , edition. cargo_ident( ) ) ] ) ;
755
761
}
756
762
}
You can’t perform that action at this time.
0 commit comments