@@ -22,7 +22,7 @@ use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHa
2222use rustc_target:: abi:: Align ;
2323use rustc_target:: spec:: LinkSelfContainedComponents ;
2424use rustc_target:: spec:: { PanicStrategy , RelocModel , SanitizerSet , SplitDebuginfo } ;
25- use rustc_target:: spec:: { Target , TargetTriple , TargetWarnings , TARGETS } ;
25+ use rustc_target:: spec:: { Target , TargetTriple , TARGETS } ;
2626use std:: collections:: btree_map:: {
2727 Iter as BTreeMapIter , Keys as BTreeMapKeysIter , Values as BTreeMapValuesIter ,
2828} ;
@@ -1549,34 +1549,25 @@ pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg {
15491549 user_cfg
15501550}
15511551
1552- pub fn build_target_config (
1553- early_dcx : & EarlyDiagCtxt ,
1554- opts : & Options ,
1555- target_override : Option < Target > ,
1556- sysroot : & Path ,
1557- ) -> Target {
1558- let target_result = target_override. map_or_else (
1559- || Target :: search ( & opts. target_triple , sysroot) ,
1560- |t| Ok ( ( t, TargetWarnings :: empty ( ) ) ) ,
1561- ) ;
1562- let ( target, target_warnings) = target_result. unwrap_or_else ( |e| {
1563- early_dcx. early_fatal ( format ! (
1552+ pub fn build_target_config ( early_dcx : & EarlyDiagCtxt , opts : & Options , sysroot : & Path ) -> Target {
1553+ match Target :: search ( & opts. target_triple , sysroot) {
1554+ Ok ( ( target, warnings) ) => {
1555+ for warning in warnings. warning_messages ( ) {
1556+ early_dcx. early_warn ( warning)
1557+ }
1558+ if !matches ! ( target. pointer_width, 16 | 32 | 64 ) {
1559+ early_dcx. early_fatal ( format ! (
1560+ "target specification was invalid: unrecognized target-pointer-width {}" ,
1561+ target. pointer_width
1562+ ) )
1563+ }
1564+ target
1565+ }
1566+ Err ( e) => early_dcx. early_fatal ( format ! (
15641567 "Error loading target specification: {e}. \
1565- Run `rustc --print target-list` for a list of built-in targets"
1566- ) )
1567- } ) ;
1568- for warning in target_warnings. warning_messages ( ) {
1569- early_dcx. early_warn ( warning)
1570- }
1571-
1572- if !matches ! ( target. pointer_width, 16 | 32 | 64 ) {
1573- early_dcx. early_fatal ( format ! (
1574- "target specification was invalid: unrecognized target-pointer-width {}" ,
1575- target. pointer_width
1576- ) )
1568+ Run `rustc --print target-list` for a list of built-in targets"
1569+ ) ) ,
15771570 }
1578-
1579- target
15801571}
15811572
15821573#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
0 commit comments