@@ -319,7 +319,7 @@ async fn modify_cargo_toml(
319
319
let cargo_toml = String :: from_utf8 ( cargo_toml. 0 ) ?;
320
320
let cargo_toml = toml:: from_str ( & cargo_toml) ?;
321
321
322
- let cargo_toml = modify_cargo_toml:: set_edition ( cargo_toml, edition. as_cargo_toml_key ( ) ) ;
322
+ let cargo_toml = modify_cargo_toml:: set_edition ( cargo_toml, edition. to_cargo_toml_key ( ) ) ;
323
323
324
324
let cargo_toml = toml:: to_string ( & cargo_toml) ?;
325
325
let cargo_toml = cargo_toml. into_bytes ( ) ;
@@ -795,6 +795,23 @@ mod tests {
795
795
}
796
796
}
797
797
798
+ fn new_compile_hir_request ( ) -> CompileRequest {
799
+ new_compile_hir_request_for ( Edition :: Rust2021 )
800
+ }
801
+
802
+ fn new_compile_hir_request_for ( edition : Edition ) -> CompileRequest {
803
+ CompileRequest {
804
+ target : CompileTarget :: Hir ,
805
+ channel : Channel :: Beta ,
806
+ crate_type : CrateType :: Library ( LibraryType :: Lib ) ,
807
+ mode : Mode :: Release ,
808
+ edition,
809
+ tests : false ,
810
+ backtrace : false ,
811
+ code : r#"pub fn sub(a: u8, b: u8) -> u8 { a - b }"# . to_owned ( ) ,
812
+ }
813
+ }
814
+
798
815
fn new_compile_llvm_ir_request ( ) -> CompileRequest {
799
816
CompileRequest {
800
817
target : CompileTarget :: LlvmIr ,
@@ -879,6 +896,30 @@ mod tests {
879
896
Ok ( ( ) )
880
897
}
881
898
899
+ #[ tokio:: test]
900
+ #[ snafu:: report]
901
+ async fn test_compile_edition ( ) -> Result < ( ) > {
902
+ for edition in Edition :: ALL {
903
+ let coordinator = new_coordinator ( ) ?;
904
+
905
+ let response = coordinator
906
+ . compile ( new_compile_hir_request_for ( edition) )
907
+ . with_timeout ( )
908
+ . await
909
+ . unwrap ( ) ;
910
+
911
+ let prelude = format ! ( "std::prelude::rust_{}" , edition. to_str( ) ) ;
912
+
913
+ assert ! ( response. success, "stderr: {}" , response. stderr) ;
914
+ assert_contains ! ( response. code, & prelude) ;
915
+
916
+ coordinator. shutdown ( ) . await ?;
917
+ }
918
+
919
+ Ok ( ( ) )
920
+ }
921
+
922
+
882
923
#[ tokio:: test]
883
924
#[ snafu:: report]
884
925
async fn test_compile_assembly ( ) -> Result < ( ) > {
@@ -904,6 +945,25 @@ mod tests {
904
945
Ok ( ( ) )
905
946
}
906
947
948
+ #[ tokio:: test]
949
+ #[ snafu:: report]
950
+ async fn test_compile_hir ( ) -> Result < ( ) > {
951
+ let coordinator = new_coordinator ( ) ?;
952
+
953
+ let response = coordinator
954
+ . compile ( new_compile_hir_request ( ) )
955
+ . with_timeout ( )
956
+ . await
957
+ . unwrap ( ) ;
958
+
959
+ assert ! ( response. success, "stderr: {}" , response. stderr) ;
960
+ assert_contains ! ( response. code, "extern crate std" ) ;
961
+
962
+ coordinator. shutdown ( ) . await ?;
963
+
964
+ Ok ( ( ) )
965
+ }
966
+
907
967
#[ tokio:: test]
908
968
#[ snafu:: report]
909
969
async fn test_compile_llvm_ir ( ) -> Result < ( ) > {
0 commit comments