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    mem_align_of,
443    mem_replace,
444    mem_size_of,
445    mem_size_of_val,
446    min,
447    min_by,
448    min_by_key,
449    min_value,
450    minimum,
451    mode,
452    module_name_repetitions,
453    msrv,
454    msrvs,
455    mul_add,
456    mut_ptr,
457    mutex,
458    needless_return,
459    next_back,
460    next_if,
461    next_if_eq,
462    next_multiple_of,
463    next_tuple,
464    nth,
465    ok,
466    ok_or,
467    once_cell,
468    open,
469    open_options_new,
470    option_expect,
471    option_unwrap,
472    or_default,
473    or_else,
474    or_insert,
475    or_insert_with,
476    os_str_to_os_string,
477    os_string_as_os_str,
478    outer_expn,
479    panic_any,
480    parse,
481    partition,
482    path_main_separator,
483    path_to_pathbuf,
484    pathbuf_as_path,
485    paths,
486    peek,
487    peek_mut,
488    peekable,
489    permissions_from_mode,
490    pin_macro,
491    pop,
492    pop_back,
493    pop_back_if,
494    pop_front,
495    pop_front_if,
496    pop_if,
497    position,
498    pow,
499    print,
500    println,
501    process_abort,
502    process_exit,
503    product,
504    ptr_read_volatile,
505    ptr_slice_from_raw_parts,
506    ptr_slice_from_raw_parts_mut,
507    ptr_without_provenance,
508    ptr_without_provenance_mut,
509    push,
510    push_back,
511    push_front,
512    push_str,
513    range_step,
514    read,
515    read_exact,
516    read_line,
517    read_to_end,
518    read_to_string,
519    read_unaligned,
520    read_volatile,
521    reduce,
522    redundant_imports,
523    redundant_pub_crate,
524    regex,
525    rem_euclid,
526    repeat,
527    replace,
528    replacen,
529    res,
530    reserve,
531    resize,
532    restriction,
533    result_ok_method,
534    rev,
535    rfind,
536    rmatch_indices,
537    rmatches,
538    rposition,
539    rsplit,
540    rsplit_once,
541    rsplit_terminator,
542    rsplitn,
543    rsplitn_mut,
544    rustc_errors,
545    rustc_lint,
546    rustc_middle,
547    rustc_span,
548    rustfmt_skip,
549    rwlock,
550    saturating_abs,
551    saturating_div,
552    saturating_pow,
553    scan,
554    seek,
555    serde,
556    set_len,
557    set_mode,
558    set_readonly,
559    signum,
560    single_component_path_imports,
561    skip,
562    skip_while,
563    slice_from_ref,
564    slice_iter,
565    slice_mut_unchecked,
566    slice_unchecked,
567    sort,
568    sort_by,
569    sort_unstable_by,
570    span_help,
571    span_lint_and_then,
572    span_note,
573    span_suggestion,
574    split,
575    split_at,
576    split_at_checked,
577    split_at_mut,
578    split_at_mut_checked,
579    split_inclusive,
580    split_once,
581    split_terminator,
582    split_whitespace,
583    splitn,
584    splitn_mut,
585    starts_with,
586    std_detect,
587    step_by,
588    str_chars,
589    str_ends_with,
590    str_len,
591    str_split_whitespace,
592    str_starts_with,
593    str_trim,
594    str_trim_end,
595    str_trim_start,
596    string_as_mut_str,
597    string_as_str,
598    string_from_utf8,
599    string_insert_str,
600    string_new,
601    string_push_str,
602    strlen,
603    style,
604    subsec_micros,
605    subsec_nanos,
606    sum,
607    symbol,
608    take,
609    take_while,
610    tcx,
611    then,
612    then_some,
613    thread_local_macro,
614    to_ascii_lowercase,
615    to_ascii_uppercase,
616    to_be_bytes,
617    to_digit,
618    to_le_bytes,
619    to_lowercase,
620    to_ne_bytes,
621    to_os_string,
622    to_owned,
623    to_path_buf,
624    to_string_method,
625    to_uppercase,
626    tokio,
627    trim,
628    trim_end,
629    trim_end_matches,
630    trim_start,
631    trim_start_matches,
632    truncate,
633    try_fold,
634    try_for_each,
635    try_from_fn,
636    unreachable_pub,
637    unsafe_removed_from_name,
638    unused,
639    unused_braces,
640    unused_extern_crates,
641    unused_import_braces,
642    unused_trait_names,
643    unwrap_err,
644    unwrap_err_unchecked,
645    unwrap_or_default,
646    unwrap_or_else,
647    unwrap_unchecked,
648    unzip,
649    utils,
650    vec_as_mut_slice,
651    vec_as_slice,
652    vec_from_elem,
653    vec_is_empty,
654    vec_macro,
655    vec_new,
656    vec_pop,
657    vec_with_capacity,
658    vecdeque_iter,
659    visit_str,
660    visit_string,
661    wake,
662    wildcard_imports,
663    with_capacity,
664    wrapping_neg,
665    wrapping_offset,
666    write,
667    write_unaligned,
668    write_volatile,
669    writeln,
670    zip,
671}