Skip to main content

clippy_utils/
sym.rs

1#![expect(non_upper_case_globals)]
2
3#[doc(no_inline)]
4pub use rustc_span::sym::*;
5
6macro_rules! val {
7    ($name:ident) => {
8        stringify!($name)
9    };
10    ($name:ident $value:literal) => {
11        $value
12    };
13}
14
15macro_rules! generate {
16    ($($name:ident $(: $value:literal)? ,)*) => {
17        /// To be supplied to `rustc_interface::Config`
18        pub const EXTRA_SYMBOLS: &[&str] = &[
19            $(
20                val!($name $($value)?),
21            )*
22        ];
23
24        mod clippy_symbols {
25            use rustc_span::{Symbol, symbol::PREDEFINED_SYMBOLS_COUNT};
26            $(
27                pub const $name: Symbol = Symbol::new(PREDEFINED_SYMBOLS_COUNT + ${index()});
28            )*
29        }
30
31        $(
32            pub use clippy_symbols::$name;
33        )*
34
35        #[allow(unused_imports)]
36        // Check that we don't have duplicate symbols with rustc.
37        // It's still checked by rustc's driver (at runtime) regardless,
38        // but it's nicer to fail at compile time instead.
39        const _: () = {
40            use rustc_span::sym::*; // First, glob import all of rustc's symbols
41            use clippy_symbols::*; // Then, glob import all of clippy's symbols
42            use { $($name),* }; // If a symbol is in both, an ambiguity error is raised
43        };
44    };
45}
46
47// List of extra symbols to be included in Clippy (for example, as `sym::ambiguous_glob_reexports`).
48// An alternative content can be specified using a colon after the symbol name.
49//
50// `cargo dev fmt` ensures that the content of the `generate!()` macro call stays sorted.
51generate! {
52    Any,
53    Applicability,
54    ArrayIntoIter,
55    AsyncReadExt,
56    AsyncWriteExt,
57    BACKSLASH_SINGLE_QUOTE: r"\'",
58    BITS,
59    BTreeEntry,
60    BTreeSet,
61    Binary,
62    BinaryHeap,
63    CLIPPY_ARGS,
64    CLIPPY_CONF_DIR,
65    CRLF: "\r\n",
66    Cargo_toml: "Cargo.toml",
67    Child,
68    Command,
69    Current,
70    DOUBLE_QUOTE: "\"",
71    DebugStruct,
72    Deserialize,
73    DirBuilder,
74    DoubleEndedIterator,
75    Duration,
76    EarlyContext,
77    EarlyLintPass,
78    Enumerate,
79    Error,
80    File,
81    FileType,
82    FromStr,
83    FsOpenOptions,
84    FsPermissions,
85    HashMapEntry,
86    Instant,
87    IntoIter,
88    IoBufRead,
89    IoLines,
90    IoRead,
91    IoSeek,
92    IoWrite,
93    IpAddr,
94    Ipv4Addr,
95    Ipv6Addr,
96    IterEmpty,
97    IterOnce,
98    IterPeekable,
99    Itertools,
100    LF: "\n",
101    LateContext,
102    Lazy,
103    LinkedList,
104    Lint,
105    LowerExp,
106    LowerHex,
107    MAX,
108    MIN,
109    MaybeDef,
110    MpmcReceiver,
111    MpscReceiver,
112    MsrvStack,
113    Octal,
114    OpenOptions,
115    OsStr,
116    OsString,
117    Path,
118    PathBuf,
119    PathLookup,
120    PhantomPinned,
121    RangeBounds,
122    RefCellRef,
123    RefCellRefMut,
124    Regex,
125    RegexBuilder,
126    RegexSet,
127    Saturating,
128    SeekFrom,
129    SliceIter,
130    Start,
131    Stdin,
132    Symbol,
133    SyntaxContext,
134    TBD,
135    ToOwned,
136    ToString,
137    UpperExp,
138    UpperHex,
139    V4,
140    V6,
141    VecDeque,
142    Visitor,
143    Wake,
144    Waker,
145    Weak,
146    Wrapping,
147    abs,
148    allow_attributes,
149    ambiguous_glob_reexports,
150    app,
151    append,
152    applicability,
153    arg,
154    as_bytes,
155    as_deref,
156    as_deref_mut,
157    as_mut,
158    as_mut_ptr,
159    as_mut_slice,
160    as_path,
161    as_slice,
162    as_str,
163    assert_failed,
164    assert_matches,
165    author,
166    back,
167    binary_heap_pop_if,
168    binaryheap_iter,
169    bool_then,
170    borrow,
171    borrow_mut,
172    box_assume_init_into_vec_unsafe,
173    btreemap_contains_key,
174    btreemap_insert,
175    btreeset_iter,
176    build_hasher,
177    by_ref,
178    bytes,
179    capacity,
180    cargo_clippy: "cargo-clippy",
181    cast,
182    cast_const,
183    cast_mut,
184    ceil_char_boundary,
185    chain,
186    char_is_ascii,
187    char_to_digit,
188    chars,
189    check_attributes,
190    checked_abs,
191    checked_add,
192    checked_isqrt,
193    checked_mul,
194    checked_pow,
195    checked_rem_euclid,
196    checked_sub,
197    child_id,
198    child_kill,
199    chunks_exact,
200    chunks_exact_mut,
201    clamp,
202    clippy_utils,
203    clone_into,
204    cloned,
205    cmp_max,
206    cmp_min,
207    cognitive_complexity,
208    collapsible_else_if,
209    collapsible_if,
210    collect,
211    const_ptr,
212    contains,
213    convert_identity,
214    copied,
215    copy_from,
216    copy_from_nonoverlapping,
217    copy_to,
218    copy_to_nonoverlapping,
219    core_arch,
220    core_panic_2021_macro,
221    count_ones,
222    create,
223    create_new,
224    cstring_as_c_str,
225    cx,
226    cycle,
227    cyclomatic_complexity,
228    dbg_macro,
229    de,
230    debug_assert_matches,
231    debug_struct,
232    deprecated_in_future,
233    deref_mut_method,
234    diagnostics,
235    disallowed_types,
236    drain,
237    dump,
238    duration_constructors,
239    ends_with,
240    enum_glob_use,
241    enumerate,
242    enumerate_method,
243    eprint,
244    eprintln,
245    err,
246    expect_err,
247    expn_data,
248    exported_private_dependencies,
249    extend,
250    f128_consts_mod,
251    f128_epsilon,
252    f16_consts_mod,
253    f16_epsilon,
254    f32_consts_mod,
255    f32_epsilon,
256    f32_legacy_const_digits,
257    f32_legacy_const_epsilon,
258    f32_legacy_const_infinity,
259    f32_legacy_const_mantissa_dig,
260    f32_legacy_const_max,
261    f32_legacy_const_max_10_exp,
262    f32_legacy_const_max_exp,
263    f32_legacy_const_min,
264    f32_legacy_const_min_10_exp,
265    f32_legacy_const_min_exp,
266    f32_legacy_const_min_positive,
267    f32_legacy_const_nan,
268    f32_legacy_const_neg_infinity,
269    f32_legacy_const_radix,
270    f64_consts_mod,
271    f64_epsilon,
272    f64_legacy_const_digits,
273    f64_legacy_const_epsilon,
274    f64_legacy_const_infinity,
275    f64_legacy_const_mantissa_dig,
276    f64_legacy_const_max,
277    f64_legacy_const_max_10_exp,
278    f64_legacy_const_max_exp,
279    f64_legacy_const_min,
280    f64_legacy_const_min_10_exp,
281    f64_legacy_const_min_exp,
282    f64_legacy_const_min_positive,
283    f64_legacy_const_nan,
284    f64_legacy_const_neg_infinity,
285    f64_legacy_const_radix,
286    file_options,
287    filter,
288    filter_map,
289    find,
290    find_map,
291    finish,
292    finish_non_exhaustive,
293    first,
294    flat_map,
295    flatten,
296    floor_char_boundary,
297    fold,
298    for_each,
299    format,
300    from_be_bytes,
301    from_bytes_with_nul,
302    from_bytes_with_nul_unchecked,
303    from_days,
304    from_fn,
305    from_hours,
306    from_le_bytes,
307    from_micros,
308    from_millis,
309    from_mins,
310    from_nanos,
311    from_nanos_u128,
312    from_ne_bytes,
313    from_ptr,
314    from_raw,
315    from_raw_parts,
316    from_secs,
317    from_secs_f32,
318    from_secs_f64,
319    from_str_method,
320    from_str_radix,
321    from_weeks,
322    front,
323    fs,
324    fs_create_dir,
325    fuse,
326    futures_util,
327    get,
328    get_mut,
329    get_or_insert,
330    get_or_insert_with,
331    get_unchecked,
332    get_unchecked_mut,
333    has_significant_drop,
334    hashmap_contains_key,
335    hashmap_drain_ty,
336    hashmap_insert,
337    hashmap_iter_mut_ty,
338    hashmap_iter_ty,
339    hashmap_keys_ty,
340    hashmap_values_mut_ty,
341    hashmap_values_ty,
342    hashset_drain_ty,
343    hashset_iter,
344    hashset_iter_ty,
345    help,
346    hidden_glob_reexports,
347    hygiene,
348    i128_legacy_const_max,
349    i128_legacy_const_min,
350    i128_legacy_fn_max_value,
351    i128_legacy_fn_min_value,
352    i128_legacy_mod,
353    i16_legacy_const_max,
354    i16_legacy_const_min,
355    i16_legacy_fn_max_value,
356    i16_legacy_fn_min_value,
357    i16_legacy_mod,
358    i32_legacy_const_max,
359    i32_legacy_const_min,
360    i32_legacy_fn_max_value,
361    i32_legacy_fn_min_value,
362    i32_legacy_mod,
363    i64_legacy_const_max,
364    i64_legacy_const_min,
365    i64_legacy_fn_max_value,
366    i64_legacy_fn_min_value,
367    i64_legacy_mod,
368    i8_legacy_const_max,
369    i8_legacy_const_min,
370    i8_legacy_fn_max_value,
371    i8_legacy_fn_min_value,
372    i8_legacy_mod,
373    ilog,
374    include_bytes_macro,
375    include_str_macro,
376    insert,
377    insert_str,
378    inspect,
379    instant_now,
380    int_roundings,
381    into,
382    into_bytes,
383    into_ok,
384    into_owned,
385    into_raw,
386    intrinsics_unaligned_volatile_load,
387    intrinsics_unaligned_volatile_store,
388    io,
389    io_error_new,
390    io_errorkind,
391    io_stderr,
392    io_stdout,
393    is_ascii,
394    is_char_boundary,
395    is_diag_item,
396    is_diagnostic_item,
397    is_digit,
398    is_empty,
399    is_err,
400    is_file,
401    is_none,
402    is_none_or,
403    is_ok,
404    is_partitioned,
405    is_some,
406    is_some_and,
407    is_sorted_by_key,
408    isize_legacy_const_max,
409    isize_legacy_const_min,
410    isize_legacy_fn_max_value,
411    isize_legacy_fn_min_value,
412    isize_legacy_mod,
413    isqrt,
414    iter_cloned,
415    iter_copied,
416    iter_filter,
417    iter_repeat,
418    itertools,
419    join,
420    kw,
421    lazy_static,
422    leading_zeros,
423    lint_vec,
424    ln,
425    lock,
426    lock_api,
427    macro_concat,
428    macro_use_imports,
429    map_break,
430    map_continue,
431    map_or,
432    map_or_else,
433    map_while,
434    match_indices,
435    matches,
436    matches_macro,
437    max,
438    max_by,
439    max_by_key,
440    max_value,
441    maximum,
442    may_panic,
443    mem_align_of,
444    mem_replace,
445    mem_size_of,
446    mem_size_of_val,
447    min,
448    min_by,
449    min_by_key,
450    min_value,
451    minimum,
452    mode,
453    module_name_repetitions,
454    msrv,
455    msrvs,
456    mul_add,
457    mut_ptr,
458    mutex,
459    needless_return,
460    next_back,
461    next_if,
462    next_if_eq,
463    next_multiple_of,
464    next_tuple,
465    nth,
466    ok,
467    ok_or,
468    once_cell,
469    open,
470    open_options_new,
471    option_expect,
472    option_unwrap,
473    or_default,
474    or_else,
475    or_insert,
476    or_insert_with,
477    os_str_to_os_string,
478    os_string_as_os_str,
479    outer_expn,
480    panic_any,
481    parse,
482    partition,
483    path_main_separator,
484    path_to_pathbuf,
485    pathbuf_as_path,
486    paths,
487    peek,
488    peek_mut,
489    peekable,
490    permissions_from_mode,
491    pin_macro,
492    pop,
493    pop_back,
494    pop_back_if,
495    pop_front,
496    pop_front_if,
497    pop_if,
498    position,
499    pow,
500    print,
501    println,
502    process_abort,
503    process_exit,
504    product,
505    ptr_read_volatile,
506    ptr_slice_from_raw_parts,
507    ptr_slice_from_raw_parts_mut,
508    ptr_without_provenance,
509    ptr_without_provenance_mut,
510    push,
511    push_back,
512    push_front,
513    push_str,
514    range_step,
515    read,
516    read_exact,
517    read_line,
518    read_to_end,
519    read_to_string,
520    read_unaligned,
521    read_volatile,
522    reduce,
523    redundant_imports,
524    redundant_pub_crate,
525    regex,
526    rem_euclid,
527    repeat,
528    replace,
529    replacen,
530    res,
531    reserve,
532    resize,
533    restriction,
534    result_ok_method,
535    rev,
536    rfind,
537    rmatch_indices,
538    rmatches,
539    rposition,
540    rsplit,
541    rsplit_once,
542    rsplit_terminator,
543    rsplitn,
544    rsplitn_mut,
545    rustc_errors,
546    rustc_lint,
547    rustc_middle,
548    rustc_span,
549    rustfmt_skip,
550    rwlock,
551    saturating_abs,
552    saturating_div,
553    saturating_pow,
554    scan,
555    seek,
556    serde,
557    set_len,
558    set_mode,
559    set_readonly,
560    signum,
561    single_component_path_imports,
562    skip,
563    skip_while,
564    slice_from_ref,
565    slice_iter,
566    slice_mut_unchecked,
567    slice_unchecked,
568    sort,
569    sort_by,
570    sort_unstable_by,
571    span_help,
572    span_lint_and_then,
573    span_note,
574    span_suggestion,
575    split,
576    split_at,
577    split_at_checked,
578    split_at_mut,
579    split_at_mut_checked,
580    split_inclusive,
581    split_once,
582    split_terminator,
583    split_whitespace,
584    splitn,
585    splitn_mut,
586    starts_with,
587    std_detect,
588    step_by,
589    str_chars,
590    str_ends_with,
591    str_len,
592    str_split_whitespace,
593    str_starts_with,
594    str_trim,
595    str_trim_end,
596    str_trim_start,
597    string_as_mut_str,
598    string_as_str,
599    string_from_utf8,
600    string_insert_str,
601    string_new,
602    string_push_str,
603    strlen,
604    style,
605    subsec_micros,
606    subsec_nanos,
607    sum,
608    symbol,
609    take,
610    take_while,
611    tcx,
612    then,
613    then_some,
614    thread_local_macro,
615    to_ascii_lowercase,
616    to_ascii_uppercase,
617    to_be_bytes,
618    to_digit,
619    to_le_bytes,
620    to_lowercase,
621    to_ne_bytes,
622    to_os_string,
623    to_owned,
624    to_path_buf,
625    to_string_method,
626    to_uppercase,
627    tokio,
628    trim,
629    trim_end,
630    trim_end_matches,
631    trim_start,
632    trim_start_matches,
633    truncate,
634    try_fold,
635    try_for_each,
636    try_from_fn,
637    unreachable_pub,
638    unsafe_removed_from_name,
639    unused,
640    unused_braces,
641    unused_extern_crates,
642    unused_import_braces,
643    unused_trait_names,
644    unwrap_err,
645    unwrap_err_unchecked,
646    unwrap_or_default,
647    unwrap_or_else,
648    unwrap_unchecked,
649    unzip,
650    utils,
651    vec_as_mut_slice,
652    vec_as_slice,
653    vec_from_elem,
654    vec_is_empty,
655    vec_macro,
656    vec_new,
657    vec_pop,
658    vec_with_capacity,
659    vecdeque_iter,
660    visit_str,
661    visit_string,
662    wake,
663    wildcard_imports,
664    with_capacity,
665    wrapping_neg,
666    wrapping_offset,
667    write,
668    write_unaligned,
669    write_volatile,
670    writeln,
671    zip,
672}