File tree 3 files changed +126
-8
lines changed
3 files changed +126
-8
lines changed Original file line number Diff line number Diff line change @@ -658,18 +658,28 @@ impl<'cfg> Workspace<'cfg> {
658
658
for pkg in self . members ( )
659
659
. filter ( |p| p. manifest_path ( ) != root_manifest)
660
660
{
661
- if pkg. manifest ( ) . original ( ) . has_profiles ( ) {
662
- let message = & format ! (
663
- "profiles for the non root package will be ignored, \
664
- specify profiles at the workspace root:\n \
661
+ let manifest = pkg. manifest ( ) ;
662
+ let emit_warning = |what| -> CargoResult < ( ) > {
663
+ let msg = format ! (
664
+ "{} for the non root package will be ignored, \
665
+ specify {} at the workspace root:\n \
665
666
package: {}\n \
666
667
workspace: {}",
668
+ what,
669
+ what,
667
670
pkg. manifest_path( ) . display( ) ,
668
- root_manifest. display( )
671
+ root_manifest. display( ) ,
669
672
) ;
670
-
671
- //TODO: remove `Eq` bound from `Profiles` when the warning is removed.
672
- self . config . shell ( ) . warn ( & message) ?;
673
+ self . config . shell ( ) . warn ( & msg)
674
+ } ;
675
+ if manifest. original ( ) . has_profiles ( ) {
676
+ emit_warning ( "profiles" ) ?;
677
+ }
678
+ if !manifest. replace ( ) . is_empty ( ) {
679
+ emit_warning ( "replace" ) ?;
680
+ }
681
+ if !manifest. patch ( ) . is_empty ( ) {
682
+ emit_warning ( "patch" ) ?;
673
683
}
674
684
}
675
685
}
Original file line number Diff line number Diff line change @@ -1086,6 +1086,24 @@ impl TomlManifest {
1086
1086
if me. bench . is_some ( ) {
1087
1087
bail ! ( "virtual manifests do not specify [[bench]]" ) ;
1088
1088
}
1089
+ if me. dependencies . is_some ( ) {
1090
+ bail ! ( "virtual manifests do not specify [dependencies]" ) ;
1091
+ }
1092
+ if me. dev_dependencies . is_some ( ) || me. dev_dependencies2 . is_some ( ) {
1093
+ bail ! ( "virtual manifests do not specify [dev-dependencies]" ) ;
1094
+ }
1095
+ if me. build_dependencies . is_some ( ) || me. build_dependencies2 . is_some ( ) {
1096
+ bail ! ( "virtual manifests do not specify [build-dependencies]" ) ;
1097
+ }
1098
+ if me. features . is_some ( ) {
1099
+ bail ! ( "virtual manifests do not specify [features]" ) ;
1100
+ }
1101
+ if me. target . is_some ( ) {
1102
+ bail ! ( "virtual manifests do not specify [target]" ) ;
1103
+ }
1104
+ if me. badges . is_some ( ) {
1105
+ bail ! ( "virtual manifests do not specify [badges]" ) ;
1106
+ }
1089
1107
1090
1108
let mut nested_paths = Vec :: new ( ) ;
1091
1109
let mut warnings = Vec :: new ( ) ;
Original file line number Diff line number Diff line change @@ -1879,3 +1879,93 @@ fn ws_rustc_err() {
1879
1879
. with_stderr ( "[ERROR] [..]against an actual package[..]" )
1880
1880
. run ( ) ;
1881
1881
}
1882
+
1883
+ #[ test]
1884
+ fn ws_err_unused ( ) {
1885
+ for key in & [
1886
+ "[lib]" ,
1887
+ "[[bin]]" ,
1888
+ "[[example]]" ,
1889
+ "[[test]]" ,
1890
+ "[[bench]]" ,
1891
+ "[dependencies]" ,
1892
+ "[dev-dependencies]" ,
1893
+ "[build-dependencies]" ,
1894
+ "[features]" ,
1895
+ "[target]" ,
1896
+ "[badges]" ,
1897
+ ] {
1898
+ let p = project ( )
1899
+ . file (
1900
+ "Cargo.toml" ,
1901
+ & format ! (
1902
+ r#"
1903
+ [workspace]
1904
+ members = ["a"]
1905
+
1906
+ {}
1907
+ "# ,
1908
+ key
1909
+ ) ,
1910
+ )
1911
+ . file ( "a/Cargo.toml" , & basic_lib_manifest ( "a" ) )
1912
+ . file ( "a/src/lib.rs" , "" )
1913
+ . build ( ) ;
1914
+ p. cargo ( "check" )
1915
+ . with_status ( 101 )
1916
+ . with_stderr ( & format ! (
1917
+ "\
1918
+ [ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
1919
+
1920
+ Caused by:
1921
+ virtual manifests do not specify {}
1922
+ " ,
1923
+ key
1924
+ ) )
1925
+ . run ( ) ;
1926
+ }
1927
+ }
1928
+
1929
+ #[ test]
1930
+ fn ws_warn_unused ( ) {
1931
+ for ( key, name) in & [
1932
+ ( "[profile.dev]\n opt-level = 1" , "profiles" ) ,
1933
+ ( "[replace]\n \" bar:0.1.0\" = { path = \" bar\" }" , "replace" ) ,
1934
+ ( "[patch.crates-io]\n bar = { path = \" bar\" }" , "patch" ) ,
1935
+ ] {
1936
+ let p = project ( )
1937
+ . file (
1938
+ "Cargo.toml" ,
1939
+ r#"
1940
+ [workspace]
1941
+ members = ["a"]
1942
+ "# ,
1943
+ )
1944
+ . file (
1945
+ "a/Cargo.toml" ,
1946
+ & format ! (
1947
+ r#"
1948
+ [package]
1949
+ name = "a"
1950
+ version = "0.1.0"
1951
+
1952
+ {}
1953
+ "# ,
1954
+ key
1955
+ ) ,
1956
+ )
1957
+ . file ( "a/src/lib.rs" , "" )
1958
+ . build ( ) ;
1959
+ p. cargo ( "check" )
1960
+ . with_status ( 0 )
1961
+ . with_stderr_contains ( & format ! (
1962
+ "\
1963
+ [WARNING] {} for the non root package will be ignored, specify {} at the workspace root:
1964
+ package: [..]/foo/a/Cargo.toml
1965
+ workspace: [..]/foo/Cargo.toml
1966
+ " ,
1967
+ name, name
1968
+ ) )
1969
+ . run ( ) ;
1970
+ }
1971
+ }
You can’t perform that action at this time.
0 commit comments