@@ -12,7 +12,10 @@ use rustc_span::{DUMMY_SP, Span, Symbol};
12
12
use rustc_target:: abi:: call:: { FnAbi , PassMode } ;
13
13
use rustc_target:: abi:: { BackendRepr , RegKind } ;
14
14
15
- use crate :: errors:: { AbiErrorDisabledVectorTypeCall , AbiErrorDisabledVectorTypeDef } ;
15
+ use crate :: errors:: {
16
+ AbiErrorDisabledVectorTypeCall , AbiErrorDisabledVectorTypeDef ,
17
+ AbiErrorUnsupportedVectorTypeCall , AbiErrorUnsupportedVectorTypeDef ,
18
+ } ;
16
19
17
20
fn uses_vector_registers ( mode : & PassMode , repr : & BackendRepr ) -> bool {
18
21
match mode {
@@ -29,7 +32,7 @@ fn do_check_abi<'tcx>(
29
32
tcx : TyCtxt < ' tcx > ,
30
33
abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
31
34
target_feature_def : DefId ,
32
- mut emit_err : impl FnMut ( & ' static str ) ,
35
+ mut emit_err : impl FnMut ( Option < & ' static str > ) ,
33
36
) {
34
37
let Some ( feature_def) = tcx. sess . target . features_for_correct_vector_abi ( ) else {
35
38
return ;
@@ -42,15 +45,15 @@ fn do_check_abi<'tcx>(
42
45
let feature = match feature_def. iter ( ) . find ( |( bits, _) | size. bits ( ) <= * bits) {
43
46
Some ( ( _, feature) ) => feature,
44
47
None => {
45
- emit_err ( "<no available feature for this size>" ) ;
48
+ emit_err ( None ) ;
46
49
continue ;
47
50
}
48
51
} ;
49
52
let feature_sym = Symbol :: intern ( feature) ;
50
53
if !tcx. sess . unstable_target_features . contains ( & feature_sym)
51
54
&& !codegen_attrs. target_features . iter ( ) . any ( |x| x. name == feature_sym)
52
55
{
53
- emit_err ( feature) ;
56
+ emit_err ( Some ( & feature) ) ;
54
57
}
55
58
}
56
59
}
@@ -67,12 +70,21 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
67
70
} ;
68
71
do_check_abi ( tcx, abi, instance. def_id ( ) , |required_feature| {
69
72
let span = tcx. def_span ( instance. def_id ( ) ) ;
70
- tcx. emit_node_span_lint (
71
- ABI_UNSUPPORTED_VECTOR_TYPES ,
72
- CRATE_HIR_ID ,
73
- span,
74
- AbiErrorDisabledVectorTypeDef { span, required_feature } ,
75
- ) ;
73
+ if let Some ( required_feature) = required_feature {
74
+ tcx. emit_node_span_lint (
75
+ ABI_UNSUPPORTED_VECTOR_TYPES ,
76
+ CRATE_HIR_ID ,
77
+ span,
78
+ AbiErrorDisabledVectorTypeDef { span, required_feature } ,
79
+ ) ;
80
+ } else {
81
+ tcx. emit_node_span_lint (
82
+ ABI_UNSUPPORTED_VECTOR_TYPES ,
83
+ CRATE_HIR_ID ,
84
+ span,
85
+ AbiErrorUnsupportedVectorTypeDef { span } ,
86
+ ) ;
87
+ }
76
88
} )
77
89
}
78
90
@@ -111,12 +123,21 @@ fn check_call_site_abi<'tcx>(
111
123
return ;
112
124
} ;
113
125
do_check_abi ( tcx, callee_abi, caller. def_id ( ) , |required_feature| {
114
- tcx. emit_node_span_lint (
115
- ABI_UNSUPPORTED_VECTOR_TYPES ,
116
- CRATE_HIR_ID ,
117
- span,
118
- AbiErrorDisabledVectorTypeCall { span, required_feature } ,
119
- ) ;
126
+ if let Some ( required_feature) = required_feature {
127
+ tcx. emit_node_span_lint (
128
+ ABI_UNSUPPORTED_VECTOR_TYPES ,
129
+ CRATE_HIR_ID ,
130
+ span,
131
+ AbiErrorDisabledVectorTypeCall { span, required_feature } ,
132
+ ) ;
133
+ } else {
134
+ tcx. emit_node_span_lint (
135
+ ABI_UNSUPPORTED_VECTOR_TYPES ,
136
+ CRATE_HIR_ID ,
137
+ span,
138
+ AbiErrorUnsupportedVectorTypeCall { span } ,
139
+ ) ;
140
+ }
120
141
} ) ;
121
142
}
122
143
0 commit comments