File tree 3 files changed +39
-2
lines changed
3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,7 @@ impl<'cfg> Workspace<'cfg> {
741
741
MaybePackage :: Package ( pkg) => pkg. manifest ( ) . warnings ( ) . warnings ( ) ,
742
742
MaybePackage :: Virtual ( vm) => vm. warnings ( ) . warnings ( ) ,
743
743
} ;
744
+ let path = path. join ( "Cargo.toml" ) ;
744
745
for warning in warnings {
745
746
if warning. is_critical {
746
747
let err = format_err ! ( "{}" , warning. message) ;
@@ -750,7 +751,14 @@ impl<'cfg> Workspace<'cfg> {
750
751
) ;
751
752
return Err ( err. context ( cx) . into ( ) ) ;
752
753
} else {
753
- self . config . shell ( ) . warn ( & warning. message ) ?
754
+ let msg = if self . root_manifest . is_none ( ) {
755
+ warning. message . to_string ( )
756
+ } else {
757
+ // In a workspace, it can be confusing where a warning
758
+ // originated, so include the path.
759
+ format ! ( "{}: {}" , path. display( ) , warning. message)
760
+ } ;
761
+ self . config . shell ( ) . warn ( msg) ?
754
762
}
755
763
}
756
764
}
Original file line number Diff line number Diff line change @@ -734,7 +734,7 @@ fn unused_keys_in_virtual_manifest() {
734
734
p. cargo ( "build --all" )
735
735
. with_stderr (
736
736
"\
737
- warning : unused manifest key: workspace.bulid
737
+ [WARNING] [..]/foo/Cargo.toml : unused manifest key: workspace.bulid
738
738
[COMPILING] bar [..]
739
739
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
740
740
" ,
Original file line number Diff line number Diff line change @@ -1969,3 +1969,32 @@ workspace: [..]/foo/Cargo.toml
1969
1969
. run ( ) ;
1970
1970
}
1971
1971
}
1972
+
1973
+ #[ test]
1974
+ fn ws_warn_path ( ) {
1975
+ // Warnings include path to manifest.
1976
+ let p = project ( )
1977
+ . file (
1978
+ "Cargo.toml" ,
1979
+ r#"
1980
+ [workspace]
1981
+ members = ["a"]
1982
+ "# ,
1983
+ )
1984
+ . file (
1985
+ "a/Cargo.toml" ,
1986
+ r#"
1987
+ cargo-features = ["edition"]
1988
+ [package]
1989
+ name = "foo"
1990
+ version = "0.1.0"
1991
+ "# ,
1992
+ )
1993
+ . file ( "a/src/lib.rs" , "" )
1994
+ . build ( ) ;
1995
+
1996
+ p. cargo ( "check" )
1997
+ . with_status ( 0 )
1998
+ . with_stderr_contains ( "[WARNING] [..]/foo/a/Cargo.toml: the cargo feature `edition`[..]" )
1999
+ . run ( ) ;
2000
+ }
You can’t perform that action at this time.
0 commit comments