@@ -3,15 +3,7 @@ use crate::code_stats::CodeStats;
3
3
pub use crate :: code_stats:: { DataTypeKind , FieldInfo , FieldKind , SizeKind , VariantInfo } ;
4
4
use crate :: config:: Input ;
5
5
use crate :: config:: { self , CrateType , InstrumentCoverage , OptLevel , OutputType , SwitchWithOptPath } ;
6
- use crate :: errors:: {
7
- BranchProtectionRequiresAArch64 , CannotEnableCrtStaticLinux , CannotMixAndMatchSanitizers ,
8
- LinkerPluginToWindowsNotSupported , NotCircumventFeature , OptimisationFuelExhausted ,
9
- ProfileSampleUseFileDoesNotExist , ProfileUseFileDoesNotExist , SanitizerCfiEnabled ,
10
- SanitizerNotSupported , SanitizersNotSupported , SkippingConstChecks ,
11
- SplitDebugInfoUnstablePlatform , StackProtectorNotSupportedForTarget ,
12
- TargetRequiresUnwindTables , UnleashedFeatureHelp , UnstableVirtualFunctionElimination ,
13
- UnsupportedDwarfVersion ,
14
- } ;
6
+ use crate :: errors;
15
7
use crate :: parse:: { add_feature_diagnostics, ParseSess } ;
16
8
use crate :: search_paths:: { PathKind , SearchPath } ;
17
9
use crate :: { filesearch, lint} ;
@@ -246,23 +238,23 @@ impl Session {
246
238
if !unleashed_features. is_empty ( ) {
247
239
let mut must_err = false ;
248
240
// Create a diagnostic pointing at where things got unleashed.
249
- self . emit_warning ( SkippingConstChecks {
241
+ self . emit_warning ( errors :: SkippingConstChecks {
250
242
unleashed_features : unleashed_features
251
243
. iter ( )
252
244
. map ( |( span, gate) | {
253
245
gate. map ( |gate| {
254
246
must_err = true ;
255
- UnleashedFeatureHelp :: Named { span : * span, gate }
247
+ errors :: UnleashedFeatureHelp :: Named { span : * span, gate }
256
248
} )
257
- . unwrap_or ( UnleashedFeatureHelp :: Unnamed { span : * span } )
249
+ . unwrap_or ( errors :: UnleashedFeatureHelp :: Unnamed { span : * span } )
258
250
} )
259
251
. collect ( ) ,
260
252
} ) ;
261
253
262
254
// If we should err, make sure we did.
263
255
if must_err && self . has_errors ( ) . is_none ( ) {
264
256
// We have skipped a feature gate, and not run into other errors... reject.
265
- self . emit_err ( NotCircumventFeature ) ;
257
+ self . emit_err ( errors :: NotCircumventFeature ) ;
266
258
}
267
259
}
268
260
}
@@ -901,7 +893,7 @@ impl Session {
901
893
// We only call `msg` in case we can actually emit warnings.
902
894
// Otherwise, this could cause a `delay_good_path_bug` to
903
895
// trigger (issue #79546).
904
- self . emit_warning ( OptimisationFuelExhausted { msg : msg ( ) } ) ;
896
+ self . emit_warning ( errors :: OptimisationFuelExhausted { msg : msg ( ) } ) ;
905
897
}
906
898
fuel. out_of_fuel = true ;
907
899
} else if fuel. remaining > 0 {
@@ -1502,28 +1494,28 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1502
1494
&& sess. opts . cg . prefer_dynamic
1503
1495
&& sess. target . is_like_windows
1504
1496
{
1505
- sess. emit_err ( LinkerPluginToWindowsNotSupported ) ;
1497
+ sess. emit_err ( errors :: LinkerPluginToWindowsNotSupported ) ;
1506
1498
}
1507
1499
1508
1500
// Make sure that any given profiling data actually exists so LLVM can't
1509
1501
// decide to silently skip PGO.
1510
1502
if let Some ( ref path) = sess. opts . cg . profile_use {
1511
1503
if !path. exists ( ) {
1512
- sess. emit_err ( ProfileUseFileDoesNotExist { path } ) ;
1504
+ sess. emit_err ( errors :: ProfileUseFileDoesNotExist { path } ) ;
1513
1505
}
1514
1506
}
1515
1507
1516
1508
// Do the same for sample profile data.
1517
1509
if let Some ( ref path) = sess. opts . unstable_opts . profile_sample_use {
1518
1510
if !path. exists ( ) {
1519
- sess. emit_err ( ProfileSampleUseFileDoesNotExist { path } ) ;
1511
+ sess. emit_err ( errors :: ProfileSampleUseFileDoesNotExist { path } ) ;
1520
1512
}
1521
1513
}
1522
1514
1523
1515
// Unwind tables cannot be disabled if the target requires them.
1524
1516
if let Some ( include_uwtables) = sess. opts . cg . force_unwind_tables {
1525
1517
if sess. target . requires_uwtable && !include_uwtables {
1526
- sess. emit_err ( TargetRequiresUnwindTables ) ;
1518
+ sess. emit_err ( errors :: TargetRequiresUnwindTables ) ;
1527
1519
}
1528
1520
}
1529
1521
@@ -1533,67 +1525,69 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1533
1525
match unsupported_sanitizers. into_iter ( ) . count ( ) {
1534
1526
0 => { }
1535
1527
1 => {
1536
- sess. emit_err ( SanitizerNotSupported { us : unsupported_sanitizers. to_string ( ) } ) ;
1528
+ sess. emit_err ( errors :: SanitizerNotSupported { us : unsupported_sanitizers. to_string ( ) } ) ;
1537
1529
}
1538
1530
_ => {
1539
- sess. emit_err ( SanitizersNotSupported { us : unsupported_sanitizers. to_string ( ) } ) ;
1531
+ sess. emit_err ( errors:: SanitizersNotSupported {
1532
+ us : unsupported_sanitizers. to_string ( ) ,
1533
+ } ) ;
1540
1534
}
1541
1535
}
1542
1536
// Cannot mix and match sanitizers.
1543
1537
let mut sanitizer_iter = sess. opts . unstable_opts . sanitizer . into_iter ( ) ;
1544
1538
if let ( Some ( first) , Some ( second) ) = ( sanitizer_iter. next ( ) , sanitizer_iter. next ( ) ) {
1545
- sess. emit_err ( CannotMixAndMatchSanitizers {
1539
+ sess. emit_err ( errors :: CannotMixAndMatchSanitizers {
1546
1540
first : first. to_string ( ) ,
1547
1541
second : second. to_string ( ) ,
1548
1542
} ) ;
1549
1543
}
1550
1544
1551
1545
// Cannot enable crt-static with sanitizers on Linux
1552
1546
if sess. crt_static ( None ) && !sess. opts . unstable_opts . sanitizer . is_empty ( ) {
1553
- sess. emit_err ( CannotEnableCrtStaticLinux ) ;
1547
+ sess. emit_err ( errors :: CannotEnableCrtStaticLinux ) ;
1554
1548
}
1555
1549
1556
1550
// LLVM CFI and VFE both require LTO.
1557
1551
if sess. lto ( ) != config:: Lto :: Fat {
1558
1552
if sess. is_sanitizer_cfi_enabled ( ) {
1559
- sess. emit_err ( SanitizerCfiEnabled ) ;
1553
+ sess. emit_err ( errors :: SanitizerCfiEnabled ) ;
1560
1554
}
1561
1555
if sess. opts . unstable_opts . virtual_function_elimination {
1562
- sess. emit_err ( UnstableVirtualFunctionElimination ) ;
1556
+ sess. emit_err ( errors :: UnstableVirtualFunctionElimination ) ;
1563
1557
}
1564
1558
}
1565
1559
1566
1560
// LLVM CFI and KCFI are mutually exclusive
1567
1561
if sess. is_sanitizer_cfi_enabled ( ) && sess. is_sanitizer_kcfi_enabled ( ) {
1568
- sess. emit_err ( CannotMixAndMatchSanitizers {
1562
+ sess. emit_err ( errors :: CannotMixAndMatchSanitizers {
1569
1563
first : "cfi" . to_string ( ) ,
1570
1564
second : "kcfi" . to_string ( ) ,
1571
1565
} ) ;
1572
1566
}
1573
1567
1574
1568
if sess. opts . unstable_opts . stack_protector != StackProtector :: None {
1575
1569
if !sess. target . options . supports_stack_protector {
1576
- sess. emit_warning ( StackProtectorNotSupportedForTarget {
1570
+ sess. emit_warning ( errors :: StackProtectorNotSupportedForTarget {
1577
1571
stack_protector : sess. opts . unstable_opts . stack_protector ,
1578
1572
target_triple : & sess. opts . target_triple ,
1579
1573
} ) ;
1580
1574
}
1581
1575
}
1582
1576
1583
1577
if sess. opts . unstable_opts . branch_protection . is_some ( ) && sess. target . arch != "aarch64" {
1584
- sess. emit_err ( BranchProtectionRequiresAArch64 ) ;
1578
+ sess. emit_err ( errors :: BranchProtectionRequiresAArch64 ) ;
1585
1579
}
1586
1580
1587
1581
if let Some ( dwarf_version) = sess. opts . unstable_opts . dwarf_version {
1588
1582
if dwarf_version > 5 {
1589
- sess. emit_err ( UnsupportedDwarfVersion { dwarf_version } ) ;
1583
+ sess. emit_err ( errors :: UnsupportedDwarfVersion { dwarf_version } ) ;
1590
1584
}
1591
1585
}
1592
1586
1593
1587
if !sess. target . options . supported_split_debuginfo . contains ( & sess. split_debuginfo ( ) )
1594
1588
&& !sess. opts . unstable_opts . unstable_options
1595
1589
{
1596
- sess. emit_err ( SplitDebugInfoUnstablePlatform { debuginfo : sess. split_debuginfo ( ) } ) ;
1590
+ sess. emit_err ( errors :: SplitDebugInfoUnstablePlatform { debuginfo : sess. split_debuginfo ( ) } ) ;
1597
1591
}
1598
1592
}
1599
1593
0 commit comments