File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -212,18 +212,16 @@ pub fn display_error(err: &Error, shell: &mut Shell) {
212212/// Displays a warning, with an error object providing detailed information
213213/// and context.
214214pub fn display_warning_with_error ( warning : & str , err : & Error , shell : & mut Shell ) {
215- drop ( shell. warn ( warning) ) ;
216- drop ( writeln ! ( shell. err( ) ) ) ;
215+ use annotate_snippets:: * ;
217216
218- let mut errs = error_chain ( err, shell. verbosity ( ) ) ;
219- let Some ( first) = errs. next ( ) else {
220- return ;
221- } ;
222- drop ( writeln ! ( shell. err( ) , "{first}" ) ) ;
217+ let mut group = Group :: with_title ( Level :: WARNING . primary_title ( warning) ) ;
218+
219+ let errs = error_chain ( err, shell. verbosity ( ) ) ;
223220 for err in errs {
224- drop ( writeln ! ( shell. err( ) , "\n Caused by:" ) ) ;
225- drop ( write ! ( shell. err( ) , "{}" , indented_lines( & err. to_string( ) ) ) ) ;
221+ group = group. element ( Level :: ERROR . with_name ( "caused by" ) . message ( err. to_string ( ) ) ) ;
226222 }
223+
224+ drop ( shell. print_report ( & [ group] , true ) ) ;
227225}
228226
229227fn error_chain ( err : & Error , verbosity : Verbosity ) -> impl Iterator < Item = & dyn std:: fmt:: Display > {
Original file line number Diff line number Diff line change @@ -1120,7 +1120,6 @@ fn new_warning_with_corrupt_ws() {
112011201 | asdf
11211121 | ^
11221122[WARNING] compiling this new package may not work due to invalid workspace configuration
1123-
11241123[NOTE] see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11251124
11261125"# ] ] ) . run ( ) ;
You can’t perform that action at this time.
0 commit comments