File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,17 @@ fn do_read_manifest(
69
69
parse ( contents, pretty_filename, config) ?
70
70
} ;
71
71
72
+ // Provide a helpful error message for a common user error.
73
+ if let Some ( package) = toml. get ( "package" ) . or_else ( || toml. get ( "project" ) ) {
74
+ if let Some ( feats) = package. get ( "cargo-features" ) {
75
+ bail ! (
76
+ "cargo-features = {} was found in the wrong location, it \
77
+ should be set at the top of Cargo.toml before any tables",
78
+ toml:: to_string( feats) . unwrap( )
79
+ ) ;
80
+ }
81
+ }
82
+
72
83
let mut unused = BTreeSet :: new ( ) ;
73
84
let manifest: TomlManifest = serde_ignored:: deserialize ( toml, |path| {
74
85
let mut key = String :: new ( ) ;
Original file line number Diff line number Diff line change @@ -327,3 +327,32 @@ fn publish_allowed() {
327
327
. masquerade_as_nightly_cargo ( )
328
328
. run ( ) ;
329
329
}
330
+
331
+ #[ cargo_test]
332
+ fn wrong_position ( ) {
333
+ let p = project ( )
334
+ . file (
335
+ "Cargo.toml" ,
336
+ r#"
337
+ [package]
338
+ name = "foo"
339
+ version = "0.1.0"
340
+ cargo-features = ["test-dummy-unstable"]
341
+ "# ,
342
+ )
343
+ . file ( "src/lib.rs" , "" )
344
+ . build ( ) ;
345
+ p. cargo ( "check" )
346
+ . masquerade_as_nightly_cargo ( )
347
+ . with_status ( 101 )
348
+ . with_stderr (
349
+ "\
350
+ error: failed to parse manifest at [..]
351
+
352
+ Caused by:
353
+ cargo-features = [\" test-dummy-unstable\" ] was found in the wrong location, it \
354
+ should be set at the top of Cargo.toml before any tables
355
+ " ,
356
+ )
357
+ . run ( ) ;
358
+ }
You can’t perform that action at this time.
0 commit comments