File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -1021,6 +1021,13 @@ impl TomlManifest {
1021
1021
None => false ,
1022
1022
} ;
1023
1023
1024
+ if summary. features ( ) . contains_key ( "default-features" ) {
1025
+ warnings. push (
1026
+ "`default-features = [\" ..\" ]` was found in [features]. \
1027
+ Did you mean to use `default = [\" ..\" ]`?". to_string ( )
1028
+ )
1029
+ }
1030
+
1024
1031
let custom_metadata = project. metadata . clone ( ) ;
1025
1032
let mut manifest = Manifest :: new (
1026
1033
summary,
Original file line number Diff line number Diff line change @@ -1730,3 +1730,36 @@ fn feature_off_dylib() {
1730
1730
// Check that building without `f1` uses a dylib without `f1`.
1731
1731
p. cargo ( "run -p bar" ) . run ( ) ;
1732
1732
}
1733
+
1734
+ #[ test]
1735
+ fn warn_if_default_features ( ) {
1736
+ let p = project ( )
1737
+ . file (
1738
+ "Cargo.toml" ,
1739
+ r#"
1740
+ [project]
1741
+ name = "foo"
1742
+ version = "0.0.1"
1743
+ authors = []
1744
+
1745
+ [dependencies.bar]
1746
+ path = "bar"
1747
+ optional = true
1748
+
1749
+ [features]
1750
+ default-features = ["bar"]
1751
+ "#
1752
+ ) . file ( "src/main.rs" , "fn main() {}" )
1753
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.1" ) )
1754
+ . file ( "bar/src/lib.rs" , "pub fn bar() {}" )
1755
+ . build ( ) ;
1756
+
1757
+ p. cargo ( "build" )
1758
+ . with_stderr (
1759
+ r#"
1760
+ [WARNING] `default-features = [".."]` was found in [features]. Did you mean to use `default = [".."]`?
1761
+ [COMPILING] foo v0.0.1 ([CWD])
1762
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1763
+ "# . trim ( ) ,
1764
+ ) . run ( ) ;
1765
+ }
You can’t perform that action at this time.
0 commit comments