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 ;
2
3
use rustc_data_structures:: fx:: FxIndexSet ;
3
4
use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
4
5
use rustc_errors:: Applicability ;
5
6
use rustc_hir as hir;
6
7
use rustc_hir:: def:: DefKind ;
7
8
use 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 ;
11
9
use rustc_session:: parse:: feature_err;
12
10
use rustc_span:: { Span , Symbol , sym} ;
13
11
use rustc_target:: target_features:: { self , Stability } ;
14
12
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 ;
16
17
17
18
/// Compute the enabled target features from the `#[target_feature]` function attribute.
18
19
/// Enabled target features are added to `target_features`.
19
- pub ( crate ) fn from_target_feature_attr (
20
+ pub fn from_target_feature_attr (
20
21
tcx : TyCtxt < ' _ > ,
21
22
attr : & hir:: Attribute ,
22
23
rust_target_features : & UnordMap < String , target_features:: Stability > ,
@@ -65,7 +66,7 @@ pub(crate) fn from_target_feature_attr(
65
66
// Only allow target features whose feature gates have been enabled
66
67
// and which are permitted to be toggled.
67
68
if let Err ( reason) = stability. toggle_allowed ( ) {
68
- tcx. dcx ( ) . emit_err ( errors :: ForbiddenTargetFeatureAttr {
69
+ tcx. dcx ( ) . emit_err ( error :: ForbiddenTargetFeatureAttr {
69
70
span : item. span ( ) ,
70
71
feature,
71
72
reason,
@@ -92,7 +93,7 @@ pub(crate) fn from_target_feature_attr(
92
93
// generating code so "it's fine".
93
94
if !tcx. sess . opts . actually_rustdoc {
94
95
if abi_feature_constraints. incompatible . contains ( & name. as_str ( ) ) {
95
- tcx. dcx ( ) . emit_err ( errors :: ForbiddenTargetFeatureAttr {
96
+ tcx. dcx ( ) . emit_err ( error :: ForbiddenTargetFeatureAttr {
96
97
span : item. span ( ) ,
97
98
feature : name. as_str ( ) ,
98
99
reason : "this feature is incompatible with the target ABI" ,
@@ -130,14 +131,12 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxIndexSet<Symbol> {
130
131
131
132
/// Checks the function annotated with `#[target_feature]` is not a safe
132
133
/// 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 ) {
134
135
if let DefKind :: AssocFn = tcx. def_kind ( id) {
135
136
let parent_id = tcx. local_parent ( id) ;
136
137
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) } ) ;
141
140
}
142
141
}
143
142
}
0 commit comments