1- use rustc_attr_parsing:: InstructionSetAttr ;
1+ //! Shared utilities for dealing with target features that haven't (yet) found a better home.
2+ use rustc_attr_data_structures:: InstructionSetAttr ;
23use rustc_data_structures:: fx:: FxIndexSet ;
34use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
45use rustc_errors:: Applicability ;
56use rustc_hir as hir;
67use rustc_hir:: def:: DefKind ;
78use rustc_hir:: def_id:: { DefId , LOCAL_CRATE , LocalDefId } ;
8- use rustc_middle:: middle:: codegen_fn_attrs:: TargetFeature ;
9- use rustc_middle:: query:: Providers ;
10- use rustc_middle:: ty:: TyCtxt ;
119use rustc_session:: parse:: feature_err;
1210use rustc_span:: { Span , Symbol , sym} ;
1311use rustc_target:: target_features:: { self , Stability } ;
1412
15- use crate :: errors;
13+ use crate :: error;
14+ use crate :: middle:: codegen_fn_attrs:: TargetFeature ;
15+ use crate :: query:: Providers ;
16+ use crate :: ty:: TyCtxt ;
1617
1718/// Compute the enabled target features from the `#[target_feature]` function attribute.
1819/// Enabled target features are added to `target_features`.
19- pub ( crate ) fn from_target_feature_attr (
20+ pub fn from_target_feature_attr (
2021 tcx : TyCtxt < ' _ > ,
2122 attr : & hir:: Attribute ,
2223 rust_target_features : & UnordMap < String , target_features:: Stability > ,
@@ -65,7 +66,7 @@ pub(crate) fn from_target_feature_attr(
6566 // Only allow target features whose feature gates have been enabled
6667 // and which are permitted to be toggled.
6768 if let Err ( reason) = stability. toggle_allowed ( ) {
68- tcx. dcx ( ) . emit_err ( errors :: ForbiddenTargetFeatureAttr {
69+ tcx. dcx ( ) . emit_err ( error :: ForbiddenTargetFeatureAttr {
6970 span : item. span ( ) ,
7071 feature,
7172 reason,
@@ -92,7 +93,7 @@ pub(crate) fn from_target_feature_attr(
9293 // generating code so "it's fine".
9394 if !tcx. sess . opts . actually_rustdoc {
9495 if abi_feature_constraints. incompatible . contains ( & name. as_str ( ) ) {
95- tcx. dcx ( ) . emit_err ( errors :: ForbiddenTargetFeatureAttr {
96+ tcx. dcx ( ) . emit_err ( error :: ForbiddenTargetFeatureAttr {
9697 span : item. span ( ) ,
9798 feature : name. as_str ( ) ,
9899 reason : "this feature is incompatible with the target ABI" ,
@@ -130,14 +131,12 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxIndexSet<Symbol> {
130131
131132/// Checks the function annotated with `#[target_feature]` is not a safe
132133/// trait method implementation, reporting an error if it is.
133- pub ( crate ) fn check_target_feature_trait_unsafe ( tcx : TyCtxt < ' _ > , id : LocalDefId , attr_span : Span ) {
134+ pub fn check_target_feature_trait_unsafe ( tcx : TyCtxt < ' _ > , id : LocalDefId , attr_span : Span ) {
134135 if let DefKind :: AssocFn = tcx. def_kind ( id) {
135136 let parent_id = tcx. local_parent ( id) ;
136137 if let DefKind :: Trait | DefKind :: Impl { of_trait : true } = tcx. def_kind ( parent_id) {
137- tcx. dcx ( ) . emit_err ( errors:: TargetFeatureSafeTrait {
138- span : attr_span,
139- def : tcx. def_span ( id) ,
140- } ) ;
138+ tcx. dcx ( )
139+ . emit_err ( error:: TargetFeatureSafeTrait { span : attr_span, def : tcx. def_span ( id) } ) ;
141140 }
142141 }
143142}
0 commit comments