@@ -133,53 +133,41 @@ fn verify_feature_enabled(
133
133
dash_feature_name
134
134
) ;
135
135
136
- let message = if let Some ( span) =
136
+ let ( contents , path , span ) = if let Some ( span) =
137
137
get_key_value_span ( manifest. document ( ) , & [ "lints" , "cargo" , lint_name] )
138
138
{
139
- Level :: Error
140
- . title ( & title)
141
- . snippet (
142
- Snippet :: source ( manifest. contents ( ) )
143
- . origin ( & manifest_path)
144
- . annotation ( Level :: Error . span ( span. key ) . label ( & label) )
145
- . fold ( true ) ,
146
- )
147
- . footer ( Level :: Help . title ( & help) )
139
+ ( manifest. contents ( ) , manifest_path, span)
140
+ } else if let Some ( lint_span) =
141
+ get_key_value_span ( ws_document, & [ "workspace" , "lints" , "cargo" , lint_name] )
142
+ {
143
+ ( ws_contents, ws_path, lint_span)
148
144
} else {
149
- let lint_span = get_key_value_span (
150
- ws_document,
151
- & [ "workspace" , "lints" , "cargo" , lint_name] ,
145
+ panic ! ( "could not find `cargo::{lint_name}` in `[lints]`, or `[workspace.lints]` " )
146
+ } ;
147
+
148
+ let mut message = Level :: Error
149
+ . title ( & title)
150
+ . snippet (
151
+ Snippet :: source ( contents)
152
+ . origin ( path)
153
+ . annotation ( Level :: Error . span ( span. key ) . label ( & label) )
154
+ . fold ( true ) ,
152
155
)
153
- . unwrap_or_else ( || {
154
- panic ! ( "could not find `cargo::{lint_name}` in `[lints]`, or `[workspace.lints]` " )
155
- } ) ;
156
+ . footer ( Level :: Help . title ( & help) ) ;
156
157
157
- let inherited_note = if let Some ( inherit_span) =
158
- get_key_value_span ( manifest . document ( ) , & [ "lints" , "workspace" ] )
159
- {
158
+ if let Some ( inherit_span) = get_key_value_span ( manifest . document ( ) , & [ "lints" , "workspace" ] )
159
+ {
160
+ message = message . footer (
160
161
Level :: Note . title ( & second_title) . snippet (
161
162
Snippet :: source ( manifest. contents ( ) )
162
163
. origin ( & manifest_path)
163
164
. annotation (
164
165
Level :: Note . span ( inherit_span. key . start ..inherit_span. value . end ) ,
165
166
)
166
167
. fold ( true ) ,
167
- )
168
- } else {
169
- Level :: Note . title ( & second_title)
170
- } ;
171
-
172
- Level :: Error
173
- . title ( & title)
174
- . snippet (
175
- Snippet :: source ( ws_contents)
176
- . origin ( & ws_path)
177
- . annotation ( Level :: Error . span ( lint_span. key ) . label ( & label) )
178
- . fold ( true ) ,
179
- )
180
- . footer ( Level :: Help . title ( & help) )
181
- . footer ( inherited_note)
182
- } ;
168
+ ) ,
169
+ ) ;
170
+ }
183
171
184
172
* error_count += 1 ;
185
173
gctx. shell ( ) . print_message ( message) ?;
@@ -540,59 +528,46 @@ fn output_unknown_lints(
540
528
let help =
541
529
matching. map ( |( name, kind) | format ! ( "there is a {kind} with a similar name: `{name}`" ) ) ;
542
530
543
- let mut footers = Vec :: new ( ) ;
531
+ let ( contents, path, span) = if let Some ( span) =
532
+ get_key_value_span ( manifest. document ( ) , & [ "lints" , "cargo" , lint_name] )
533
+ {
534
+ ( manifest. contents ( ) , manifest_path, span)
535
+ } else if let Some ( lint_span) =
536
+ get_key_value_span ( ws_document, & [ "workspace" , "lints" , "cargo" , lint_name] )
537
+ {
538
+ ( ws_contents, ws_path, lint_span)
539
+ } else {
540
+ panic ! ( "could not find `cargo::{lint_name}` in `[lints]`, or `[workspace.lints]` " )
541
+ } ;
542
+
543
+ let mut message = level. title ( & title) . snippet (
544
+ Snippet :: source ( contents)
545
+ . origin ( path)
546
+ . annotation ( Level :: Error . span ( span. key ) )
547
+ . fold ( true ) ,
548
+ ) ;
549
+
544
550
if emitted_source. is_none ( ) {
545
551
emitted_source = Some ( UNKNOWN_LINTS . emitted_source ( lint_level, reason) ) ;
546
- footers . push ( Level :: Note . title ( emitted_source. as_ref ( ) . unwrap ( ) ) ) ;
552
+ message = message . footer ( Level :: Note . title ( emitted_source. as_ref ( ) . unwrap ( ) ) ) ;
547
553
}
554
+
548
555
if let Some ( help) = help. as_ref ( ) {
549
- footers . push ( Level :: Help . title ( help) ) ;
556
+ message = message . footer ( Level :: Help . title ( help) ) ;
550
557
}
551
558
552
- let mut message = if let Some ( span) =
553
- get_key_value_span ( manifest. document ( ) , & [ "lints" , "cargo" , lint_name] )
559
+ if let Some ( inherit_span) = get_key_value_span ( manifest. document ( ) , & [ "lints" , "workspace" ] )
554
560
{
555
- level. title ( & title) . snippet (
556
- Snippet :: source ( manifest. contents ( ) )
557
- . origin ( & manifest_path)
558
- . annotation ( Level :: Error . span ( span. key ) )
559
- . fold ( true ) ,
560
- )
561
- } else {
562
- let lint_span = get_key_value_span (
563
- ws_document,
564
- & [ "workspace" , "lints" , "cargo" , lint_name] ,
565
- )
566
- . unwrap_or_else ( || {
567
- panic ! ( "could not find `cargo::{lint_name}` in `[lints]`, or `[workspace.lints]` " )
568
- } ) ;
569
-
570
- let inherited_note = if let Some ( inherit_span) =
571
- get_key_value_span ( manifest. document ( ) , & [ "lints" , "workspace" ] )
572
- {
561
+ message = message. footer (
573
562
Level :: Note . title ( & second_title) . snippet (
574
563
Snippet :: source ( manifest. contents ( ) )
575
564
. origin ( & manifest_path)
576
565
. annotation (
577
566
Level :: Note . span ( inherit_span. key . start ..inherit_span. value . end ) ,
578
567
)
579
568
. fold ( true ) ,
580
- )
581
- } else {
582
- Level :: Note . title ( & second_title)
583
- } ;
584
- footers. push ( inherited_note) ;
585
-
586
- level. title ( & title) . snippet (
587
- Snippet :: source ( ws_contents)
588
- . origin ( & ws_path)
589
- . annotation ( Level :: Error . span ( lint_span. key ) )
590
- . fold ( true ) ,
569
+ ) ,
591
570
)
592
- } ;
593
-
594
- for footer in footers {
595
- message = message. footer ( footer) ;
596
571
}
597
572
598
573
gctx. shell ( ) . print_message ( message) ?;
0 commit comments