@@ -2,6 +2,7 @@ use rustc_middle::bug;
2
2
use rustc_session:: config:: ExpectedValues ;
3
3
use rustc_session:: Session ;
4
4
use rustc_span:: edit_distance:: find_best_match_for_name;
5
+ use rustc_span:: symbol:: Ident ;
5
6
use rustc_span:: { sym, Span , Symbol } ;
6
7
7
8
use crate :: lints;
@@ -30,7 +31,7 @@ enum EscapeQuotes {
30
31
No ,
31
32
}
32
33
33
- fn to_check_cfg_arg ( name : Symbol , value : Option < Symbol > , quotes : EscapeQuotes ) -> String {
34
+ fn to_check_cfg_arg ( name : Ident , value : Option < Symbol > , quotes : EscapeQuotes ) -> String {
34
35
if let Some ( value) = value {
35
36
let value = str:: escape_debug ( value. as_str ( ) ) . to_string ( ) ;
36
37
let values = match quotes {
@@ -110,6 +111,7 @@ pub(super) fn unexpected_cfg_name(
110
111
}
111
112
} ;
112
113
114
+ let best_match = Ident :: new ( best_match, name_span) ;
113
115
if let Some ( ( value, value_span) ) = value {
114
116
if best_match_values. contains ( & Some ( value) ) {
115
117
lints:: unexpected_cfg_name:: CodeSuggestion :: SimilarNameAndValue {
@@ -163,6 +165,8 @@ pub(super) fn unexpected_cfg_name(
163
165
} ;
164
166
let expected_names = if !possibilities. is_empty ( ) {
165
167
let ( possibilities, and_more) = sort_and_truncate_possibilities ( sess, possibilities) ;
168
+ let possibilities: Vec < _ > =
169
+ possibilities. into_iter ( ) . map ( |s| Ident :: new ( s, name_span) ) . collect ( ) ;
166
170
Some ( lints:: unexpected_cfg_name:: ExpectedNames {
167
171
possibilities : possibilities. into ( ) ,
168
172
and_more,
@@ -176,7 +180,9 @@ pub(super) fn unexpected_cfg_name(
176
180
}
177
181
} ;
178
182
179
- let inst = |escape_quotes| to_check_cfg_arg ( name, value. map ( |( v, _s) | v) , escape_quotes) ;
183
+ let inst = |escape_quotes| {
184
+ to_check_cfg_arg ( Ident :: new ( name, name_span) , value. map ( |( v, _s) | v) , escape_quotes)
185
+ } ;
180
186
181
187
let invocation_help = if is_from_cargo {
182
188
let sub = if !is_feature_cfg { Some ( cargo_help_sub ( sess, & inst) ) } else { None } ;
@@ -273,7 +279,9 @@ pub(super) fn unexpected_cfg_value(
273
279
|| ( matches ! ( sess. psess. unstable_features, rustc_feature:: UnstableFeatures :: Cheat )
274
280
&& !sess. opts . unstable_opts . ui_testing ) ;
275
281
276
- let inst = |escape_quotes| to_check_cfg_arg ( name, value. map ( |( v, _s) | v) , escape_quotes) ;
282
+ let inst = |escape_quotes| {
283
+ to_check_cfg_arg ( Ident :: new ( name, name_span) , value. map ( |( v, _s) | v) , escape_quotes)
284
+ } ;
277
285
278
286
let invocation_help = if is_from_cargo {
279
287
let help = if name == sym:: feature {
0 commit comments