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() {
2020 let mut cargo_toml: Value = toml:: from_str ( & input)
2121 . unwrap_or_else ( |e| panic ! ( "Cannot parse {} as TOML: {}" , input_filename. display( ) , e) ) ;
2222
23+ if env:: var_os ( "PLAYGROUND_FEATURE_EDITION2021" ) . is_some ( ) {
24+ cargo_toml = set_feature_edition2021 ( cargo_toml) ;
25+ }
26+
2327 if let Ok ( edition) = env:: var ( "PLAYGROUND_EDITION" ) {
2428 cargo_toml = set_edition ( cargo_toml, & edition) ;
2529 }
@@ -62,6 +66,22 @@ fn ensure_string_in_vec(values: &mut Vec<String>, val: &str) {
6266 }
6367}
6468
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+
6585fn set_edition ( cargo_toml : Value , edition : & str ) -> Value {
6686 #[ derive( Debug , Serialize , Deserialize ) ]
6787 #[ serde( rename_all = "kebab-case" ) ]
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const AdvancedOptionsMenu: React.SFC = () => {
2929 >
3030 < option value = { Edition . Rust2015 } > 2015</ option >
3131 < option value = { Edition . Rust2018 } > 2018</ option >
32+ < option value = { Edition . Rust2021 } > 2021</ option >
3233 </ SelectConfig >
3334
3435 < EitherConfig
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ export enum Mode {
9696export enum Edition {
9797 Rust2015 = '2015' ,
9898 Rust2018 = '2018' ,
99+ Rust2021 = '2021' ,
99100}
100101
101102export 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>> {
14801480 "" => None ,
14811481 "2015" => Some ( sandbox:: Edition :: Rust2015 ) ,
14821482 "2018" => Some ( sandbox:: Edition :: Rust2018 ) ,
1483+ "2021" => Some ( sandbox:: Edition :: Rust2021 ) ,
14831484 value => InvalidEdition { value } . fail ( ) ?,
14841485 } )
14851486}
Original file line number Diff line number Diff line change @@ -681,6 +681,7 @@ pub enum Mode {
681681pub enum Edition {
682682 Rust2015 ,
683683 Rust2018 ,
684+ Rust2021 , // TODO - add parallel tests for 2021
684685}
685686
686687impl Edition {
@@ -690,6 +691,7 @@ impl Edition {
690691 match * self {
691692 Rust2015 => "2015" ,
692693 Rust2018 => "2018" ,
694+ Rust2021 => "2021" ,
693695 }
694696 }
695697}
@@ -751,6 +753,10 @@ impl DockerCommandExt for Command {
751753
752754 fn apply_edition ( & mut self , req : impl EditionRequest ) {
753755 if let Some ( edition) = req. edition ( ) {
756+ if edition == Edition :: Rust2021 {
757+ self . args ( & [ "--env" , & format ! ( "PLAYGROUND_FEATURE_EDITION2021=true" ) ] ) ;
758+ }
759+
754760 self . args ( & [ "--env" , & format ! ( "PLAYGROUND_EDITION={}" , edition. cargo_ident( ) ) ] ) ;
755761 }
756762 }
You can’t perform that action at this time.
0 commit comments