File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,11 @@ impl FromStr for Edition {
82
82
match s {
83
83
"2015" => Ok ( Edition :: Edition2015 ) ,
84
84
"2018" => Ok ( Edition :: Edition2018 ) ,
85
+ s if s. parse ( ) . map_or ( false , |y : u16 | y > 2020 && y < 2050 ) => bail ! (
86
+ "this version of Cargo is older than the `{}` edition, \
87
+ and only supports `2015` and `2018` editions.",
88
+ s
89
+ ) ,
85
90
s => bail ! (
86
91
"supported edition values are `2015` or `2018`, but `{}` \
87
92
is unknown",
Original file line number Diff line number Diff line change @@ -1086,6 +1086,38 @@ Caused by:
1086
1086
. run ( ) ;
1087
1087
}
1088
1088
1089
+ #[ cargo_test]
1090
+ fn test_edition_from_the_future ( ) {
1091
+ let p = project ( )
1092
+ . file (
1093
+ "Cargo.toml" ,
1094
+ r#"[package]
1095
+ edition = "2038"
1096
+ name = "foo"
1097
+ version = "99.99.99"
1098
+ authors = []
1099
+ "# ,
1100
+ )
1101
+ . file ( "src/main.rs" , r#""# )
1102
+ . build ( ) ;
1103
+
1104
+ p. cargo ( "build" )
1105
+ . with_status ( 101 )
1106
+ . with_stderr (
1107
+ "\
1108
+ error: failed to parse manifest at `[..]`
1109
+
1110
+ Caused by:
1111
+ failed to parse the `edition` key
1112
+
1113
+ Caused by:
1114
+ this version of Cargo is older than the `2038` edition, and only supports `2015` and `2018` editions.
1115
+ "
1116
+ . to_string ( ) ,
1117
+ )
1118
+ . run ( ) ;
1119
+ }
1120
+
1089
1121
#[ cargo_test]
1090
1122
fn do_not_package_if_src_was_modified ( ) {
1091
1123
let p = project ( )
You can’t perform that action at this time.
0 commit comments