1use rustc_attr_ir::WindowsSubsystemKind;
2use rustc_data_structures::fx::FxIndexMap;
3use rustc_feature::AttributeStability;
4use rustc_lint_defs::Reflectiveness::{NonReflective, Reflective};
5use rustc_lint_defs::ToolOptions;
6use rustc_lint_defs::builtin::{DUPLICATE_TOOLS, UNKNOWN_CRATE_TYPES};
7use rustc_session::diagnostics::feature_err;
8use rustc_span::Symbol;
9use rustc_span::edit_distance::find_best_match_for_name_with_substrings;
10use rustc_structures::CrateType;
11
12use super::prelude::*;
13use crate::diagnostics::{
14 DuplicateTool, PredefinedToolReflective, ToolReserved, UnknownCrateTypes,
15 UnknownCrateTypesSuggestion, UnrecognizedToolOption,
16};
17
18pub(crate) struct CrateNameParser;
19
20impl SingleAttributeParser for CrateNameParser {
21 const PATH: &[Symbol] = &[sym::crate_name];
22 const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError;
23 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["name"]),
docs: None,
}template!(NameValueStr: "name");
24 const ALLOWED_TARGETS: AllowedTargets<'_> =
25 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
26 const STABILITY: AttributeStability = AttributeStability::Stable;
27
28 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
29 let n = cx.expect_name_value(args, cx.attr_span, None)?;
30
31 let name = cx.expect_string_literal(n)?;
32
33 Some(AttributeKind::CrateName { name, name_span: n.value_span, attr_span: cx.attr_span })
34 }
35}
36
37pub(crate) struct CrateTypeParser;
38
39impl CombineAttributeParser for CrateTypeParser {
40 const PATH: &[Symbol] = &[sym::crate_type];
41 type Item = CrateType;
42 const CONVERT: ConvertFn<Self::Item> = |items, _| AttributeKind::CrateType(items);
43 const ALLOWED_TARGETS: AllowedTargets<'_> =
44 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
45 const TEMPLATE: AttributeTemplate =
46 crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["crate type"]),
docs: Some("https://doc.rust-lang.org/reference/linkage.html"),
}template!(NameValueStr: "crate type", "https://doc.rust-lang.org/reference/linkage.html");
47 const STABILITY: AttributeStability = AttributeStability::Stable;
48
49 fn extend(
50 cx: &mut AcceptContext<'_, '_>,
51 args: &ArgParser,
52 ) -> impl IntoIterator<Item = Self::Item> {
53 let n = cx.expect_name_value(args, cx.attr_span, None)?;
54
55 let crate_type = cx.expect_string_literal(n)?;
56
57 let Ok(crate_type) = crate_type.try_into() else {
58 if cx.shared.target == Target::Crate {
60 let candidate = find_best_match_for_name_with_substrings(
61 &CrateType::all_stable().iter().map(|(name, _)| *name).collect::<Vec<_>>(),
62 crate_type,
63 Some(5),
64 );
65 let span = n.value_span;
66 cx.emit_lint(
67 UNKNOWN_CRATE_TYPES,
68 UnknownCrateTypes {
69 sugg: candidate.map(|s| UnknownCrateTypesSuggestion { span, snippet: s }),
70 },
71 span,
72 );
73 }
74 return None;
75 };
76
77 Some(crate_type)
78 }
79}
80
81pub(crate) struct RecursionLimitParser;
82
83impl SingleAttributeParser for RecursionLimitParser {
84 const PATH: &[Symbol] = &[sym::recursion_limit];
85 const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError;
86 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["N"]),
docs: Some("https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute"),
}template!(NameValueStr: "N", "https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute");
87 const ALLOWED_TARGETS: AllowedTargets<'_> =
88 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
89 const STABILITY: AttributeStability = AttributeStability::Stable;
90
91 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
92 let nv = cx.expect_name_value(args, cx.attr_span, None)?;
93
94 Some(AttributeKind::RecursionLimit { limit: cx.parse_limit_int(nv)? })
95 }
96}
97
98pub(crate) struct MoveSizeLimitParser;
99
100impl SingleAttributeParser for MoveSizeLimitParser {
101 const PATH: &[Symbol] = &[sym::move_size_limit];
102 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["N"]),
docs: None,
}template!(NameValueStr: "N");
103 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
104 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::large_assignments;
AttributeStability::Unstable {
gate_name: rustc_span::sym::large_assignments,
notes: &[],
}
}unstable!(large_assignments);
105
106 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
107 let nv = cx.expect_name_value(args, cx.attr_span, None)?;
108
109 Some(AttributeKind::MoveSizeLimit { limit: cx.parse_limit_int(nv)? })
110 }
111}
112
113pub(crate) struct TypeLengthLimitParser;
114
115impl SingleAttributeParser for TypeLengthLimitParser {
116 const PATH: &[Symbol] = &[sym::type_length_limit];
117 const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError;
118 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["N"]),
docs: None,
}template!(NameValueStr: "N");
119 const ALLOWED_TARGETS: AllowedTargets<'_> =
120 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
121 const STABILITY: AttributeStability = AttributeStability::Stable;
122
123 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
124 let nv = cx.expect_name_value(args, cx.attr_span, None)?;
125
126 Some(AttributeKind::TypeLengthLimit { limit: cx.parse_limit_int(nv)? })
127 }
128}
129
130pub(crate) struct PatternComplexityLimitParser;
131
132impl SingleAttributeParser for PatternComplexityLimitParser {
133 const PATH: &[Symbol] = &[sym::pattern_complexity_limit];
134 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["N"]),
docs: None,
}template!(NameValueStr: "N");
135 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
136 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::rustc_attrs;
AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
notes: &["the `pattern_complexity_limit` attribute is used for rustc unit tests"],
}
}unstable!(
137 rustc_attrs,
138 "the `pattern_complexity_limit` attribute is used for rustc unit tests"
139 );
140
141 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
142 let nv = cx.expect_name_value(args, cx.attr_span, None)?;
143
144 Some(AttributeKind::PatternComplexityLimit { limit: cx.parse_limit_int(nv)? })
145 }
146}
147
148pub(crate) struct NoCoreParser;
149
150impl NoArgsAttributeParser for NoCoreParser {
151 const PATH: &[Symbol] = &[sym::no_core];
152 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
153 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::no_core;
AttributeStability::Unstable {
gate_name: rustc_span::sym::no_core,
notes: &[],
}
}unstable!(no_core);
154 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoCore;
155}
156
157pub(crate) struct NoStdParser;
158
159impl NoArgsAttributeParser for NoStdParser {
160 const PATH: &[Symbol] = &[sym::no_std];
161 const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn;
162 const ALLOWED_TARGETS: AllowedTargets<'_> =
163 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
164 const STABILITY: AttributeStability = AttributeStability::Stable;
165 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoStd;
166}
167
168pub(crate) struct NoMainParser;
169
170impl NoArgsAttributeParser for NoMainParser {
171 const PATH: &[Symbol] = &[sym::no_main];
172 const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn;
173 const ALLOWED_TARGETS: AllowedTargets<'_> =
174 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
175 const STABILITY: AttributeStability = AttributeStability::Stable;
176 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoMain;
177}
178
179pub(crate) struct RustcCoherenceIsCoreParser;
180
181impl NoArgsAttributeParser for RustcCoherenceIsCoreParser {
182 const PATH: &[Symbol] = &[sym::rustc_coherence_is_core];
183 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
184 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::rustc_attrs;
AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
notes: &[],
}
}unstable!(rustc_attrs);
185 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcCoherenceIsCore;
186}
187
188pub(crate) struct WindowsSubsystemParser;
189
190impl SingleAttributeParser for WindowsSubsystemParser {
191 const PATH: &[Symbol] = &[sym::windows_subsystem];
192 const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError;
193 const ALLOWED_TARGETS: AllowedTargets<'_> =
194 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
195 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["windows", "console"]),
docs: Some("https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute"),
}template!(NameValueStr: ["windows", "console"], "https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute");
196 const STABILITY: AttributeStability = AttributeStability::Stable;
197
198 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
199 let nv = cx.expect_name_value(args, cx.inner_span, Some(sym::windows_subsystem))?;
200
201 let kind = match nv.value_as_str() {
202 Some(sym::console) => WindowsSubsystemKind::Console,
203 Some(sym::windows) => WindowsSubsystemKind::Windows,
204 Some(_) | None => {
205 cx.adcx().expected_specific_argument_strings(
206 nv.value_span,
207 &[sym::console, sym::windows],
208 );
209 return None;
210 }
211 };
212
213 Some(AttributeKind::WindowsSubsystem(kind))
214 }
215}
216
217pub(crate) struct PanicRuntimeParser;
218
219impl NoArgsAttributeParser for PanicRuntimeParser {
220 const PATH: &[Symbol] = &[sym::panic_runtime];
221 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
222 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::panic_runtime;
AttributeStability::Unstable {
gate_name: rustc_span::sym::panic_runtime,
notes: &[],
}
}unstable!(panic_runtime);
223 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::PanicRuntime;
224}
225
226pub(crate) struct NeedsPanicRuntimeParser;
227
228impl NoArgsAttributeParser for NeedsPanicRuntimeParser {
229 const PATH: &[Symbol] = &[sym::needs_panic_runtime];
230 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
231 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::needs_panic_runtime;
AttributeStability::Unstable {
gate_name: rustc_span::sym::needs_panic_runtime,
notes: &[],
}
}unstable!(needs_panic_runtime);
232 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsPanicRuntime;
233}
234
235pub(crate) struct ProfilerRuntimeParser;
236
237impl NoArgsAttributeParser for ProfilerRuntimeParser {
238 const PATH: &[Symbol] = &[sym::profiler_runtime];
239 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
240 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::profiler_runtime;
AttributeStability::Unstable {
gate_name: rustc_span::sym::profiler_runtime,
notes: &[],
}
}unstable!(profiler_runtime);
241 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ProfilerRuntime;
242}
243
244pub(crate) struct NoBuiltinsParser;
245
246impl NoArgsAttributeParser for NoBuiltinsParser {
247 const PATH: &[Symbol] = &[sym::no_builtins];
248 const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn;
249 const ALLOWED_TARGETS: AllowedTargets<'_> =
250 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
251 const STABILITY: AttributeStability = AttributeStability::Stable;
252 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoBuiltins;
253}
254
255pub(crate) struct RustcPreserveUbChecksParser;
256
257impl NoArgsAttributeParser for RustcPreserveUbChecksParser {
258 const PATH: &[Symbol] = &[sym::rustc_preserve_ub_checks];
259 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
260 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::rustc_attrs;
AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
notes: &[],
}
}unstable!(rustc_attrs);
261 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPreserveUbChecks;
262}
263
264pub(crate) struct RustcNoImplicitBoundsParser;
265
266impl NoArgsAttributeParser for RustcNoImplicitBoundsParser {
267 const PATH: &[Symbol] = &[sym::rustc_no_implicit_bounds];
268 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
269 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::rustc_attrs;
AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
notes: &[],
}
}unstable!(rustc_attrs);
270 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitBounds;
271}
272
273pub(crate) struct DefaultLibAllocatorParser;
274
275impl NoArgsAttributeParser for DefaultLibAllocatorParser {
276 const PATH: &[Symbol] = &[sym::default_lib_allocator];
277 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
278 const STABILITY: AttributeStability = {
_ = rustc_feature::Features::allocator_internals;
AttributeStability::Unstable {
gate_name: rustc_span::sym::allocator_internals,
notes: &[],
}
}unstable!(allocator_internals);
279 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::DefaultLibAllocator;
280}
281
282pub(crate) struct FeatureParser;
283
284impl CombineAttributeParser for FeatureParser {
285 const PATH: &[Symbol] = &[sym::feature];
286 type Item = Ident;
287 const CONVERT: ConvertFn<Self::Item> = AttributeKind::Feature;
288 const ALLOWED_TARGETS: AllowedTargets<'_> =
289 AllowedTargets::AllowListWarnRest(&[Allow(Target::Crate), Error(Target::Param)]);
290 const TEMPLATE: AttributeTemplate = crate::AttributeTemplate {
word: false,
list: Some(&["feature1, feature2, ..."]),
one_of: &[],
name_value_str: None,
docs: None,
}template!(List: &["feature1, feature2, ..."]);
291 const STABILITY: AttributeStability = AttributeStability::Stable;
292
293 fn extend(
294 cx: &mut AcceptContext<'_, '_>,
295 args: &ArgParser,
296 ) -> impl IntoIterator<Item = Self::Item> {
297 let Some(list) = cx.expect_list(args, cx.attr_span) else {
298 return Vec::new();
299 };
300
301 if list.is_empty() {
302 let attr_span = cx.attr_span;
303 cx.adcx().warn_empty_attribute(attr_span);
304 }
305
306 let mut res = Vec::new();
307
308 for elem in list.mixed() {
309 let Some(elem) = elem.meta_item() else {
310 cx.adcx().expected_identifier(elem.span());
311 continue;
312 };
313 let Some(()) = cx.expect_no_args(elem.args()) else {
314 continue;
315 };
316 let path = elem.path();
317 let Some(ident) = path.word() else {
318 cx.adcx().expected_identifier(path.span());
319 continue;
320 };
321 res.push(ident);
322 }
323
324 res
325 }
326}
327
328#[derive(#[automatically_derived]impl ::core::default::Default for RegisterToolParser {
#[inline]
fn default() -> Self {
RegisterToolParser {
attr_tools: ::core::default::Default::default(),
lint_tools: ::core::default::Default::default(),
}
}
}Default)]
329pub(crate) struct RegisterToolParser {
330 attr_tools: FxIndexMap<Ident, ToolOptions>,
331 lint_tools: FxIndexMap<Ident, ToolOptions>,
332}
333
334pub const PREDEFINED_TOOLS: &[Symbol] =
335 &[sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri, sym::rust_analyzer];
336
337fn parse_register_tool(
338 tools: &mut [&mut FxIndexMap<Ident, ToolOptions>],
339 cx: &mut AcceptContext<'_, '_>,
340 args: &ArgParser,
341) {
342 let Some(list) = cx.expect_list(args, cx.attr_span) else {
343 return;
344 };
345
346 if list.is_empty() {
347 let attr_span = cx.attr_span;
348 cx.adcx().warn_empty_attribute(attr_span);
349 }
350
351 for elem in list.mixed() {
352 let Some(elem) = elem.meta_item() else {
353 cx.adcx().expected_identifier(elem.span());
354 continue;
355 };
356
357 let path = elem.path();
358 let Some(ident) = path.word() else {
359 cx.adcx().expected_identifier(path.span());
360 continue;
361 };
362 if !ident.name.can_be_raw() {
363 cx.adcx().expected_identifier(path.span());
364 continue;
365 }
366
367 if ident.name == sym::rustc {
368 cx.should_emit
369 .emit_err(cx.dcx().create_err(ToolReserved { span: ident.span, tool: ident }));
370 continue;
371 }
372
373 let reflectiveness =
374 match elem.args() {
375 ArgParser::NoArgs => NonReflective,
376 ArgParser::List(list) => 'reflect: {
377 if cx.features.is_some_and(|f| !f.type_info()) {
379 feature_err(
380 cx.sess(),
381 sym::type_info,
382 elem.span(),
383 "tool attribute options are currently unstable",
384 )
385 .emit();
386 break 'reflect NonReflective;
387 }
388
389 let Some(itm) = cx.expect_single(list) else {
390 break 'reflect NonReflective;
391 };
392
393 let Some(itm) = itm.meta_item_no_args() else {
394 cx.adcx().expected_no_args(itm.span());
395 break 'reflect NonReflective;
396 };
397
398 if !itm.path().word_is(sym::reflect) {
399 cx.should_emit.emit_err(cx.dcx().create_err(UnrecognizedToolOption {
400 span: itm.span(),
401 option: itm.path().get_attribute_path(),
402 }));
403
404 break 'reflect NonReflective;
405 }
406
407 if PREDEFINED_TOOLS.iter().any(|t| t == &ident.name) {
408 cx.should_emit.emit_err(cx.dcx().create_err(PredefinedToolReflective {
409 span: elem.span(),
410 tool: ident,
411 }));
412
413 break 'reflect NonReflective;
414 }
415
416 Reflective
417 }
418 ArgParser::NameValue(_) => {
419 cx.adcx().expected_list_or_no_args(elem.span());
420 NonReflective
421 }
422 };
423
424 let mut lint_emitted = false;
425 for tools in tools.iter_mut() {
426 let opts = if let Some((old_ident, old_opts)) = tools.get_key_value(&ident)
427 && !lint_emitted
428 {
429 lint_emitted = true;
430 cx.emit_lint(
431 DUPLICATE_TOOLS,
432 DuplicateTool { span: ident.span, tool: ident, old_ident_span: old_ident.span },
433 ident.span,
434 );
435
436 old_opts.union(ToolOptions { reflectiveness })
437 } else {
438 ToolOptions { reflectiveness }
439 };
440
441 tools.insert(ident, opts);
442 }
443 }
444}
445
446impl AttributeParser for RegisterToolParser {
447 const ATTRIBUTES: AcceptMapping<Self> = &[
448 (
449 &[sym::register_tool],
450 crate::AttributeTemplate {
word: false,
list: Some(&["tool1, tool2(reflect), ..."]),
one_of: &[],
name_value_str: None,
docs: None,
}template!(List: &["tool1, tool2(reflect), ..."]),
451 {
_ = rustc_feature::Features::register_tool;
AttributeStability::Unstable {
gate_name: rustc_span::sym::register_tool,
notes: &[],
}
}unstable!(register_tool),
452 |this, cx, args| {
453 parse_register_tool(&mut [&mut this.attr_tools, &mut this.lint_tools], cx, args)
454 },
455 ),
456 (
457 &[sym::register_attribute_tool],
458 crate::AttributeTemplate {
word: false,
list: Some(&["tool1, tool2(reflect), ..."]),
one_of: &[],
name_value_str: None,
docs: None,
}template!(List: &["tool1, tool2(reflect), ..."]),
459 {
_ = rustc_feature::Features::register_tool;
AttributeStability::Unstable {
gate_name: rustc_span::sym::register_tool,
notes: &[],
}
}unstable!(register_tool),
460 |this, cx, args| parse_register_tool(&mut [&mut this.attr_tools], cx, args),
461 ),
462 (
463 &[sym::register_lint_tool],
464 crate::AttributeTemplate {
word: false,
list: Some(&["tool1, tool2(reflect), ..."]),
one_of: &[],
name_value_str: None,
docs: None,
}template!(List: &["tool1, tool2(reflect), ..."]),
465 {
_ = rustc_feature::Features::register_tool;
AttributeStability::Unstable {
gate_name: rustc_span::sym::register_tool,
notes: &[],
}
}unstable!(register_tool),
466 |this, cx, args| parse_register_tool(&mut [&mut this.lint_tools], cx, args),
467 ),
468 ];
469
470 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
471
472 fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
473 if self.attr_tools.is_empty() && self.lint_tools.is_empty() {
474 None
475 } else {
476 Some(AttributeKind::RegisterTool {
477 attr_tools: self.attr_tools.into_iter().collect(),
478 lint_tools: self.lint_tools.into_iter().collect(),
479 })
480 }
481 }
482}