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) {
212
212
/// Displays a warning, with an error object providing detailed information
213
213
/// and context.
214
214
pub 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:: * ;
217
216
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 ( ) ) ;
223
220
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 ( ) ) ) ;
226
222
}
223
+
224
+ drop ( shell. print_report ( & [ group] , true ) ) ;
227
225
}
228
226
229
227
fn 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() {
1120
1120
1 | asdf
1121
1121
| ^
1122
1122
[WARNING] compiling this new package may not work due to invalid workspace configuration
1123
-
1124
1123
[NOTE] see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1125
1124
1126
1125
"# ] ] ) . run ( ) ;
You can’t perform that action at this time.
0 commit comments