@@ -673,7 +673,7 @@ impl DiagCtxt {
673
673
let key = ( span. with_parent ( None ) , key) ;
674
674
675
675
if diag. is_error ( ) {
676
- if matches ! ( diag. level, Level :: Error { lint: true } ) {
676
+ if matches ! ( diag. level, Error { lint: true } ) {
677
677
inner. lint_err_count += 1 ;
678
678
} else {
679
679
inner. err_count += 1 ;
@@ -697,7 +697,7 @@ impl DiagCtxt {
697
697
let key = ( span. with_parent ( None ) , key) ;
698
698
let diag = inner. stashed_diagnostics . remove ( & key) ?;
699
699
if diag. is_error ( ) {
700
- if matches ! ( diag. level, Level :: Error { lint: true } ) {
700
+ if matches ! ( diag. level, Error { lint: true } ) {
701
701
inner. lint_err_count -= 1 ;
702
702
} else {
703
703
inner. err_count -= 1 ;
@@ -759,14 +759,14 @@ impl DiagCtxt {
759
759
#[ rustc_lint_diagnostics]
760
760
#[ track_caller]
761
761
pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
762
- DiagnosticBuilder :: new ( self , Level :: Warning ( None ) , msg)
762
+ DiagnosticBuilder :: new ( self , Warning ( None ) , msg)
763
763
}
764
764
765
765
/// Construct a builder at the `Allow` level with the `msg`.
766
766
#[ rustc_lint_diagnostics]
767
767
#[ track_caller]
768
768
pub fn struct_allow ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
769
- DiagnosticBuilder :: new ( self , Level :: Allow , msg)
769
+ DiagnosticBuilder :: new ( self , Allow , msg)
770
770
}
771
771
772
772
/// Construct a builder at the `Expect` level with the `msg`.
@@ -777,7 +777,7 @@ impl DiagCtxt {
777
777
msg : impl Into < DiagnosticMessage > ,
778
778
id : LintExpectationId ,
779
779
) -> DiagnosticBuilder < ' _ , ( ) > {
780
- DiagnosticBuilder :: new ( self , Level :: Expect ( id) , msg)
780
+ DiagnosticBuilder :: new ( self , Expect ( id) , msg)
781
781
}
782
782
783
783
/// Construct a builder at the `Error` level at the given `span` and with the `msg`.
@@ -812,7 +812,7 @@ impl DiagCtxt {
812
812
#[ rustc_lint_diagnostics]
813
813
#[ track_caller]
814
814
pub fn struct_err ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ > {
815
- DiagnosticBuilder :: new ( self , Level :: Error { lint : false } , msg)
815
+ DiagnosticBuilder :: new ( self , Error { lint : false } , msg)
816
816
}
817
817
818
818
/// Construct a builder at the `Error` level with the `msg` and the `code`.
@@ -875,7 +875,7 @@ impl DiagCtxt {
875
875
& self ,
876
876
msg : impl Into < DiagnosticMessage > ,
877
877
) -> DiagnosticBuilder < ' _ , FatalAbort > {
878
- DiagnosticBuilder :: new ( self , Level :: Fatal , msg)
878
+ DiagnosticBuilder :: new ( self , Fatal , msg)
879
879
}
880
880
881
881
/// Construct a builder at the `Fatal` level with the `msg`, that doesn't abort.
@@ -885,27 +885,27 @@ impl DiagCtxt {
885
885
& self ,
886
886
msg : impl Into < DiagnosticMessage > ,
887
887
) -> DiagnosticBuilder < ' _ , FatalError > {
888
- DiagnosticBuilder :: new ( self , Level :: Fatal , msg)
888
+ DiagnosticBuilder :: new ( self , Fatal , msg)
889
889
}
890
890
891
891
/// Construct a builder at the `Help` level with the `msg`.
892
892
#[ rustc_lint_diagnostics]
893
893
pub fn struct_help ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
894
- DiagnosticBuilder :: new ( self , Level :: Help , msg)
894
+ DiagnosticBuilder :: new ( self , Help , msg)
895
895
}
896
896
897
897
/// Construct a builder at the `Note` level with the `msg`.
898
898
#[ rustc_lint_diagnostics]
899
899
#[ track_caller]
900
900
pub fn struct_note ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
901
- DiagnosticBuilder :: new ( self , Level :: Note , msg)
901
+ DiagnosticBuilder :: new ( self , Note , msg)
902
902
}
903
903
904
904
/// Construct a builder at the `Bug` level with the `msg`.
905
905
#[ rustc_lint_diagnostics]
906
906
#[ track_caller]
907
907
pub fn struct_bug ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , BugAbort > {
908
- DiagnosticBuilder :: new ( self , Level :: Bug , msg)
908
+ DiagnosticBuilder :: new ( self , Bug , msg)
909
909
}
910
910
911
911
/// Construct a builder at the `Bug` level at the given `span` with the `msg`.
@@ -995,7 +995,7 @@ impl DiagCtxt {
995
995
// FIXME: don't abort here if report_delayed_bugs is off
996
996
self . span_bug ( sp, msg) ;
997
997
}
998
- let mut diagnostic = Diagnostic :: new ( Level :: DelayedBug , msg) ;
998
+ let mut diagnostic = Diagnostic :: new ( DelayedBug , msg) ;
999
999
diagnostic. set_span ( sp) ;
1000
1000
self . emit_diagnostic ( diagnostic) . unwrap ( )
1001
1001
}
@@ -1005,7 +1005,7 @@ impl DiagCtxt {
1005
1005
pub fn good_path_delayed_bug ( & self , msg : impl Into < DiagnosticMessage > ) {
1006
1006
let mut inner = self . inner . borrow_mut ( ) ;
1007
1007
1008
- let mut diagnostic = Diagnostic :: new ( Level :: DelayedBug , msg) ;
1008
+ let mut diagnostic = Diagnostic :: new ( DelayedBug , msg) ;
1009
1009
if inner. flags . report_delayed_bugs {
1010
1010
inner. emit_diagnostic_without_consuming ( & mut diagnostic) ;
1011
1011
}
@@ -1118,10 +1118,9 @@ impl DiagCtxt {
1118
1118
1119
1119
match ( errors. len ( ) , warnings. len ( ) ) {
1120
1120
( 0 , 0 ) => return ,
1121
- ( 0 , _) => inner. emitter . emit_diagnostic ( & Diagnostic :: new (
1122
- Level :: Warning ( None ) ,
1123
- DiagnosticMessage :: Str ( warnings) ,
1124
- ) ) ,
1121
+ ( 0 , _) => inner
1122
+ . emitter
1123
+ . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1125
1124
( _, 0 ) => {
1126
1125
inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
1127
1126
}
@@ -1210,14 +1209,14 @@ impl DiagCtxt {
1210
1209
1211
1210
#[ track_caller]
1212
1211
pub fn create_err < ' a > ( & ' a self , err : impl IntoDiagnostic < ' a > ) -> DiagnosticBuilder < ' a > {
1213
- err. into_diagnostic ( self , Level :: Error { lint : false } )
1212
+ err. into_diagnostic ( self , Error { lint : false } )
1214
1213
}
1215
1214
1216
1215
pub fn create_warning < ' a > (
1217
1216
& ' a self ,
1218
1217
warning : impl IntoDiagnostic < ' a , ( ) > ,
1219
1218
) -> DiagnosticBuilder < ' a , ( ) > {
1220
- warning. into_diagnostic ( self , Level :: Warning ( None ) )
1219
+ warning. into_diagnostic ( self , Warning ( None ) )
1221
1220
}
1222
1221
1223
1222
pub fn emit_warning < ' a > ( & ' a self , warning : impl IntoDiagnostic < ' a , ( ) > ) {
@@ -1228,7 +1227,7 @@ impl DiagCtxt {
1228
1227
& ' a self ,
1229
1228
fatal : impl IntoDiagnostic < ' a , FatalError > ,
1230
1229
) -> DiagnosticBuilder < ' a , FatalError > {
1231
- fatal. into_diagnostic ( self , Level :: Fatal )
1230
+ fatal. into_diagnostic ( self , Fatal )
1232
1231
}
1233
1232
1234
1233
pub fn emit_almost_fatal < ' a > (
@@ -1242,7 +1241,7 @@ impl DiagCtxt {
1242
1241
& ' a self ,
1243
1242
fatal : impl IntoDiagnostic < ' a , FatalAbort > ,
1244
1243
) -> DiagnosticBuilder < ' a , FatalAbort > {
1245
- fatal. into_diagnostic ( self , Level :: Fatal )
1244
+ fatal. into_diagnostic ( self , Fatal )
1246
1245
}
1247
1246
1248
1247
pub fn emit_fatal < ' a > ( & ' a self , fatal : impl IntoDiagnostic < ' a , FatalAbort > ) -> ! {
@@ -1253,7 +1252,7 @@ impl DiagCtxt {
1253
1252
& ' a self ,
1254
1253
bug : impl IntoDiagnostic < ' a , BugAbort > ,
1255
1254
) -> DiagnosticBuilder < ' a , BugAbort > {
1256
- bug. into_diagnostic ( self , Level :: Bug )
1255
+ bug. into_diagnostic ( self , Bug )
1257
1256
}
1258
1257
1259
1258
pub fn emit_bug < ' a > ( & ' a self , bug : impl IntoDiagnostic < ' a , BugAbort > ) -> ! {
@@ -1268,7 +1267,7 @@ impl DiagCtxt {
1268
1267
& ' a self ,
1269
1268
note : impl IntoDiagnostic < ' a , ( ) > ,
1270
1269
) -> DiagnosticBuilder < ' a , ( ) > {
1271
- note. into_diagnostic ( self , Level :: Note )
1270
+ note. into_diagnostic ( self , Note )
1272
1271
}
1273
1272
1274
1273
pub fn emit_artifact_notification ( & self , path : & Path , artifact_type : & str ) {
@@ -1355,7 +1354,7 @@ impl DiagCtxtInner {
1355
1354
for diag in diags {
1356
1355
// Decrement the count tracking the stash; emitting will increment it.
1357
1356
if diag. is_error ( ) {
1358
- if matches ! ( diag. level, Level :: Error { lint: true } ) {
1357
+ if matches ! ( diag. level, Error { lint: true } ) {
1359
1358
self . lint_err_count -= 1 ;
1360
1359
} else {
1361
1360
self . err_count -= 1 ;
@@ -1386,9 +1385,8 @@ impl DiagCtxtInner {
1386
1385
& mut self ,
1387
1386
diagnostic : & mut Diagnostic ,
1388
1387
) -> Option < ErrorGuaranteed > {
1389
- if matches ! ( diagnostic. level, Level :: Error { .. } | Level :: Fatal ) && self . treat_err_as_bug ( )
1390
- {
1391
- diagnostic. level = Level :: Bug ;
1388
+ if matches ! ( diagnostic. level, Error { .. } | Fatal ) && self . treat_err_as_bug ( ) {
1389
+ diagnostic. level = Bug ;
1392
1390
}
1393
1391
1394
1392
// The `LintExpectationId` can be stable or unstable depending on when it was created.
@@ -1400,7 +1398,7 @@ impl DiagCtxtInner {
1400
1398
return None ;
1401
1399
}
1402
1400
1403
- if diagnostic. level == Level :: DelayedBug {
1401
+ if diagnostic. level == DelayedBug {
1404
1402
// FIXME(eddyb) this should check for `has_errors` and stop pushing
1405
1403
// once *any* errors were emitted (and truncate `span_delayed_bugs`
1406
1404
// when an error is first emitted, also), but maybe there's a case
@@ -1416,7 +1414,7 @@ impl DiagCtxtInner {
1416
1414
}
1417
1415
1418
1416
if diagnostic. has_future_breakage ( ) {
1419
- // Future breakages aren't emitted if they're Level::Allowed ,
1417
+ // Future breakages aren't emitted if they're Level::Allow ,
1420
1418
// but they still need to be constructed and stashed below,
1421
1419
// so they'll trigger the good-path bug check.
1422
1420
self . suppressed_expected_diag = true ;
@@ -1438,7 +1436,7 @@ impl DiagCtxtInner {
1438
1436
return None ;
1439
1437
}
1440
1438
1441
- if matches ! ( diagnostic. level, Level :: Expect ( _) | Level :: Allow ) {
1439
+ if matches ! ( diagnostic. level, Expect ( _) | Allow ) {
1442
1440
( * TRACK_DIAGNOSTICS ) ( diagnostic, & mut |_| { } ) ;
1443
1441
return None ;
1444
1442
}
@@ -1463,7 +1461,7 @@ impl DiagCtxtInner {
1463
1461
debug ! ( ?self . emitted_diagnostics) ;
1464
1462
let already_emitted_sub = |sub : & mut SubDiagnostic | {
1465
1463
debug ! ( ?sub) ;
1466
- if sub. level != Level :: OnceNote && sub. level != Level :: OnceHelp {
1464
+ if sub. level != OnceNote && sub. level != OnceHelp {
1467
1465
return false ;
1468
1466
}
1469
1467
let mut hasher = StableHasher :: new ( ) ;
@@ -1488,7 +1486,7 @@ impl DiagCtxtInner {
1488
1486
}
1489
1487
}
1490
1488
if diagnostic. is_error ( ) {
1491
- if matches ! ( diagnostic. level, Level :: Error { lint: true } ) {
1489
+ if matches ! ( diagnostic. level, Error { lint: true } ) {
1492
1490
self . bump_lint_err_count ( ) ;
1493
1491
} else {
1494
1492
self . bump_err_count ( ) ;
@@ -1568,15 +1566,15 @@ impl DiagCtxtInner {
1568
1566
if backtrace || self . ice_file . is_none ( ) { bug. decorate ( ) } else { bug. inner } ;
1569
1567
1570
1568
// "Undelay" the `DelayedBug`s (into plain `Bug`s).
1571
- if bug. level != Level :: DelayedBug {
1569
+ if bug. level != DelayedBug {
1572
1570
// NOTE(eddyb) not panicking here because we're already producing
1573
1571
// an ICE, and the more information the merrier.
1574
1572
bug. subdiagnostic ( InvalidFlushedDelayedDiagnosticLevel {
1575
1573
span : bug. span . primary_span ( ) . unwrap ( ) ,
1576
1574
level : bug. level ,
1577
1575
} ) ;
1578
1576
}
1579
- bug. level = Level :: Bug ;
1577
+ bug. level = Bug ;
1580
1578
1581
1579
self . emit_diagnostic ( bug) ;
1582
1580
}
@@ -1783,7 +1781,7 @@ impl Level {
1783
1781
1784
1782
pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
1785
1783
match self {
1786
- Level :: Expect ( id) | Level :: Warning ( Some ( id) ) => Some ( * id) ,
1784
+ Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1787
1785
_ => None ,
1788
1786
}
1789
1787
}
0 commit comments