1 //! Generated by `sourcegen_lints`, do not edit by hand.
5 pub label
: &'
static str,
6 pub description
: &'
static str,
10 pub children
: &'
static [&'
static str],
12 pub const DEFAULT_LINTS
: &[Lint
] = &[
14 label
: "absolute_paths_not_starting_with_crate",
15 description
: r
##"fully qualified paths that start with a module name instead of `crate`, `self`, or an extern crate name"##,
17 Lint { label: "ambiguous_associated_items", description: r##"ambiguous associated items"## }
,
18 Lint { label: "anonymous_parameters", description: r##"detects anonymous parameters"## }
,
19 Lint { label: "arithmetic_overflow", description: r##"arithmetic operation overflows"## }
,
21 label
: "array_into_iter",
22 description
: r
##"detects calling `into_iter` on arrays in Rust 2015 and 2018"##,
25 label
: "asm_sub_register",
26 description
: r
##"using only a subset of a register for inline asm inputs"##,
28 Lint { label: "bad_asm_style", description: r##"incorrect use of inline assembly"## }
,
30 label
: "bare_trait_objects",
31 description
: r
##"suggest using `dyn Trait` for trait objects"##,
34 label
: "bindings_with_variant_name",
35 description
: r
##"detects pattern bindings with the same name as one of the matched variants"##,
37 Lint { label: "box_pointers", description: r##"use of owned (Box type) heap memory"## }
,
39 label
: "break_with_label_and_loop",
40 description
: r
##"`break` expression with label and unlabeled loop as value expression"##,
43 label
: "cenum_impl_drop_cast",
44 description
: r
##"a C-like enum implementing Drop is cast"##,
47 label
: "clashing_extern_declarations",
48 description
: r
##"detects when an extern fn has been declared with the same name but different types"##,
51 label
: "coherence_leak_check",
52 description
: r
##"distinct impls distinguished only by the leak-check code"##,
55 label
: "conflicting_repr_hints",
56 description
: r
##"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice"##,
59 label
: "confusable_idents",
60 description
: r
##"detects visually confusable pairs between identifiers"##,
64 description
: r
##"constant evaluation encountered erroneous expression"##,
67 label
: "const_evaluatable_unchecked",
68 description
: r
##"detects a generic constant is used in a type without a emitting a warning"##,
71 label
: "const_item_mutation",
72 description
: r
##"detects attempts to mutate a `const` item"##,
74 Lint { label: "dead_code", description: r##"detect unused, unexported items"## }
,
75 Lint { label: "deprecated", description: r##"detects use of deprecated items"## }
,
77 label
: "deprecated_in_future",
78 description
: r
##"detects use of items that will be deprecated in a future version"##,
81 label
: "deref_into_dyn_supertrait",
82 description
: r
##"`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future"##,
85 label
: "deref_nullptr",
86 description
: r
##"detects when an null pointer is dereferenced"##,
90 description
: r
##"bounds of the form `T: Drop` are most likely incorrect"##,
94 description
: r
##"trait objects of the form `dyn Drop` are useless"##,
97 label
: "elided_lifetimes_in_paths",
98 description
: r
##"hidden lifetime parameters in types are deprecated"##,
101 label
: "ellipsis_inclusive_range_patterns",
102 description
: r
##"`...` range patterns are deprecated"##,
105 label
: "enum_intrinsics_non_enums",
106 description
: r
##"detects calls to `core::mem::discriminant` and `core::mem::variant_count` with non-enum types"##,
109 label
: "explicit_outlives_requirements",
110 description
: r
##"outlives requirements can be inferred"##,
113 label
: "exported_private_dependencies",
114 description
: r
##"public interface leaks type from a private dependency"##,
116 Lint { label: "forbidden_lint_groups", description: r##"applying forbid to lint-groups"## }
,
118 label
: "function_item_references",
119 description
: r
##"suggest casting to a function pointer when attempting to take references to function items"##,
122 label
: "future_incompatible",
123 description
: r
##"lint group for: forbidden-lint-groups, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, const-err, unaligned-references, patterns-in-fns-without-body, missing-fragment-specifier, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, pointer-structural-match, nontrivial-structural-match, soft-unstable, cenum-impl-drop-cast, const-evaluatable-unchecked, uninhabited-static, unsupported-naked-functions, invalid-doc-attributes, semicolon-in-expressions-from-macros, legacy-derive-helpers, proc-macro-back-compat, unsupported-calling-conventions, deref-into-dyn-supertrait"##,
126 label
: "ill_formed_attribute_input",
127 description
: r
##"ill-formed attribute inputs that were previously accepted and used in practice"##,
130 label
: "illegal_floating_point_literal_pattern",
131 description
: r
##"floating-point literals cannot be used in patterns"##,
134 label
: "improper_ctypes",
135 description
: r
##"proper use of libc types in foreign modules"##,
138 label
: "improper_ctypes_definitions",
139 description
: r
##"proper use of libc types in foreign item definitions"##,
142 label
: "incomplete_features",
143 description
: r
##"incomplete features that may function improperly in some or all cases"##,
145 Lint { label: "incomplete_include", description: r##"trailing content in included file"## }
,
147 label
: "indirect_structural_match",
148 description
: r
##"constant used in pattern contains value of non-structural-match type in a field or a variant"##,
151 label
: "ineffective_unstable_trait_impl",
152 description
: r
##"detects `#[unstable]` on stable trait implementations for stable types"##,
155 label
: "inline_no_sanitize",
156 description
: r
##"detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`"##,
159 label
: "invalid_atomic_ordering",
160 description
: r
##"usage of invalid atomic ordering in atomic operations and memory fences"##,
163 label
: "invalid_doc_attributes",
164 description
: r
##"detects invalid `#[doc(...)]` attributes"##,
167 label
: "invalid_type_param_default",
168 description
: r
##"type parameter default erroneously allowed in invalid location"##,
171 label
: "invalid_value",
172 description
: r
##"an invalid value is being created (such as a null reference)"##,
175 label
: "irrefutable_let_patterns",
176 description
: r
##"detects irrefutable patterns in `if let` and `while let` statements"##,
179 label
: "keyword_idents",
180 description
: r
##"detects edition keywords being used as an identifier"##,
182 Lint { label: "large_assignments", description: r##"detects large moves or copies"## }
,
184 label
: "late_bound_lifetime_arguments",
185 description
: r
##"detects generic lifetime arguments in path segments with late bound lifetime parameters"##,
188 label
: "legacy_derive_helpers",
189 description
: r
##"detects derive helper attributes that are used before they are introduced"##,
192 label
: "macro_expanded_macro_exports_accessed_by_absolute_paths",
193 description
: r
##"macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"##,
196 label
: "macro_use_extern_crate",
197 description
: r
##"the `#[macro_use]` attribute is now deprecated in favor of using macros via the module system"##,
200 label
: "meta_variable_misuse",
201 description
: r
##"possible meta-variable misuse at macro definition"##,
203 Lint { label: "missing_abi", description: r##"No declared ABI for extern declaration"## }
,
205 label
: "missing_copy_implementations",
206 description
: r
##"detects potentially-forgotten implementations of `Copy`"##,
209 label
: "missing_debug_implementations",
210 description
: r
##"detects missing implementations of Debug"##,
213 label
: "missing_docs",
214 description
: r
##"detects missing documentation for public members"##,
217 label
: "missing_fragment_specifier",
218 description
: r
##"detects missing fragment specifiers in unused `macro_rules!` patterns"##,
221 label
: "mixed_script_confusables",
222 description
: r
##"detects Unicode scripts whose mixed script confusables codepoints are solely used"##,
225 label
: "must_not_suspend",
226 description
: r
##"use of a `#[must_not_suspend]` value across a yield point"##,
229 label
: "mutable_borrow_reservation_conflict",
230 description
: r
##"reservation of a two-phased borrow conflicts with other shared borrows"##,
233 label
: "mutable_transmutes",
234 description
: r
##"mutating transmuted &mut T from &T may cause undefined behavior"##,
236 Lint { label: "named_asm_labels", description: r##"named labels in inline assembly"## }
,
238 label
: "no_mangle_const_items",
239 description
: r
##"const items will not have their symbols exported"##,
241 Lint { label: "no_mangle_generic_items", description: r##"generic items must be mangled"## }
,
242 Lint { label: "non_ascii_idents", description: r##"detects non-ASCII identifiers"## }
,
244 label
: "non_camel_case_types",
245 description
: r
##"types, variants, traits and type parameters should have camel case names"##,
248 label
: "non_exhaustive_omitted_patterns",
249 description
: r
##"detect when patterns of types marked `non_exhaustive` are missed"##,
252 label
: "non_fmt_panics",
253 description
: r
##"detect single-argument panic!() invocations in which the argument is not a format string"##,
256 label
: "non_shorthand_field_patterns",
257 description
: r
##"using `Struct { x: x }` instead of `Struct { x }` in a pattern"##,
260 label
: "non_snake_case",
261 description
: r
##"variables, methods, functions, lifetime parameters and modules should have snake case names"##,
264 label
: "non_upper_case_globals",
265 description
: r
##"static constants should have uppercase identifiers"##,
268 label
: "nonstandard_style",
269 description
: r
##"lint group for: non-camel-case-types, non-snake-case, non-upper-case-globals"##,
272 label
: "nontrivial_structural_match",
273 description
: r
##"constant used in pattern of non-structural-match type and the constant's initializer expression contains values of non-structural-match types"##,
276 label
: "noop_method_call",
277 description
: r
##"detects the use of well-known noop methods"##,
280 label
: "order_dependent_trait_objects",
281 description
: r
##"trait-object types were treated as different depending on marker-trait order"##,
283 Lint { label: "overflowing_literals", description: r##"literal out of range for its type"## }
,
285 label
: "overlapping_range_endpoints",
286 description
: r
##"detects range patterns with overlapping endpoints"##,
288 Lint { label: "path_statements", description: r##"path statements with no effect"## }
,
290 label
: "patterns_in_fns_without_body",
291 description
: r
##"patterns in functions without body were erroneously allowed"##,
294 label
: "pointer_structural_match",
295 description
: r
##"pointers are not structural-match"##,
298 label
: "private_in_public",
299 description
: r
##"detect private items in public interfaces not caught by the old implementation"##,
302 label
: "proc_macro_back_compat",
303 description
: r
##"detects usage of old versions of certain proc-macro crates"##,
306 label
: "proc_macro_derive_resolution_fallback",
307 description
: r
##"detects proc macro derives using inaccessible names from parent modules"##,
310 label
: "pub_use_of_private_extern_crate",
311 description
: r
##"detect public re-exports of private extern crates"##,
314 label
: "redundant_semicolons",
315 description
: r
##"detects unnecessary trailing semicolons"##,
318 label
: "renamed_and_removed_lints",
319 description
: r
##"lints that have been renamed or removed"##,
322 label
: "rust_2018_compatibility",
323 description
: r
##"lint group for: keyword-idents, anonymous-parameters, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate"##,
326 label
: "rust_2018_idioms",
327 description
: r
##"lint group for: bare-trait-objects, unused-extern-crates, ellipsis-inclusive-range-patterns, elided-lifetimes-in-paths, explicit-outlives-requirements"##,
330 label
: "rust_2021_compatibility",
331 description
: r
##"lint group for: ellipsis-inclusive-range-patterns, bare-trait-objects, rust-2021-incompatible-closure-captures, rust-2021-incompatible-or-patterns, rust-2021-prelude-collisions, rust-2021-prefixes-incompatible-syntax, array-into-iter, non-fmt-panics"##,
334 label
: "rust_2021_incompatible_closure_captures",
335 description
: r
##"detects closures affected by Rust 2021 changes"##,
338 label
: "rust_2021_incompatible_or_patterns",
339 description
: r
##"detects usage of old versions of or-patterns"##,
342 label
: "rust_2021_prefixes_incompatible_syntax",
343 description
: r
##"identifiers that will be parsed as a prefix in Rust 2021"##,
346 label
: "rust_2021_prelude_collisions",
347 description
: r
##"detects the usage of trait methods which are ambiguous with traits added to the prelude in future editions"##,
350 label
: "semicolon_in_expressions_from_macros",
351 description
: r
##"trailing semicolon in macro body used as expression"##,
354 label
: "single_use_lifetimes",
355 description
: r
##"detects lifetime parameters that are only used once"##,
358 label
: "soft_unstable",
359 description
: r
##"a feature gate that doesn't break dependent crates"##,
362 label
: "stable_features",
363 description
: r
##"stable features found in `#[feature]` directive"##,
366 label
: "temporary_cstring_as_ptr",
367 description
: r
##"detects getting the inner pointer of a temporary `CString`"##,
370 label
: "text_direction_codepoint_in_comment",
371 description
: r
##"invisible directionality-changing codepoints in comment"##,
374 label
: "text_direction_codepoint_in_literal",
375 description
: r
##"detect special Unicode codepoints that affect the visual representation of text on screen, changing the direction in which text flows"##,
378 label
: "trivial_bounds",
379 description
: r
##"these bounds don't depend on an type parameters"##,
382 label
: "trivial_casts",
383 description
: r
##"detects trivial casts which could be removed"##,
386 label
: "trivial_numeric_casts",
387 description
: r
##"detects trivial casts of numeric types which could be removed"##,
390 label
: "type_alias_bounds",
391 description
: r
##"bounds in type aliases are not enforced"##,
394 label
: "tyvar_behind_raw_pointer",
395 description
: r
##"raw pointer to an inference variable"##,
398 label
: "unaligned_references",
399 description
: r
##"detects unaligned references to fields of packed structs"##,
402 label
: "uncommon_codepoints",
403 description
: r
##"detects uncommon Unicode codepoints in identifiers"##,
406 label
: "unconditional_panic",
407 description
: r
##"operation will cause a panic at runtime"##,
410 label
: "unconditional_recursion",
411 description
: r
##"functions that cannot return without calling themselves"##,
413 Lint { label: "uninhabited_static", description: r##"uninhabited static"## }
,
415 label
: "unknown_crate_types",
416 description
: r
##"unknown crate type found in `#[crate_type]` directive"##,
418 Lint { label: "unknown_lints", description: r##"unrecognized lint attribute"## }
,
420 label
: "unnameable_test_items",
421 description
: r
##"detects an item that cannot be named being marked as `#[test_case]`"##,
423 Lint { label: "unreachable_code", description: r##"detects unreachable code paths"## }
,
424 Lint { label: "unreachable_patterns", description: r##"detects unreachable patterns"## }
,
426 label
: "unreachable_pub",
427 description
: r
##"`pub` items not reachable from crate root"##,
429 Lint { label: "unsafe_code", description: r##"usage of `unsafe` code"## }
,
431 label
: "unsafe_op_in_unsafe_fn",
432 description
: r
##"unsafe operations in unsafe functions without an explicit unsafe block are deprecated"##,
435 label
: "unstable_features",
436 description
: r
##"enabling unstable features (deprecated. do not use)"##,
439 label
: "unstable_name_collisions",
440 description
: r
##"detects name collision with an existing but unstable method"##,
443 label
: "unsupported_calling_conventions",
444 description
: r
##"use of unsupported calling convention"##,
447 label
: "unsupported_naked_functions",
448 description
: r
##"unsupported naked function definitions"##,
452 description
: r
##"lint group for: unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unreachable-patterns, unused-must-use, unused-unsafe, path-statements, unused-attributes, unused-macros, unused-allocation, unused-doc-comments, unused-extern-crates, unused-features, unused-labels, unused-parens, unused-braces, redundant-semicolons"##,
455 label
: "unused_allocation",
456 description
: r
##"detects unnecessary allocations that can be eliminated"##,
459 label
: "unused_assignments",
460 description
: r
##"detect assignments that will never be read"##,
463 label
: "unused_attributes",
464 description
: r
##"detects attributes that were not used by the compiler"##,
466 Lint { label: "unused_braces", description: r##"unnecessary braces around an expression"## }
,
468 label
: "unused_comparisons",
469 description
: r
##"comparisons made useless by limits of the types involved"##,
472 label
: "unused_crate_dependencies",
473 description
: r
##"crate dependencies that are never used"##,
476 label
: "unused_doc_comments",
477 description
: r
##"detects doc comments that aren't used by rustdoc"##,
479 Lint { label: "unused_extern_crates", description: r##"extern crates that are never used"## }
,
481 label
: "unused_features",
482 description
: r
##"unused features found in crate-level `#[feature]` directives"##,
485 label
: "unused_import_braces",
486 description
: r
##"unnecessary braces around an imported item"##,
488 Lint { label: "unused_imports", description: r##"imports that are never used"## }
,
489 Lint { label: "unused_labels", description: r##"detects labels that are never used"## }
,
491 label
: "unused_lifetimes",
492 description
: r
##"detects lifetime parameters that are never used"##,
494 Lint { label: "unused_macros", description: r##"detects macros that were not used"## }
,
496 label
: "unused_must_use",
497 description
: r
##"unused result of a type flagged as `#[must_use]`"##,
501 description
: r
##"detect mut variables which don't need to be mutable"##,
504 label
: "unused_parens",
505 description
: r
##"`if`, `match`, `while` and `return` do not need parentheses"##,
508 label
: "unused_qualifications",
509 description
: r
##"detects unnecessarily qualified names"##,
512 label
: "unused_results",
513 description
: r
##"unused result of an expression in a statement"##,
515 Lint { label: "unused_unsafe", description: r##"unnecessary use of an `unsafe` block"## }
,
517 label
: "unused_variables",
518 description
: r
##"detect variables which are not used in any way"##,
521 label
: "useless_deprecated",
522 description
: r
##"detects deprecation attributes with no effect"##,
525 label
: "variant_size_differences",
526 description
: r
##"detects enums with widely varying variant sizes"##,
530 description
: r
##"mass-change the level for lints which produce warnings"##,
534 description
: r
##"lint group for: all lints that are set to issue warnings"##,
537 label
: "where_clauses_object_safety",
538 description
: r
##"checks the object safety of where clauses"##,
542 description
: r
##"suggest using `loop { }` instead of `while true { }`"##,
545 pub const DEFAULT_LINT_GROUPS
: &[LintGroup
] = &[
548 label
: "future_incompatible",
549 description
: r
##"lint group for: forbidden-lint-groups, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, const-err, unaligned-references, patterns-in-fns-without-body, missing-fragment-specifier, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, pointer-structural-match, nontrivial-structural-match, soft-unstable, cenum-impl-drop-cast, const-evaluatable-unchecked, uninhabited-static, unsupported-naked-functions, invalid-doc-attributes, semicolon-in-expressions-from-macros, legacy-derive-helpers, proc-macro-back-compat, unsupported-calling-conventions, deref-into-dyn-supertrait"##,
552 "forbidden_lint_groups",
553 "illegal_floating_point_literal_pattern",
555 "pub_use_of_private_extern_crate",
556 "invalid_type_param_default",
558 "unaligned_references",
559 "patterns_in_fns_without_body",
560 "missing_fragment_specifier",
561 "late_bound_lifetime_arguments",
562 "order_dependent_trait_objects",
563 "coherence_leak_check",
564 "unstable_name_collisions",
565 "where_clauses_object_safety",
566 "proc_macro_derive_resolution_fallback",
567 "macro_expanded_macro_exports_accessed_by_absolute_paths",
568 "ill_formed_attribute_input",
569 "conflicting_repr_hints",
570 "ambiguous_associated_items",
571 "mutable_borrow_reservation_conflict",
572 "indirect_structural_match",
573 "pointer_structural_match",
574 "nontrivial_structural_match",
576 "cenum_impl_drop_cast",
577 "const_evaluatable_unchecked",
578 "uninhabited_static",
579 "unsupported_naked_functions",
580 "invalid_doc_attributes",
581 "semicolon_in_expressions_from_macros",
582 "legacy_derive_helpers",
583 "proc_macro_back_compat",
584 "unsupported_calling_conventions",
585 "deref_into_dyn_supertrait",
590 label
: "nonstandard_style",
591 description
: r
##"lint group for: non-camel-case-types, non-snake-case, non-upper-case-globals"##,
593 children
: &["non_camel_case_types", "non_snake_case", "non_upper_case_globals"],
597 label
: "rust_2018_compatibility",
598 description
: r
##"lint group for: keyword-idents, anonymous-parameters, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate"##,
602 "anonymous_parameters",
603 "tyvar_behind_raw_pointer",
604 "absolute_paths_not_starting_with_crate",
609 label
: "rust_2018_idioms",
610 description
: r
##"lint group for: bare-trait-objects, unused-extern-crates, ellipsis-inclusive-range-patterns, elided-lifetimes-in-paths, explicit-outlives-requirements"##,
613 "bare_trait_objects",
614 "unused_extern_crates",
615 "ellipsis_inclusive_range_patterns",
616 "elided_lifetimes_in_paths",
617 "explicit_outlives_requirements",
622 label
: "rust_2021_compatibility",
623 description
: r
##"lint group for: ellipsis-inclusive-range-patterns, bare-trait-objects, rust-2021-incompatible-closure-captures, rust-2021-incompatible-or-patterns, rust-2021-prelude-collisions, rust-2021-prefixes-incompatible-syntax, array-into-iter, non-fmt-panics"##,
626 "ellipsis_inclusive_range_patterns",
627 "bare_trait_objects",
628 "rust_2021_incompatible_closure_captures",
629 "rust_2021_incompatible_or_patterns",
630 "rust_2021_prelude_collisions",
631 "rust_2021_prefixes_incompatible_syntax",
639 description
: r
##"lint group for: unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unreachable-patterns, unused-must-use, unused-unsafe, path-statements, unused-attributes, unused-macros, unused-allocation, unused-doc-comments, unused-extern-crates, unused-features, unused-labels, unused-parens, unused-braces, redundant-semicolons"##,
644 "unused_assignments",
648 "unreachable_patterns",
655 "unused_doc_comments",
656 "unused_extern_crates",
661 "redundant_semicolons",
667 description
: r
##"lint group for: all lints that are set to issue warnings"##,
673 pub const RUSTDOC_LINTS
: &[Lint
] = &[
675 label
: "rustdoc::all",
676 description
: r
##"lint group for: rustdoc::broken-intra-doc-links, rustdoc::private-intra-doc-links, rustdoc::missing-doc-code-examples, rustdoc::private-doc-tests, rustdoc::invalid-codeblock-attributes, rustdoc::invalid-rust-codeblocks, rustdoc::invalid-html-tags, rustdoc::bare-urls, rustdoc::missing-crate-level-docs"##,
678 Lint { label: "rustdoc::bare_urls", description: r##"detects URLs that are not hyperlinks"## }
,
680 label
: "rustdoc::broken_intra_doc_links",
681 description
: r
##"failures in resolving intra-doc link targets"##,
684 label
: "rustdoc::invalid_codeblock_attributes",
685 description
: r
##"codeblock attribute looks a lot like a known one"##,
688 label
: "rustdoc::invalid_html_tags",
689 description
: r
##"detects invalid HTML tags in doc comments"##,
692 label
: "rustdoc::invalid_rust_codeblocks",
693 description
: r
##"codeblock could not be parsed as valid Rust or is empty"##,
696 label
: "rustdoc::missing_crate_level_docs",
697 description
: r
##"detects crates with no crate-level documentation"##,
700 label
: "rustdoc::missing_doc_code_examples",
701 description
: r
##"detects publicly-exported items without code samples in their documentation"##,
704 label
: "rustdoc::private_doc_tests",
705 description
: r
##"detects code samples in docs of private items not documented by rustdoc"##,
708 label
: "rustdoc::private_intra_doc_links",
709 description
: r
##"linking from a public item to a private one"##,
712 pub const RUSTDOC_LINT_GROUPS
: &[LintGroup
] = &[LintGroup
{
714 label
: "rustdoc::all",
715 description
: r
##"lint group for: rustdoc::broken-intra-doc-links, rustdoc::private-intra-doc-links, rustdoc::missing-doc-code-examples, rustdoc::private-doc-tests, rustdoc::invalid-codeblock-attributes, rustdoc::invalid-rust-codeblocks, rustdoc::invalid-html-tags, rustdoc::bare-urls, rustdoc::missing-crate-level-docs"##,
718 "rustdoc::broken_intra_doc_links",
719 "rustdoc::private_intra_doc_links",
720 "rustdoc::missing_doc_code_examples",
721 "rustdoc::private_doc_tests",
722 "rustdoc::invalid_codeblock_attributes",
723 "rustdoc::invalid_rust_codeblocks",
724 "rustdoc::invalid_html_tags",
725 "rustdoc::bare_urls",
726 "rustdoc::missing_crate_level_docs",
730 pub const FEATURES
: &[Lint
] = &[
732 label
: "abi_c_cmse_nonsecure_call",
733 description
: r
##"# `abi_c_cmse_nonsecure_call`
735 The tracking issue for this feature is: [#81391]
737 [#81391]: https://github.com/rust-lang/rust/issues/81391
739 ------------------------
742 feature](https://developer.arm.com/documentation/100690/latest/) is available
743 for targets with the Armv8-M architecture profile (`thumbv8m` in their target
745 LLVM, the Rust compiler and the linker are providing
746 [support](https://developer.arm.com/documentation/ecm0359818/latest/) for the
749 One of the things provided, with this unstable feature, is the
750 `C-cmse-nonsecure-call` function ABI. This ABI is used on function pointers to
751 non-secure code to mark a non-secure function call (see [section
752 5.5](https://developer.arm.com/documentation/ecm0359818/latest/) for details).
754 With this ABI, the compiler will do the following to perform the call:
755 * save registers needed after the call to Secure memory
756 * clear all registers that might contain confidential information
757 * clear the Least Significant Bit of the function address
758 * branches using the BLXNS instruction
760 To avoid using the non-secure stack, the compiler will constrain the number and
761 type of parameters/return value.
763 The `extern "C-cmse-nonsecure-call"` ABI is otherwise equivalent to the
766 <!-- NOTE(ignore) this example is specific to thumbv8m targets -->
770 #![feature(abi_c_cmse_nonsecure_call)]
773 pub fn call_nonsecure_function(addr: usize) -> u32 {
774 let non_secure_function =
775 unsafe { core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn() -> u32>(addr) };
776 non_secure_function()
781 $ rustc --emit asm --crate-type lib --target thumbv8m.main-none-eabi function.rs
783 call_nonsecure_function:
797 push.w {r4, r5, r6, r7, r8, r9, r10, r11}
813 pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
824 label
: "abi_msp430_interrupt",
825 description
: r
##"# `abi_msp430_interrupt`
827 The tracking issue for this feature is: [#38487]
829 [#38487]: https://github.com/rust-lang/rust/issues/38487
831 ------------------------
833 In the MSP430 architecture, interrupt handlers have a special calling
834 convention. You can use the `"msp430-interrupt"` ABI to make the compiler apply
835 the right calling convention to the interrupt handlers you define.
837 <!-- NOTE(ignore) this example is specific to the msp430 target -->
840 #![feature(abi_msp430_interrupt)]
843 // Place the interrupt handler at the appropriate memory address
844 // (Alternatively, you can use `#[used]` and remove `pub` and `#[no_mangle]`)
845 #[link_section = "__interrupt_vector_10"]
847 pub static TIM0_VECTOR: extern "msp430-interrupt" fn() = tim0;
849 // The interrupt handler
850 extern "msp430-interrupt" fn tim0() {
856 $ msp430-elf-objdump -CD ./target/msp430/release/app
857 Disassembly of section __interrupt_vector_10:
859 0000fff2 <TIM0_VECTOR>:
860 fff2: 00 c0 interrupt service routine at 0xc000
862 Disassembly of section .text:
864 0000c000 <int::tim0>:
871 description
: r
##"# `abi_ptx`
873 The tracking issue for this feature is: [#38788]
875 [#38788]: https://github.com/rust-lang/rust/issues/38788
877 ------------------------
879 When emitting PTX code, all vanilla Rust functions (`fn`) get translated to
880 "device" functions. These functions are *not* callable from the host via the
881 CUDA API so a crate with only device functions is not too useful!
883 OTOH, "global" functions *can* be called by the host; you can think of them
884 as the real public API of your crate. To produce a global function use the
887 <!-- NOTE(ignore) this example is specific to the nvptx targets -->
893 pub unsafe extern "ptx-kernel" fn global_function() {
897 pub fn device_function() {
903 $ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm
905 $ cat $(find -name '*.s')
907 // Generated by LLVM NVPTX Back-End
914 // .globl _ZN6kernel15global_function17h46111ebe6516b382E
916 .visible .entry _ZN6kernel15global_function17h46111ebe6516b382E()
923 // .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E
924 .visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E()
934 label
: "abi_thiscall",
935 description
: r
##"# `abi_thiscall`
937 The tracking issue for this feature is: [#42202]
939 [#42202]: https://github.com/rust-lang/rust/issues/42202
941 ------------------------
943 The MSVC ABI on x86 Windows uses the `thiscall` calling convention for C++
944 instance methods by default; it is identical to the usual (C) calling
945 convention on x86 Windows except that the first parameter of the method,
946 the `this` pointer, is passed in the ECX register.
950 label
: "allocator_api",
951 description
: r
##"# `allocator_api`
953 The tracking issue for this feature is [#32838]
955 [#32838]: https://github.com/rust-lang/rust/issues/32838
957 ------------------------
959 Sometimes you want the memory for one collection to use a different
960 allocator than the memory for another collection. In this case,
961 replacing the global allocator is not a workable option. Instead,
962 you need to pass in an instance of an `AllocRef` to each collection
963 for which you want a custom allocator.
969 label
: "allocator_internals",
970 description
: r
##"# `allocator_internals`
972 This feature does not have a tracking issue, it is an unstable implementation
973 detail of the `global_allocator` feature not intended for use outside the
976 ------------------------
980 label
: "arbitrary_enum_discriminant",
981 description
: r
##"# `arbitrary_enum_discriminant`
983 The tracking issue for this feature is: [#60553]
985 [#60553]: https://github.com/rust-lang/rust/issues/60553
987 ------------------------
989 The `arbitrary_enum_discriminant` feature permits tuple-like and
990 struct-like enum variants with `#[repr(<int-type>)]` to have explicit discriminants.
995 #![feature(arbitrary_enum_discriminant)]
1009 fn tag(&self) -> u8 {
1010 unsafe { *(self as *const Self as *const u8) }
1014 assert_eq!(3, Enum::Unit.tag());
1015 assert_eq!(2, Enum::Tuple(5).tag());
1016 assert_eq!(1, Enum::Struct{a: 7, b: 11}.tag());
1022 description
: r
##"# `asm_const`
1024 The tracking issue for this feature is: [#72016]
1026 [#72016]: https://github.com/rust-lang/rust/issues/72016
1028 ------------------------
1030 This feature adds a `const <expr>` operand type to `asm!` and `global_asm!`.
1031 - `<expr>` must be an integer constant expression.
1032 - The value of the expression is formatted as a string and substituted directly into the asm template string.
1036 label
: "asm_experimental_arch",
1037 description
: r
##"# `asm_experimental_arch`
1039 The tracking issue for this feature is: [#72016]
1041 [#72016]: https://github.com/rust-lang/rust/issues/72016
1043 ------------------------
1045 This feature tracks `asm!` and `global_asm!` support for the following architectures:
1049 - MIPS32r2 and MIPS64r2
1057 | Architecture | Register class | Registers | LLVM constraint code |
1058 | ------------ | -------------- | ---------------------------------- | -------------------- |
1059 | MIPS | `reg` | `$[2-25]` | `r` |
1060 | MIPS | `freg` | `$f[0-31]` | `f` |
1061 | NVPTX | `reg16` | None\* | `h` |
1062 | NVPTX | `reg32` | None\* | `r` |
1063 | NVPTX | `reg64` | None\* | `l` |
1064 | Hexagon | `reg` | `r[0-28]` | `r` |
1065 | PowerPC | `reg` | `r[0-31]` | `r` |
1066 | PowerPC | `reg_nonzero` | `r[1-31]` | `b` |
1067 | PowerPC | `freg` | `f[0-31]` | `f` |
1068 | PowerPC | `cr` | `cr[0-7]`, `cr` | Only clobbers |
1069 | PowerPC | `xer` | `xer` | Only clobbers |
1070 | wasm32 | `local` | None\* | `r` |
1071 | BPF | `reg` | `r[0-10]` | `r` |
1072 | BPF | `wreg` | `w[0-10]` | `w` |
1073 | AVR | `reg` | `r[2-25]`, `XH`, `XL`, `ZH`, `ZL` | `r` |
1074 | AVR | `reg_upper` | `r[16-25]`, `XH`, `XL`, `ZH`, `ZL` | `d` |
1075 | AVR | `reg_pair` | `r3r2` .. `r25r24`, `X`, `Z` | `r` |
1076 | AVR | `reg_iw` | `r25r24`, `X`, `Z` | `w` |
1077 | AVR | `reg_ptr` | `X`, `Z` | `e` |
1080 > - NVPTX doesn't have a fixed register set, so named registers are not supported.
1082 > - WebAssembly doesn't have registers, so named registers are not supported.
1084 # Register class supported types
1086 | Architecture | Register class | Target feature | Allowed types |
1087 | ------------ | ------------------------------- | -------------- | --------------------------------------- |
1088 | MIPS32 | `reg` | None | `i8`, `i16`, `i32`, `f32` |
1089 | MIPS32 | `freg` | None | `f32`, `f64` |
1090 | MIPS64 | `reg` | None | `i8`, `i16`, `i32`, `i64`, `f32`, `f64` |
1091 | MIPS64 | `freg` | None | `f32`, `f64` |
1092 | NVPTX | `reg16` | None | `i8`, `i16` |
1093 | NVPTX | `reg32` | None | `i8`, `i16`, `i32`, `f32` |
1094 | NVPTX | `reg64` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |
1095 | Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |
1096 | PowerPC | `reg` | None | `i8`, `i16`, `i32` |
1097 | PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32` |
1098 | PowerPC | `freg` | None | `f32`, `f64` |
1099 | PowerPC | `cr` | N/A | Only clobbers |
1100 | PowerPC | `xer` | N/A | Only clobbers |
1101 | wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` |
1102 | BPF | `reg` | None | `i8` `i16` `i32` `i64` |
1103 | BPF | `wreg` | `alu32` | `i8` `i16` `i32` |
1104 | AVR | `reg`, `reg_upper` | None | `i8` |
1105 | AVR | `reg_pair`, `reg_iw`, `reg_ptr` | None | `i16` |
1109 | Architecture | Base register | Aliases |
1110 | ------------ | ------------- | --------- |
1111 | Hexagon | `r29` | `sp` |
1112 | Hexagon | `r30` | `fr` |
1113 | Hexagon | `r31` | `lr` |
1114 | BPF | `r[0-10]` | `w[0-10]` |
1115 | AVR | `XH` | `r27` |
1116 | AVR | `XL` | `r26` |
1117 | AVR | `ZH` | `r31` |
1118 | AVR | `ZL` | `r30` |
1120 ## Unsupported registers
1122 | Architecture | Unsupported register | Reason |
1123 | ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1124 | All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |
1125 | All | `fr` (Hexagon), `$fp` (MIPS), `Y` (AVR) | The frame pointer cannot be used as an input or output. |
1126 | All | `r19` (Hexagon) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
1127 | MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
1128 | MIPS | `$1` or `$at` | Reserved for assembler. |
1129 | MIPS | `$26`/`$k0`, `$27`/`$k1` | OS-reserved registers. |
1130 | MIPS | `$28`/`$gp` | Global pointer cannot be used as inputs or outputs. |
1131 | MIPS | `$ra` | Return address cannot be used as inputs or outputs. |
1132 | Hexagon | `lr` | This is the link register which cannot be used as an input or output. |
1133 | AVR | `r0`, `r1`, `r1r0` | Due to an issue in LLVM, the `r0` and `r1` registers cannot be used as inputs or outputs. If modified, they must be restored to their original values before the end of the block. |
1135 ## Template modifiers
1137 | Architecture | Register class | Modifier | Example output | LLVM modifier |
1138 | ------------ | -------------- | -------- | -------------- | ------------- |
1139 | MIPS | `reg` | None | `$2` | None |
1140 | MIPS | `freg` | None | `$f0` | None |
1141 | NVPTX | `reg16` | None | `rs0` | None |
1142 | NVPTX | `reg32` | None | `r0` | None |
1143 | NVPTX | `reg64` | None | `rd0` | None |
1144 | Hexagon | `reg` | None | `r0` | None |
1145 | PowerPC | `reg` | None | `0` | None |
1146 | PowerPC | `reg_nonzero` | None | `3` | `b` |
1147 | PowerPC | `freg` | None | `0` | None |
1149 # Flags covered by `preserves_flags`
1151 These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set:
1153 - The status register `SREG`.
1158 description
: r
##"# `asm_sym`
1160 The tracking issue for this feature is: [#72016]
1162 [#72016]: https://github.com/rust-lang/rust/issues/72016
1164 ------------------------
1166 This feature adds a `sym <path>` operand type to `asm!` and `global_asm!`.
1167 - `<path>` must refer to a `fn` or `static`.
1168 - A mangled symbol name referring to the item is substituted into the asm template string.
1169 - The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc).
1170 - `<path>` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data.
1174 label
: "asm_unwind",
1175 description
: r
##"# `asm_unwind`
1177 The tracking issue for this feature is: [#72016]
1179 [#72016]: https://github.com/rust-lang/rust/issues/72016
1181 ------------------------
1183 This feature adds a `may_unwind` option to `asm!` which allows an `asm` block to unwind stack and be part of the stack unwinding process. This option is only supported by the LLVM backend right now.
1187 label
: "auto_traits",
1188 description
: r
##"# `auto_traits`
1190 The tracking issue for this feature is [#13231]
1192 [#13231]: https://github.com/rust-lang/rust/issues/13231
1196 The `auto_traits` feature gate allows you to define auto traits.
1198 Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits
1199 that are automatically implemented for every type, unless the type, or a type it contains,
1200 has explicitly opted out via a negative impl. (Negative impls are separately controlled
1201 by the `negative_impls` feature.)
1203 [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
1204 [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
1206 ```rust,ignore (partial-example)
1207 impl !Trait for Type {}
1213 #![feature(negative_impls)]
1214 #![feature(auto_traits)]
1221 impl !Valid for False {}
1223 struct MaybeValid<T>(T);
1225 fn must_be_valid<T: Valid>(_t: T) { }
1229 must_be_valid( MaybeValid(True) );
1231 // compiler error - trait bound not satisfied
1232 // must_be_valid( MaybeValid(False) );
1236 ## Automatic trait implementations
1238 When a type is declared as an `auto trait`, we will automatically
1239 create impls for every struct/enum/union, unless an explicit impl is
1240 provided. These automatic impls contain a where clause for each field
1241 of the form `T: AutoTrait`, where `T` is the type of the field and
1242 `AutoTrait` is the auto trait in question. As an example, consider the
1243 struct `List` and the auto trait `Send`:
1248 next: Option<Box<List<T>>>,
1252 Presuming that there is no explicit impl of `Send` for `List`, the
1253 compiler will supply an automatic impl of the form:
1258 next: Option<Box<List<T>>>,
1261 unsafe impl<T> Send for List<T>
1263 T: Send, // from the field `data`
1264 Option<Box<List<T>>>: Send, // from the field `next`
1268 Explicit impls may be either positive or negative. They take the form:
1270 ```rust,ignore (partial-example)
1271 impl<...> AutoTrait for StructName<..> { }
1272 impl<...> !AutoTrait for StructName<..> { }
1275 ## Coinduction: Auto traits permit cyclic matching
1277 Unlike ordinary trait matching, auto traits are **coinductive**. This
1278 means, in short, that cycles which occur in trait matching are
1279 considered ok. As an example, consider the recursive struct `List`
1280 introduced in the previous section. In attempting to determine whether
1281 `List: Send`, we would wind up in a cycle: to apply the impl, we must
1282 show that `Option<Box<List>>: Send`, which will in turn require
1283 `Box<List>: Send` and then finally `List: Send` again. Under ordinary
1284 trait matching, this cycle would be an error, but for an auto trait it
1285 is considered a successful match.
1289 Auto traits cannot have any trait items, such as methods or associated types. This ensures that we can generate default implementations.
1293 Auto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile.
1297 label
: "box_patterns",
1298 description
: r
##"# `box_patterns`
1300 The tracking issue for this feature is: [#29641]
1302 [#29641]: https://github.com/rust-lang/rust/issues/29641
1304 See also [`box_syntax`](box-syntax.md)
1306 ------------------------
1308 Box patterns let you match on `Box<T>`s:
1312 #![feature(box_patterns)]
1315 let b = Some(Box::new(5));
1317 Some(box n) if n < 0 => {
1318 println!("Box contains negative number {}", n);
1320 Some(box n) if n >= 0 => {
1321 println!("Box contains non-negative number {}", n);
1333 label
: "box_syntax",
1334 description
: r
##"# `box_syntax`
1336 The tracking issue for this feature is: [#49733]
1338 [#49733]: https://github.com/rust-lang/rust/issues/49733
1340 See also [`box_patterns`](box-patterns.md)
1342 ------------------------
1344 Currently the only stable way to create a `Box` is via the `Box::new` method.
1345 Also it is not possible in stable Rust to destructure a `Box` in a match
1346 pattern. The unstable `box` keyword can be used to create a `Box`. An example
1350 #![feature(box_syntax)]
1360 description
: r
##"# `c_unwind`
1362 The tracking issue for this feature is: [#74990]
1364 [#74990]: https://github.com/rust-lang/rust/issues/74990
1366 ------------------------
1368 Introduces four new ABI strings: "C-unwind", "stdcall-unwind",
1369 "thiscall-unwind", and "system-unwind". These enable unwinding from other
1370 languages (such as C++) into Rust frames and from Rust into other languages.
1372 See [RFC 2945] for more information.
1374 [RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
1378 label
: "c_variadic",
1379 description
: r
##"# `c_variadic`
1381 The tracking issue for this feature is: [#44930]
1383 [#44930]: https://github.com/rust-lang/rust/issues/44930
1385 ------------------------
1387 The `c_variadic` language feature enables C-variadic functions to be
1388 defined in Rust. The may be called both from within Rust and via FFI.
1393 #![feature(c_variadic)]
1395 pub unsafe extern "C" fn add(n: usize, mut args: ...) -> usize {
1398 sum += args.arg::<usize>();
1406 label
: "c_variadic",
1407 description
: r
##"# `c_variadic`
1409 The tracking issue for this feature is: [#44930]
1411 [#44930]: https://github.com/rust-lang/rust/issues/44930
1413 ------------------------
1415 The `c_variadic` library feature exposes the `VaList` structure,
1416 Rust's analogue of C's `va_list` type.
1421 #![feature(c_variadic)]
1423 use std::ffi::VaList;
1425 pub unsafe extern "C" fn vadd(n: usize, mut args: VaList) -> usize {
1428 sum += args.arg::<usize>();
1436 label
: "c_void_variant",
1437 description
: r
##"# `c_void_variant`
1439 This feature is internal to the Rust compiler and is not intended for general use.
1441 ------------------------
1446 description
: r
##"# `cfg_panic`
1448 The tracking issue for this feature is: [#77443]
1450 [#77443]: https://github.com/rust-lang/rust/issues/77443
1452 ------------------------
1454 The `cfg_panic` feature makes it possible to execute different code
1455 depending on the panic strategy.
1457 Possible values at the moment are `"unwind"` or `"abort"`, although
1458 it is possible that new panic strategies may be added to Rust in the
1464 #![feature(cfg_panic)]
1466 #[cfg(panic = "unwind")]
1471 #[cfg(not(panic = "unwind"))]
1477 if cfg!(panic = "abort") {
1487 label
: "cfg_sanitize",
1488 description
: r
##"# `cfg_sanitize`
1490 The tracking issue for this feature is: [#39699]
1492 [#39699]: https://github.com/rust-lang/rust/issues/39699
1494 ------------------------
1496 The `cfg_sanitize` feature makes it possible to execute different code
1497 depending on whether a particular sanitizer is enabled or not.
1502 #![feature(cfg_sanitize)]
1504 #[cfg(sanitize = "thread")]
1509 #[cfg(not(sanitize = "thread"))]
1515 if cfg!(sanitize = "leak") {
1525 label
: "cfg_version",
1526 description
: r
##"# `cfg_version`
1528 The tracking issue for this feature is: [#64796]
1530 [#64796]: https://github.com/rust-lang/rust/issues/64796
1532 ------------------------
1534 The `cfg_version` feature makes it possible to execute different code
1535 depending on the compiler version. It will return true if the compiler
1536 version is greater than or equal to the specified version.
1541 #![feature(cfg_version)]
1543 #[cfg(version("1.42"))] // 1.42 and above
1548 #[cfg(not(version("1.42")))] // 1.41 and below
1554 if cfg!(version("1.42")) {
1564 label
: "char_error_internals",
1565 description
: r
##"# `char_error_internals`
1567 This feature is internal to the Rust compiler and is not intended for general use.
1569 ------------------------
1573 label
: "closure_track_caller",
1574 description
: r
##"# `closure_track_caller`
1576 The tracking issue for this feature is: [#87417]
1578 [#87417]: https://github.com/rust-lang/rust/issues/87417
1580 ------------------------
1582 Allows using the `#[track_caller]` attribute on closures and generators.
1583 Calls made to the closure or generator will have caller information
1584 available through `std::panic::Location::caller()`, just like using
1585 `#[track_caller]` on a function.
1589 label
: "cmse_nonsecure_entry",
1590 description
: r
##"# `cmse_nonsecure_entry`
1592 The tracking issue for this feature is: [#75835]
1594 [#75835]: https://github.com/rust-lang/rust/issues/75835
1596 ------------------------
1599 feature](https://developer.arm.com/documentation/100690/latest/) is available
1600 for targets with the Armv8-M architecture profile (`thumbv8m` in their target
1602 LLVM, the Rust compiler and the linker are providing
1603 [support](https://developer.arm.com/documentation/ecm0359818/latest/) for the
1604 TrustZone-M feature.
1606 One of the things provided, with this unstable feature, is the
1607 `cmse_nonsecure_entry` attribute. This attribute marks a Secure function as an
1608 entry function (see [section
1609 5.4](https://developer.arm.com/documentation/ecm0359818/latest/) for details).
1610 With this attribute, the compiler will do the following:
1611 * add a special symbol on the function which is the `__acle_se_` prefix and the
1612 standard function name
1613 * constrain the number of parameters to avoid using the Non-Secure stack
1614 * before returning from the function, clear registers that might contain Secure
1616 * use the `BXNS` instruction to return
1618 Because the stack can not be used to pass parameters, there will be compilation
1620 * the total size of all parameters is too big (for example more than four 32
1622 * the entry function is not using a C ABI
1624 The special symbol `__acle_se_` will be used by the linker to generate a secure
1627 <!-- NOTE(ignore) this example is specific to thumbv8m targets -->
1630 #![feature(cmse_nonsecure_entry)]
1633 #[cmse_nonsecure_entry]
1634 pub extern "C" fn entry_function(input: u32) -> u32 {
1640 $ rustc --emit obj --crate-type lib --target thumbv8m.main-none-eabi function.rs
1641 $ arm-none-eabi-objdump -D function.o
1643 00000000 <entry_function>:
1644 0: b580 push {r7, lr}
1647 6: 9001 str r0, [sp, #4]
1648 8: 1d81 adds r1, r0, #6
1651 e: 9200 str r2, [sp, #0]
1652 10: d30b bcc.n 2a <entry_function+0x2a>
1653 12: e7ff b.n 14 <entry_function+0x14>
1654 14: 9800 ldr r0, [sp, #0]
1656 18: e8bd 4080 ldmia.w sp!, {r7, lr}
1661 24: f38e 8800 msr CPSR_f, lr
1663 2a: f240 0000 movw r0, #0
1664 2e: f2c0 0000 movt r0, #0
1665 32: f240 0200 movw r2, #0
1666 36: f2c0 0200 movt r2, #0
1667 3a: 211c movs r1, #28
1668 3c: f7ff fffe bl 0 <_ZN4core9panicking5panic17h5c028258ca2fb3f5E>
1669 40: defe udf #254 ; 0xfe
1674 label
: "compiler_builtins",
1675 description
: r
##"# `compiler_builtins`
1677 This feature is internal to the Rust compiler and is not intended for general use.
1679 ------------------------
1683 label
: "concat_idents",
1684 description
: r
##"# `concat_idents`
1686 The tracking issue for this feature is: [#29599]
1688 [#29599]: https://github.com/rust-lang/rust/issues/29599
1690 ------------------------
1692 The `concat_idents` feature adds a macro for concatenating multiple identifiers
1693 into one identifier.
1698 #![feature(concat_idents)]
1701 fn foobar() -> u32 { 23 }
1702 let f = concat_idents!(foo, bar);
1703 assert_eq!(f(), 23);
1709 label
: "const_eval_limit",
1710 description
: r
##"# `const_eval_limit`
1712 The tracking issue for this feature is: [#67217]
1714 [#67217]: https://github.com/rust-lang/rust/issues/67217
1716 The `const_eval_limit` allows someone to limit the evaluation steps the CTFE undertakes to evaluate a `const fn`.
1720 label
: "core_intrinsics",
1721 description
: r
##"# `core_intrinsics`
1723 This feature is internal to the Rust compiler and is not intended for general use.
1725 ------------------------
1729 label
: "core_panic",
1730 description
: r
##"# `core_panic`
1732 This feature is internal to the Rust compiler and is not intended for general use.
1734 ------------------------
1738 label
: "core_private_bignum",
1739 description
: r
##"# `core_private_bignum`
1741 This feature is internal to the Rust compiler and is not intended for general use.
1743 ------------------------
1747 label
: "core_private_diy_float",
1748 description
: r
##"# `core_private_diy_float`
1750 This feature is internal to the Rust compiler and is not intended for general use.
1752 ------------------------
1756 label
: "crate_visibility_modifier",
1757 description
: r
##"# `crate_visibility_modifier`
1759 The tracking issue for this feature is: [#53120]
1761 [#53120]: https://github.com/rust-lang/rust/issues/53120
1765 The `crate_visibility_modifier` feature allows the `crate` keyword to be used
1766 as a visibility modifier synonymous to `pub(crate)`, indicating that a type
1767 (function, _&c._) is to be visible to the entire enclosing crate, but not to
1771 #![feature(crate_visibility_modifier)]
1780 label
: "custom_test_frameworks",
1781 description
: r
##"# `custom_test_frameworks`
1783 The tracking issue for this feature is: [#50297]
1785 [#50297]: https://github.com/rust-lang/rust/issues/50297
1787 ------------------------
1789 The `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`.
1790 Any function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`)
1791 and be passed to the test runner determined by the `#![test_runner]` crate attribute.
1794 #![feature(custom_test_frameworks)]
1795 #![test_runner(my_runner)]
1797 fn my_runner(tests: &[&i32]) {
1808 const WILL_PASS: i32 = 0;
1811 const WILL_FAIL: i32 = 4;
1817 description
: r
##"# `dec2flt`
1819 This feature is internal to the Rust compiler and is not intended for general use.
1821 ------------------------
1825 label
: "default_free_fn",
1826 description
: r
##"# `default_free_fn`
1828 The tracking issue for this feature is: [#73014]
1830 [#73014]: https://github.com/rust-lang/rust/issues/73014
1832 ------------------------
1834 Adds a free `default()` function to the `std::default` module. This function
1835 just forwards to [`Default::default()`], but may remove repetition of the word
1836 "default" from the call site.
1838 [`Default::default()`]: https://doc.rust-lang.org/nightly/std/default/trait.Default.html#tymethod.default
1843 #![feature(default_free_fn)]
1844 use std::default::default;
1864 let options = AppConfig {
1876 label
: "derive_clone_copy",
1877 description
: r
##"# `derive_clone_copy`
1879 This feature is internal to the Rust compiler and is not intended for general use.
1881 ------------------------
1886 description
: r
##"# `derive_eq`
1888 This feature is internal to the Rust compiler and is not intended for general use.
1890 ------------------------
1895 description
: r
##"# `doc_cfg`
1897 The tracking issue for this feature is: [#43781]
1901 The `doc_cfg` feature allows an API be documented as only available in some specific platforms.
1902 This attribute has two effects:
1904 1. In the annotated item's documentation, there will be a message saying "This is supported on
1907 2. The item's doc-tests will only run on the specific platform.
1909 In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a
1910 special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your
1913 This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
1914 standard library be documented.
1917 #![feature(doc_cfg)]
1919 #[cfg(any(windows, doc))]
1920 #[doc(cfg(windows))]
1921 /// The application's icon in the notification area (a.k.a. system tray).
1926 /// extern crate my_awesome_ui_library;
1927 /// use my_awesome_ui_library::current_app;
1928 /// use my_awesome_ui_library::windows::notification;
1930 /// let icon = current_app().get::<notification::Icon>();
1932 /// icon.show_message("Hello
");
1939 [#43781]: https://github.com/rust-lang/rust/issues/43781
1940 [#43348]: https://github.com/rust-lang/rust/issues/43348
1944 label
: "doc_masked",
1945 description
: r
##"# `doc_masked`
1947 The tracking issue for this feature is: [#44027]
1951 The `doc_masked` feature allows a crate to exclude types from a given crate from appearing in lists
1952 of trait implementations. The specifics of the feature are as follows:
1954 1. When rustdoc encounters an `extern crate` statement annotated with a `#[doc(masked)]` attribute,
1955 it marks the crate as being masked.
1957 2. When listing traits a given type implements, rustdoc ensures that traits from masked crates are
1958 not emitted into the documentation.
1960 3. When listing types that implement a given trait, rustdoc ensures that types from masked crates
1961 are not emitted into the documentation.
1963 This feature was introduced in PR [#44026] to ensure that compiler-internal and
1964 implementation-specific types and traits were not included in the standard library's documentation.
1965 Such types would introduce broken links into the documentation.
1967 [#44026]: https://github.com/rust-lang/rust/pull/44026
1968 [#44027]: https://github.com/rust-lang/rust/pull/44027
1972 label
: "doc_notable_trait",
1973 description
: r
##"# `doc_notable_trait`
1975 The tracking issue for this feature is: [#45040]
1977 The `doc_notable_trait` feature allows the use of the `#[doc(notable_trait)]`
1978 attribute, which will display the trait in a "Notable traits" dialog for
1979 functions returning types that implement the trait. For example, this attribute
1980 is applied to the `Iterator`, `Future`, `io::Read`, and `io::Write` traits in
1981 the standard library.
1983 You can do this on your own traits like so:
1986 #![feature(doc_notable_trait)]
1988 #[doc(notable_trait)]
1989 pub trait MyTrait {}
1991 pub struct MyStruct;
1992 impl MyTrait for MyStruct {}
1994 /// The docs for this function will have a button that displays a dialog about
1995 /// `MyStruct` implementing `MyTrait`.
1996 pub fn my_fn() -> MyStruct { MyStruct }
1999 This feature was originally implemented in PR [#45039].
2001 See also its documentation in [the rustdoc book][rustdoc-book-notable_trait].
2003 [#45040]: https://github.com/rust-lang/rust/issues/45040
2004 [#45039]: https://github.com/rust-lang/rust/pull/45039
2005 [rustdoc-book-notable_trait]: ../../rustdoc/unstable-features.html#adding-your-trait-to-the-notable-traits-dialog
2009 label
: "exclusive_range_pattern",
2010 description
: r
##"# `exclusive_range_pattern`
2012 The tracking issue for this feature is: [#37854].
2015 [#67264]: https://github.com/rust-lang/rust/issues/67264
2016 [#37854]: https://github.com/rust-lang/rust/issues/37854
2019 The `exclusive_range_pattern` feature allows non-inclusive range
2020 patterns (`0..10`) to be used in appropriate pattern matching
2021 contexts. It also can be combined with `#![feature(half_open_range_patterns]`
2022 to be able to use RangeTo patterns (`..10`).
2024 It also enabled RangeFrom patterns but that has since been
2028 #![feature(exclusive_range_pattern)]
2031 0..10 => println!("single digit"),
2032 10 => println!("ten isn't part of the above range"),
2033 _ => println!("nor is everything else.")
2039 label
: "explicit_generic_args_with_impl_trait",
2040 description
: r
##"# `explicit_generic_args_with_impl_trait`
2042 The tracking issue for this feature is: [#83701]
2044 [#83701]: https://github.com/rust-lang/rust/issues/83701
2046 ------------------------
2048 The `explicit_generic_args_with_impl_trait` feature gate lets you specify generic arguments even
2049 when `impl Trait` is used in argument position.
2051 A simple example is:
2054 #![feature(explicit_generic_args_with_impl_trait)]
2056 fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
2059 foo::<str>("".to_string());
2063 This is currently rejected:
2066 error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
2067 --> src/main.rs:6:11
2069 6 | foo::<str>("".to_string());
2070 | ^^^ explicit generic argument not allowed
2074 However it would compile if `explicit_generic_args_with_impl_trait` is enabled.
2076 Note that the synthetic type parameters from `impl Trait` are still implicit and you
2077 cannot explicitly specify these:
2079 ```rust,compile_fail
2080 #![feature(explicit_generic_args_with_impl_trait)]
2082 fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
2083 fn bar<T: ?Sized, F: AsRef<T>>(_f: F) {}
2086 bar::<str, _>("".to_string()); // Okay
2087 bar::<str, String>("".to_string()); // Okay
2089 foo::<str>("".to_string()); // Okay
2090 foo::<str, String>("".to_string()); // Error, you cannot specify `impl Trait` explicitly
2097 description
: r
##"# `fd`
2099 This feature is internal to the Rust compiler and is not intended for general use.
2101 ------------------------
2106 description
: r
##"# `fd_read`
2108 This feature is internal to the Rust compiler and is not intended for general use.
2110 ------------------------
2115 description
: r
##"# `ffi_const`
2117 The tracking issue for this feature is: [#58328]
2121 The `#[ffi_const]` attribute applies clang's `const` attribute to foreign
2122 functions declarations.
2124 That is, `#[ffi_const]` functions shall have no effects except for its return
2125 value, which can only depend on the values of the function parameters, and is
2126 not affected by changes to the observable state of the program.
2128 Applying the `#[ffi_const]` attribute to a function that violates these
2129 requirements is undefined behaviour.
2131 This attribute enables Rust to perform common optimizations, like sub-expression
2132 elimination, and it can avoid emitting some calls in repeated invocations of the
2133 function with the same argument values regardless of other operations being
2134 performed in between these functions calls (as opposed to `#[ffi_pure]`
2139 A `#[ffi_const]` function can only read global memory that would not affect
2140 its return value for the whole execution of the program (e.g. immutable global
2141 memory). `#[ffi_const]` functions are referentially-transparent and therefore
2142 more strict than `#[ffi_pure]` functions.
2144 A common pitfall involves applying the `#[ffi_const]` attribute to a
2145 function that reads memory through pointer arguments which do not necessarily
2146 point to immutable global memory.
2148 A `#[ffi_const]` function that returns unit has no effect on the abstract
2149 machine's state, and a `#[ffi_const]` function cannot be `#[ffi_pure]`.
2151 A `#[ffi_const]` function must not diverge, neither via a side effect (e.g. a
2152 call to `abort`) nor by infinite loops.
2154 When translating C headers to Rust FFI, it is worth verifying for which targets
2155 the `const` attribute is enabled in those headers, and using the appropriate
2156 `cfg` macros in the Rust side to match those definitions. While the semantics of
2157 `const` are implemented identically by many C and C++ compilers, e.g., clang,
2158 [GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily
2159 implemented in this way on all of them. It is therefore also worth verifying
2160 that the semantics of the C toolchain used to compile the binary being linked
2161 against are compatible with those of the `#[ffi_const]`.
2163 [#58328]: https://github.com/rust-lang/rust/issues/58328
2164 [ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacgigch.html
2165 [GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute
2166 [IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_const.htm
2171 description
: r
##"# `ffi_pure`
2173 The tracking issue for this feature is: [#58329]
2177 The `#[ffi_pure]` attribute applies clang's `pure` attribute to foreign
2178 functions declarations.
2180 That is, `#[ffi_pure]` functions shall have no effects except for its return
2181 value, which shall not change across two consecutive function calls with
2182 the same parameters.
2184 Applying the `#[ffi_pure]` attribute to a function that violates these
2185 requirements is undefined behavior.
2187 This attribute enables Rust to perform common optimizations, like sub-expression
2188 elimination and loop optimizations. Some common examples of pure functions are
2189 `strlen` or `memcmp`.
2191 These optimizations are only applicable when the compiler can prove that no
2192 program state observable by the `#[ffi_pure]` function has changed between calls
2193 of the function, which could alter the result. See also the `#[ffi_const]`
2194 attribute, which provides stronger guarantees regarding the allowable behavior
2195 of a function, enabling further optimization.
2199 A `#[ffi_pure]` function can read global memory through the function
2200 parameters (e.g. pointers), globals, etc. `#[ffi_pure]` functions are not
2201 referentially-transparent, and are therefore more relaxed than `#[ffi_const]`
2204 However, accessing global memory through volatile or atomic reads can violate the
2205 requirement that two consecutive function calls shall return the same value.
2207 A `pure` function that returns unit has no effect on the abstract machine's
2210 A `#[ffi_pure]` function must not diverge, neither via a side effect (e.g. a
2211 call to `abort`) nor by infinite loops.
2213 When translating C headers to Rust FFI, it is worth verifying for which targets
2214 the `pure` attribute is enabled in those headers, and using the appropriate
2215 `cfg` macros in the Rust side to match those definitions. While the semantics of
2216 `pure` are implemented identically by many C and C++ compilers, e.g., clang,
2217 [GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily
2218 implemented in this way on all of them. It is therefore also worth verifying
2219 that the semantics of the C toolchain used to compile the binary being linked
2220 against are compatible with those of the `#[ffi_pure]`.
2223 [#58329]: https://github.com/rust-lang/rust/issues/58329
2224 [ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacigdac.html
2225 [GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
2226 [IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_pure.htm
2231 description
: r
##"# `flt2dec`
2233 This feature is internal to the Rust compiler and is not intended for general use.
2235 ------------------------
2239 label
: "fmt_internals",
2240 description
: r
##"# `fmt_internals`
2242 This feature is internal to the Rust compiler and is not intended for general use.
2244 ------------------------
2249 description
: r
##"# `fn_traits`
2251 The tracking issue for this feature is [#29625]
2253 See Also: [`unboxed_closures`](../language-features/unboxed-closures.md)
2255 [#29625]: https://github.com/rust-lang/rust/issues/29625
2259 The `fn_traits` feature allows for implementation of the [`Fn*`] traits
2260 for creating custom closure-like types.
2262 [`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html
2265 #![feature(unboxed_closures)]
2266 #![feature(fn_traits)]
2272 impl FnOnce<(u32, )> for Adder {
2274 extern "rust-call" fn call_once(self, b: (u32, )) -> Self::Output {
2280 let adder = Adder { a: 3 };
2281 assert_eq!(adder(2), 5);
2287 label
: "generators",
2288 description
: r
##"# `generators`
2290 The tracking issue for this feature is: [#43122]
2292 [#43122]: https://github.com/rust-lang/rust/issues/43122
2294 ------------------------
2296 The `generators` feature gate in Rust allows you to define generator or
2297 coroutine literals. A generator is a "resumable function" that syntactically
2298 resembles a closure but compiles to much different semantics in the compiler
2299 itself. The primary feature of a generator is that it can be suspended during
2300 execution to be resumed at a later date. Generators use the `yield` keyword to
2301 "return", and then the caller can `resume` a generator to resume execution just
2302 after the `yield` keyword.
2304 Generators are an extra-unstable feature in the compiler right now. Added in
2305 [RFC 2033] they're mostly intended right now as a information/constraint
2306 gathering phase. The intent is that experimentation can happen on the nightly
2307 compiler before actual stabilization. A further RFC will be required to
2308 stabilize generators/coroutines and will likely contain at least a few small
2309 tweaks to the overall design.
2311 [RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033
2313 A syntactical example of a generator is:
2316 #![feature(generators, generator_trait)]
2318 use std::ops::{Generator, GeneratorState};
2322 let mut generator = || {
2327 match Pin::new(&mut generator).resume(()) {
2328 GeneratorState::Yielded(1) => {}
2329 _ => panic!("unexpected value from resume"),
2331 match Pin::new(&mut generator).resume(()) {
2332 GeneratorState::Complete("foo") => {}
2333 _ => panic!("unexpected value from resume"),
2338 Generators are closure-like literals which can contain a `yield` statement. The
2339 `yield` statement takes an optional expression of a value to yield out of the
2340 generator. All generator literals implement the `Generator` trait in the
2341 `std::ops` module. The `Generator` trait has one main method, `resume`, which
2342 resumes execution of the generator at the previous suspension point.
2344 An example of the control flow of generators is that the following example
2345 prints all numbers in order:
2348 #![feature(generators, generator_trait)]
2350 use std::ops::Generator;
2354 let mut generator = || {
2361 Pin::new(&mut generator).resume(());
2363 Pin::new(&mut generator).resume(());
2368 At this time the main intended use case of generators is an implementation
2369 primitive for async/await syntax, but generators will likely be extended to
2370 ergonomic implementations of iterators and other primitives in the future.
2371 Feedback on the design and usage is always appreciated!
2373 ### The `Generator` trait
2375 The `Generator` trait in `std::ops` currently looks like:
2378 # #![feature(arbitrary_self_types, generator_trait)]
2379 # use std::ops::GeneratorState;
2380 # use std::pin::Pin;
2382 pub trait Generator<R = ()> {
2385 fn resume(self: Pin<&mut Self>, resume: R) -> GeneratorState<Self::Yield, Self::Return>;
2389 The `Generator::Yield` type is the type of values that can be yielded with the
2390 `yield` statement. The `Generator::Return` type is the returned type of the
2391 generator. This is typically the last expression in a generator's definition or
2392 any value passed to `return` in a generator. The `resume` function is the entry
2393 point for executing the `Generator` itself.
2395 The return value of `resume`, `GeneratorState`, looks like:
2398 pub enum GeneratorState<Y, R> {
2404 The `Yielded` variant indicates that the generator can later be resumed. This
2405 corresponds to a `yield` point in a generator. The `Complete` variant indicates
2406 that the generator is complete and cannot be resumed again. Calling `resume`
2407 after a generator has returned `Complete` will likely result in a panic of the
2410 ### Closure-like semantics
2412 The closure-like syntax for generators alludes to the fact that they also have
2413 closure-like semantics. Namely:
2415 * When created, a generator executes no code. A closure literal does not
2416 actually execute any of the closure's code on construction, and similarly a
2417 generator literal does not execute any code inside the generator when
2420 * Generators can capture outer variables by reference or by move, and this can
2421 be tweaked with the `move` keyword at the beginning of the closure. Like
2422 closures all generators will have an implicit environment which is inferred by
2423 the compiler. Outer variables can be moved into a generator for use as the
2424 generator progresses.
2426 * Generator literals produce a value with a unique type which implements the
2427 `std::ops::Generator` trait. This allows actual execution of the generator
2428 through the `Generator::resume` method as well as also naming it in return
2431 * Traits like `Send` and `Sync` are automatically implemented for a `Generator`
2432 depending on the captured variables of the environment. Unlike closures,
2433 generators also depend on variables live across suspension points. This means
2434 that although the ambient environment may be `Send` or `Sync`, the generator
2435 itself may not be due to internal variables live across `yield` points being
2436 not-`Send` or not-`Sync`. Note that generators do
2437 not implement traits like `Copy` or `Clone` automatically.
2439 * Whenever a generator is dropped it will drop all captured environment
2442 ### Generators as state machines
2444 In the compiler, generators are currently compiled as state machines. Each
2445 `yield` expression will correspond to a different state that stores all live
2446 variables over that suspension point. Resumption of a generator will dispatch on
2447 the current state and then execute internally until a `yield` is reached, at
2448 which point all state is saved off in the generator and a value is returned.
2450 Let's take a look at an example to see what's going on here:
2453 #![feature(generators, generator_trait)]
2455 use std::ops::Generator;
2460 let mut generator = move || {
2465 Pin::new(&mut generator).resume(());
2466 Pin::new(&mut generator).resume(());
2470 This generator literal will compile down to something similar to:
2473 #![feature(arbitrary_self_types, generators, generator_trait)]
2475 use std::ops::{Generator, GeneratorState};
2480 let mut generator = {
2482 Start(&'static str),
2483 Yield1(&'static str),
2487 impl Generator for __Generator {
2489 type Return = &'static str;
2491 fn resume(mut self: Pin<&mut Self>, resume: ()) -> GeneratorState<i32, &'static str> {
2493 match mem::replace(&mut *self, __Generator::Done) {
2494 __Generator::Start(s) => {
2495 *self = __Generator::Yield1(s);
2496 GeneratorState::Yielded(1)
2499 __Generator::Yield1(s) => {
2500 *self = __Generator::Done;
2501 GeneratorState::Complete(s)
2504 __Generator::Done => {
2505 panic!("generator resumed after completion")
2511 __Generator::Start(ret)
2514 Pin::new(&mut generator).resume(());
2515 Pin::new(&mut generator).resume(());
2519 Notably here we can see that the compiler is generating a fresh type,
2520 `__Generator` in this case. This type has a number of states (represented here
2521 as an `enum`) corresponding to each of the conceptual states of the generator.
2522 At the beginning we're closing over our outer variable `foo` and then that
2523 variable is also live over the `yield` point, so it's stored in both states.
2525 When the generator starts it'll immediately yield 1, but it saves off its state
2526 just before it does so indicating that it has reached the yield point. Upon
2527 resuming again we'll execute the `return ret` which returns the `Complete`
2530 Here we can also note that the `Done` state, if resumed, panics immediately as
2531 it's invalid to resume a completed generator. It's also worth noting that this
2532 is just a rough desugaring, not a normative specification for what the compiler
2537 label
: "half_open_range_patterns",
2538 description
: r
##"# `half_open_range_patterns`
2540 The tracking issue for this feature is: [#67264]
2541 It is part of the `#![exclusive_range_pattern]` feature,
2542 tracked at [#37854].
2544 [#67264]: https://github.com/rust-lang/rust/issues/67264
2545 [#37854]: https://github.com/rust-lang/rust/issues/37854
2548 The `half_open_range_patterns` feature allows RangeTo patterns
2549 (`..10`) to be used in appropriate pattern matching contexts.
2550 This requires also enabling the `exclusive_range_pattern` feature.
2552 It also enabled RangeFrom patterns but that has since been
2556 #![feature(half_open_range_patterns)]
2557 #![feature(exclusive_range_pattern)]
2560 ..0 => println!("negative!"), // "RangeTo" pattern. Unstable.
2561 0 => println!("zero!"),
2562 1.. => println!("positive!"), // "RangeFrom" pattern. Stable.
2568 label
: "infer_static_outlives_requirements",
2569 description
: r
##"# `infer_static_outlives_requirements`
2571 The tracking issue for this feature is: [#54185]
2573 [#54185]: https://github.com/rust-lang/rust/issues/54185
2575 ------------------------
2576 The `infer_static_outlives_requirements` feature indicates that certain
2577 `'static` outlives requirements can be inferred by the compiler rather than
2578 stating them explicitly.
2580 Note: It is an accompanying feature to `infer_outlives_requirements`,
2581 which must be enabled to infer outlives requirements.
2583 For example, currently generic struct definitions that contain
2584 references, require where-clauses of the form T: 'static. By using
2585 this feature the outlives predicates will be inferred, although
2586 they may still be written explicitly.
2588 ```rust,ignore (pseudo-Rust)
2589 struct Foo<U> where U: 'static { // <-- currently required
2592 struct Bar<T: 'static> {
2600 ```rust,ignore (pseudo-Rust)
2601 #![feature(infer_outlives_requirements)]
2602 #![feature(infer_static_outlives_requirements)]
2605 // Implicitly infer U: 'static
2609 struct Bar<T: 'static> {
2616 label
: "inline_const",
2617 description
: r
##"# `inline_const`
2619 The tracking issue for this feature is: [#76001]
2621 See also [`inline_const_pat`](inline-const-pat.md)
2625 This feature allows you to use inline constant expressions. For example, you can
2629 # fn add_one(x: i32) -> i32 { x + 1 }
2630 const MY_COMPUTATION: i32 = 1 + 2 * 3 / 4;
2633 let x = add_one(MY_COMPUTATION);
2640 #![feature(inline_const)]
2642 # fn add_one(x: i32) -> i32 { x + 1 }
2644 let x = add_one(const { 1 + 2 * 3 / 4 });
2648 [#76001]: https://github.com/rust-lang/rust/issues/76001
2652 label
: "inline_const_pat",
2653 description
: r
##"# `inline_const_pat`
2655 The tracking issue for this feature is: [#76001]
2657 See also [`inline_const`](inline-const.md)
2661 This feature allows you to use inline constant expressions in pattern position:
2664 #![feature(inline_const_pat)]
2666 const fn one() -> i32 { 1 }
2670 const { 1 + 2 } => println!("Matched 1 + 2"),
2671 const { one() } => println!("Matched const fn returning 1"),
2672 _ => println!("Didn't match anything :("),
2676 [#76001]: https://github.com/rust-lang/rust/issues/76001
2680 label
: "int_error_internals",
2681 description
: r
##"# `int_error_internals`
2683 This feature is internal to the Rust compiler and is not intended for general use.
2685 ------------------------
2689 label
: "internal_output_capture",
2690 description
: r
##"# `internal_output_capture`
2692 This feature is internal to the Rust compiler and is not intended for general use.
2694 ------------------------
2698 label
: "intra_doc_pointers",
2699 description
: r
##"# `intra-doc-pointers`
2701 The tracking issue for this feature is: [#80896]
2703 [#80896]: https://github.com/rust-lang/rust/issues/80896
2705 ------------------------
2707 Rustdoc does not currently allow disambiguating between `*const` and `*mut`, and
2708 raw pointers in intra-doc links are unstable until it does.
2711 #![feature(intra_doc_pointers)]
2717 label
: "intrinsics",
2718 description
: r
##"# `intrinsics`
2720 The tracking issue for this feature is: None.
2722 Intrinsics are never intended to be stable directly, but intrinsics are often
2723 exported in some sort of stable manner. Prefer using the stable interfaces to
2724 the intrinsic directly when you can.
2726 ------------------------
2729 These are imported as if they were FFI functions, with the special
2730 `rust-intrinsic` ABI. For example, if one was in a freestanding
2731 context, but wished to be able to `transmute` between types, and
2732 perform efficient pointer arithmetic, one would import those functions
2733 via a declaration like
2736 #![feature(intrinsics)]
2739 extern "rust-intrinsic" {
2740 fn transmute<T, U>(x: T) -> U;
2742 fn offset<T>(dst: *const T, offset: isize) -> *const T;
2746 As with any other FFI functions, these are always `unsafe` to call.
2751 description
: r
##"# `is_sorted`
2753 The tracking issue for this feature is: [#53485]
2755 [#53485]: https://github.com/rust-lang/rust/issues/53485
2757 ------------------------
2759 Add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to `[T]`;
2760 add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to
2765 label
: "lang_items",
2766 description
: r
##"# `lang_items`
2768 The tracking issue for this feature is: None.
2770 ------------------------
2772 The `rustc` compiler has certain pluggable operations, that is,
2773 functionality that isn't hard-coded into the language, but is
2774 implemented in libraries, with a special marker to tell the compiler
2775 it exists. The marker is the attribute `#[lang = "..."]` and there are
2776 various different values of `...`, i.e. various different 'lang
2779 For example, `Box` pointers require two lang items, one for allocation
2780 and one for deallocation. A freestanding program that uses the `Box`
2781 sugar for dynamic allocations via `malloc` and `free`:
2783 ```rust,ignore (libc-is-finicky)
2784 #![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)]
2786 use core::intrinsics;
2787 use core::panic::PanicInfo;
2791 #[lang = "owned_box"]
2792 pub struct Box<T>(*mut T);
2794 #[lang = "exchange_malloc"]
2795 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
2796 let p = libc::malloc(size as libc::size_t) as *mut u8;
2798 // Check if `malloc` failed:
2799 if p as usize == 0 {
2800 intrinsics::abort();
2806 #[lang = "box_free"]
2807 unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
2808 libc::free(ptr as *mut libc::c_void)
2812 fn main(_argc: isize, _argv: *const *const u8) -> isize {
2818 #[lang = "eh_personality"] extern fn rust_eh_personality() {}
2819 #[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
2820 #[no_mangle] pub extern fn rust_eh_register_frames () {}
2821 #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
2824 Note the use of `abort`: the `exchange_malloc` lang item is assumed to
2825 return a valid pointer, and so needs to do the check internally.
2827 Other features provided by lang items include:
2829 - overloadable operators via traits: the traits corresponding to the
2830 `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
2831 marked with lang items; those specific four are `eq`, `ord`,
2832 `deref`, and `add` respectively.
2833 - stack unwinding and general failure; the `eh_personality`,
2834 `panic` and `panic_bounds_check` lang items.
2835 - the traits in `std::marker` used to indicate types of
2836 various kinds; lang items `send`, `sync` and `copy`.
2837 - the marker types and variance indicators found in
2838 `std::marker`; lang items `covariant_type`,
2839 `contravariant_lifetime`, etc.
2841 Lang items are loaded lazily by the compiler; e.g. if one never uses
2842 `Box` then there is no need to define functions for `exchange_malloc`
2843 and `box_free`. `rustc` will emit an error when an item is needed
2844 but not found in the current crate or any that it depends on.
2846 Most lang items are defined by `libcore`, but if you're trying to build
2847 an executable without the standard library, you'll run into the need
2848 for lang items. The rest of this page focuses on this use-case, even though
2849 lang items are a bit broader than that.
2853 In order to build a `#[no_std]` executable we will need libc as a dependency.
2854 We can specify this using our `Cargo.toml` file:
2858 libc = { version = "0.2.14", default-features = false }
2861 Note that the default features have been disabled. This is a critical step -
2862 **the default features of libc include the standard library and so must be
2865 ### Writing an executable without stdlib
2867 Controlling the entry point is possible in two ways: the `#[start]` attribute,
2868 or overriding the default shim for the C `main` function with your own.
2870 The function marked `#[start]` is passed the command line parameters
2871 in the same format as C:
2873 ```rust,ignore (libc-is-finicky)
2874 #![feature(lang_items, core_intrinsics, rustc_private)]
2877 use core::intrinsics;
2878 use core::panic::PanicInfo;
2880 // Pull in the system libc library for what crt0.o likely requires.
2883 // Entry point for this program.
2885 fn start(_argc: isize, _argv: *const *const u8) -> isize {
2889 // These functions are used by the compiler, but not
2890 // for a bare-bones hello world. These are normally
2891 // provided by libstd.
2892 #[lang = "eh_personality"]
2894 pub extern fn rust_eh_personality() {
2897 #[lang = "panic_impl"]
2899 pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
2900 unsafe { intrinsics::abort() }
2904 To override the compiler-inserted `main` shim, one has to disable it
2905 with `#![no_main]` and then create the appropriate symbol with the
2906 correct ABI and the correct name, which requires overriding the
2907 compiler's name mangling too:
2909 ```rust,ignore (libc-is-finicky)
2910 #![feature(lang_items, core_intrinsics, rustc_private)]
2914 use core::intrinsics;
2915 use core::panic::PanicInfo;
2917 // Pull in the system libc library for what crt0.o likely requires.
2920 // Entry point for this program.
2921 #[no_mangle] // ensure that this symbol is called `main` in the output
2922 pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
2926 // These functions are used by the compiler, but not
2927 // for a bare-bones hello world. These are normally
2928 // provided by libstd.
2929 #[lang = "eh_personality"]
2931 pub extern fn rust_eh_personality() {
2934 #[lang = "panic_impl"]
2936 pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
2937 unsafe { intrinsics::abort() }
2941 In many cases, you may need to manually link to the `compiler_builtins` crate
2942 when building a `no_std` binary. You may observe this via linker error messages
2943 such as "```undefined reference to `__rust_probestack'```".
2945 ## More about the language items
2947 The compiler currently makes a few assumptions about symbols which are
2948 available in the executable to call. Normally these functions are provided by
2949 the standard library, but without it you must define your own. These symbols
2950 are called "language items", and they each have an internal name, and then a
2951 signature that an implementation must conform to.
2953 The first of these functions, `rust_eh_personality`, is used by the failure
2954 mechanisms of the compiler. This is often mapped to GCC's personality function
2955 (see the [libstd implementation][unwind] for more information), but crates
2956 which do not trigger a panic can be assured that this function is never
2957 called. The language item's name is `eh_personality`.
2959 [unwind]: https://github.com/rust-lang/rust/blob/master/library/panic_unwind/src/gcc.rs
2961 The second function, `rust_begin_panic`, is also used by the failure mechanisms of the
2962 compiler. When a panic happens, this controls the message that's displayed on
2963 the screen. While the language item's name is `panic_impl`, the symbol name is
2966 Finally, a `eh_catch_typeinfo` static is needed for certain targets which
2967 implement Rust panics on top of C++ exceptions.
2969 ## List of all language items
2971 This is a list of all language items in Rust along with where they are located in
2975 - `i8`: `libcore/num/mod.rs`
2976 - `i16`: `libcore/num/mod.rs`
2977 - `i32`: `libcore/num/mod.rs`
2978 - `i64`: `libcore/num/mod.rs`
2979 - `i128`: `libcore/num/mod.rs`
2980 - `isize`: `libcore/num/mod.rs`
2981 - `u8`: `libcore/num/mod.rs`
2982 - `u16`: `libcore/num/mod.rs`
2983 - `u32`: `libcore/num/mod.rs`
2984 - `u64`: `libcore/num/mod.rs`
2985 - `u128`: `libcore/num/mod.rs`
2986 - `usize`: `libcore/num/mod.rs`
2987 - `f32`: `libstd/f32.rs`
2988 - `f64`: `libstd/f64.rs`
2989 - `char`: `libcore/char.rs`
2990 - `slice`: `liballoc/slice.rs`
2991 - `str`: `liballoc/str.rs`
2992 - `const_ptr`: `libcore/ptr.rs`
2993 - `mut_ptr`: `libcore/ptr.rs`
2994 - `unsafe_cell`: `libcore/cell.rs`
2996 - `start`: `libstd/rt.rs`
2997 - `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)
2998 - `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)
2999 - `eh_personality`: `libpanic_unwind/seh.rs` (SEH)
3000 - `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)
3001 - `panic`: `libcore/panicking.rs`
3002 - `panic_bounds_check`: `libcore/panicking.rs`
3003 - `panic_impl`: `libcore/panicking.rs`
3004 - `panic_impl`: `libstd/panicking.rs`
3006 - `owned_box`: `liballoc/boxed.rs`
3007 - `exchange_malloc`: `liballoc/heap.rs`
3008 - `box_free`: `liballoc/heap.rs`
3010 - `not`: `libcore/ops/bit.rs`
3011 - `bitand`: `libcore/ops/bit.rs`
3012 - `bitor`: `libcore/ops/bit.rs`
3013 - `bitxor`: `libcore/ops/bit.rs`
3014 - `shl`: `libcore/ops/bit.rs`
3015 - `shr`: `libcore/ops/bit.rs`
3016 - `bitand_assign`: `libcore/ops/bit.rs`
3017 - `bitor_assign`: `libcore/ops/bit.rs`
3018 - `bitxor_assign`: `libcore/ops/bit.rs`
3019 - `shl_assign`: `libcore/ops/bit.rs`
3020 - `shr_assign`: `libcore/ops/bit.rs`
3021 - `deref`: `libcore/ops/deref.rs`
3022 - `deref_mut`: `libcore/ops/deref.rs`
3023 - `index`: `libcore/ops/index.rs`
3024 - `index_mut`: `libcore/ops/index.rs`
3025 - `add`: `libcore/ops/arith.rs`
3026 - `sub`: `libcore/ops/arith.rs`
3027 - `mul`: `libcore/ops/arith.rs`
3028 - `div`: `libcore/ops/arith.rs`
3029 - `rem`: `libcore/ops/arith.rs`
3030 - `neg`: `libcore/ops/arith.rs`
3031 - `add_assign`: `libcore/ops/arith.rs`
3032 - `sub_assign`: `libcore/ops/arith.rs`
3033 - `mul_assign`: `libcore/ops/arith.rs`
3034 - `div_assign`: `libcore/ops/arith.rs`
3035 - `rem_assign`: `libcore/ops/arith.rs`
3036 - `eq`: `libcore/cmp.rs`
3037 - `ord`: `libcore/cmp.rs`
3039 - `fn`: `libcore/ops/function.rs`
3040 - `fn_mut`: `libcore/ops/function.rs`
3041 - `fn_once`: `libcore/ops/function.rs`
3042 - `generator_state`: `libcore/ops/generator.rs`
3043 - `generator`: `libcore/ops/generator.rs`
3045 - `coerce_unsized`: `libcore/ops/unsize.rs`
3046 - `drop`: `libcore/ops/drop.rs`
3047 - `drop_in_place`: `libcore/ptr.rs`
3048 - `clone`: `libcore/clone.rs`
3049 - `copy`: `libcore/marker.rs`
3050 - `send`: `libcore/marker.rs`
3051 - `sized`: `libcore/marker.rs`
3052 - `unsize`: `libcore/marker.rs`
3053 - `sync`: `libcore/marker.rs`
3054 - `phantom_data`: `libcore/marker.rs`
3055 - `discriminant_kind`: `libcore/marker.rs`
3056 - `freeze`: `libcore/marker.rs`
3057 - `debug_trait`: `libcore/fmt/mod.rs`
3058 - `non_zero`: `libcore/nonzero.rs`
3059 - `arc`: `liballoc/sync.rs`
3060 - `rc`: `liballoc/rc.rs`
3064 label
: "libstd_sys_internals",
3065 description
: r
##"# `libstd_sys_internals`
3067 This feature is internal to the Rust compiler and is not intended for general use.
3069 ------------------------
3073 label
: "libstd_thread_internals",
3074 description
: r
##"# `libstd_thread_internals`
3076 This feature is internal to the Rust compiler and is not intended for general use.
3078 ------------------------
3083 description
: r
##"# `link_cfg`
3085 This feature is internal to the Rust compiler and is not intended for general use.
3087 ------------------------
3092 description
: r
##"# `llvm_asm`
3094 The tracking issue for this feature is: [#70173]
3096 [#70173]: https://github.com/rust-lang/rust/issues/70173
3098 ------------------------
3100 For extremely low-level manipulations and performance reasons, one
3101 might wish to control the CPU directly. Rust supports using inline
3102 assembly to do this via the `llvm_asm!` macro.
3104 ```rust,ignore (pseudo-code)
3105 llvm_asm!(assembly template
3113 Any use of `llvm_asm` is feature gated (requires `#![feature(llvm_asm)]` on the
3114 crate to allow) and of course requires an `unsafe` block.
3116 > **Note**: the examples here are given in x86/x86-64 assembly, but
3117 > all platforms are supported.
3119 ## Assembly template
3121 The `assembly template` is the only required parameter and must be a
3122 literal string (i.e. `""`)
3125 #![feature(llvm_asm)]
3127 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3135 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
3136 fn foo() { /* ... */ }
3145 (The `feature(llvm_asm)` and `#[cfg]`s are omitted from now on.)
3147 Output operands, input operands, clobbers and options are all optional
3148 but you must add the right number of `:` if you skip them:
3151 # #![feature(llvm_asm)]
3152 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3153 # fn main() { unsafe {
3154 llvm_asm!("xor %eax, %eax"
3160 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
3164 Whitespace also doesn't matter:
3167 # #![feature(llvm_asm)]
3168 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3169 # fn main() { unsafe {
3170 llvm_asm!("xor %eax, %eax" ::: "eax");
3172 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
3178 Input and output operands follow the same format: `:
3179 "constraints1"(expr1), "constraints2"(expr2), ..."`. Output operand
3180 expressions must be mutable place
, or not yet assigned
:
3183 # #![feature(llvm_asm)]
3184 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3185 fn add(a
: i32, b
: i32) -> i32 {
3188 llvm_asm
!("add $2, $0"
3195 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
3196 # fn add(a: i32, b: i32) -> i32 { a + b }
3199 assert_eq
!(add(3, 14159), 14162)
3203 If you would like to
use real operands
in this position
, however
,
3204 you are required to put curly braces `{}` around the register that
3205 you want
, and you are required to put the specific size of the
3206 operand
. This is useful
for very low level programming
, where
3207 which register you
use is important
:
3210 # #![feature(llvm_asm)]
3211 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3212 # unsafe fn read_byte_in(port: u16) -> u8 {
3214 llvm_asm
!("in %dx, %al" : "={al}"(result
) : "{dx}"(port
));
3221 Some instructions modify registers which might otherwise have held
3222 different values so we
use the clobbers list to indicate to the
3223 compiler not to assume any values loaded into those registers will
3227 # #![feature(llvm_asm)]
3228 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3229 # fn main() { unsafe {
3230 // Put the value 0x200 in eax:
3231 llvm_asm
!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax");
3233 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
3237 Input and output registers need not be listed since that information
3238 is already communicated by the given constraints
. Otherwise
, any other
3239 registers used either implicitly or explicitly should be listed
.
3241 If the assembly changes the condition code register `cc` should be
3242 specified
as one of the clobbers
. Similarly
, if the assembly modifies
3243 memory
, `memory` should also be specified
.
3247 The last section
, `options` is specific to Rust
. The format is comma
3248 separated literal
strings (i
.e
. `
:"foo", "bar", "baz"`
). It's used to
3249 specify some extra info about the inline assembly
:
3251 Current valid options are
:
3253 1. `volatile`
- specifying this is analogous to
3254 `__asm__
__volatile__ (...)`
in gcc
/clang
.
3255 2. `alignstack`
- certain instructions expect the stack to be
3256 aligned a certain
way (i
.e
. SSE
) and specifying this indicates to
3257 the compiler to insert its usual stack alignment code
3258 3. `intel`
- use intel syntax instead of the
default AT
&T
.
3261 # #![feature(llvm_asm)]
3262 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3266 llvm_asm
!("mov eax, 2" : "={eax}"(result
) : : : "intel")
3268 println
!("eax is currently {}", result
);
3270 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
3276 The current implementation of the `llvm_asm
!`
macro is a direct binding to
[LLVM's
3277 inline assembler expressions
][llvm
-docs
], so be sure to check out
[their
3278 documentation
as well
][llvm
-docs
] for more information about clobbers
,
3281 [llvm
-docs
]: http
://llvm.org/docs/LangRef.html#inline-assembler-expressions
3285 label: "marker_trait_attr
",
3286 description: r##"# `marker_trait_attr`
3288 The tracking issue
for this feature is
: [#29864]
3290 [#29864]: https://github.com/rust-lang/rust/issues/29864
3292 ------------------------
3294 Normally
, Rust keeps you from adding
trait implementations that could
3295 overlap with each other
, as it would be ambiguous which to
use. This
3296 feature
, however
, carves out an exception to that rule
: a
trait can
3297 opt
-in to having overlapping implementations
, at the cost that those
3298 implementations are not allowed to
override anything (and thus the
3299 trait itself cannot have any associated items
, as they're pointless
3300 when they'd need to
do the same thing
for every
type anyway
).
3303 #![feature(marker_trait_attr)]
3305 #[marker] trait CheapToClone: Clone {}
3307 impl<T
: Copy
> CheapToClone
for T {}
3309 // These could potentially overlap with the blanket implementation above,
3310 // so are only allowed because CheapToClone is a marker trait.
3311 impl<T
: CheapToClone
, U
: CheapToClone
> CheapToClone
for (T
, U
) {}
3312 impl<T
: CheapToClone
> CheapToClone
for std
::ops
::Range
<T
> {}
3314 fn cheap_clone
<T
: CheapToClone
>(t
: T
) -> T
{
3319 This is expected to replace the unstable `overlapping_marker_traits`
3320 feature
, which applied to all empty
traits (without needing an opt
-in).
3324 label: "more_qualified_paths
",
3325 description: r##"# `more_qualified_paths`
3327 The `more_qualified_paths` feature can be used
in order to enable the
3328 use of qualified paths
in patterns
.
3333 #![feature(more_qualified_paths)]
3336 // destructure through a qualified path
3337 let <Foo
as A
>::Assoc { br }
= StructStruct { br: 2 }
;
3340 struct StructStruct
{
3351 type Assoc
= StructStruct
;
3357 label: "native_link_modifiers
",
3358 description: r##"# `native_link_modifiers`
3360 The tracking issue
for this feature is
: [#81490]
3362 [#81490]: https://github.com/rust-lang/rust/issues/81490
3364 ------------------------
3366 The `native_link_modifiers` feature allows you to
use the `modifiers` syntax with the `
#[link(..)]` attribute.
3368 Modifiers are specified
as a comma
-delimited string with each modifier prefixed with either a `
+` or `
-` to indicate that the modifier is enabled or disabled
, respectively
. The last boolean value specified
for a given modifier wins
.
3372 label: "native_link_modifiers_as_needed
",
3373 description: r##"# `native_link_modifiers_as_needed`
3375 The tracking issue
for this feature is
: [#81490]
3377 [#81490]: https://github.com/rust-lang/rust/issues/81490
3379 ------------------------
3381 The `native_link_modifiers_as_needed` feature allows you to
use the `
as-needed` modifier
.
3383 `
as-needed` is only compatible with the `dynamic` and `framework` linking kinds
. Using any other kind will result
in a compiler error
.
3385 `
+as-needed` means that the library will be actually linked only
if it satisfies some undefined symbols at the point at which it is specified on the command line
, making it similar to
static libraries
in this regard
.
3387 This modifier translates to `
--as-needed`
for ld
-like linkers
, and to `
-dead_strip_dylibs`
/ `
-needed_library`
/ `
-needed_framework`
for ld64
.
3388 The modifier does nothing
for linkers that don't support
it (e
.g
. `link
.exe`
).
3390 The
default for this modifier is unclear
, some targets currently specify it
as `
+as-needed`
, some
do not
. We may want to try making `
+as-needed` a
default for all targets
.
3394 label: "native_link_modifiers_bundle
",
3395 description: r##"# `native_link_modifiers_bundle`
3397 The tracking issue
for this feature is
: [#81490]
3399 [#81490]: https://github.com/rust-lang/rust/issues/81490
3401 ------------------------
3403 The `native_link_modifiers_bundle` feature allows you to
use the `bundle` modifier
.
3405 Only compatible with the `
static` linking kind
. Using any other kind will result
in a compiler error
.
3407 `
+bundle` means objects from the
static library are bundled into the produced
crate (a rlib
, for example
) and are used from this
crate later during linking of the
final binary
.
3409 `
-bundle` means the
static library is included into the produced rlib
"by name" and object files from it are included only during linking of the
final binary
, the file search by that name is also performed during
final linking
.
3411 This modifier is supposed to supersede the `
static-nobundle` linking kind defined by
[RFC
1717](https
://github.com/rust-lang/rfcs/pull/1717).
3413 The
default for this modifier is currently `
+bundle`
, but it could be changed later on some future edition boundary
.
3417 label: "native_link_modifiers_verbatim
",
3418 description: r##"# `native_link_modifiers_verbatim`
3420 The tracking issue
for this feature is
: [#81490]
3422 [#81490]: https://github.com/rust-lang/rust/issues/81490
3424 ------------------------
3426 The `native_link_modifiers_verbatim` feature allows you to
use the `verbatim` modifier
.
3428 `
+verbatim` means that rustc itself won't add any target
-specified library prefixes or
suffixes (like `lib` or `
.a`
) to the library name
, and will try its best to ask
for the same thing from the linker
.
3430 For `ld`
-like linkers rustc will
use the `
-l
:filename`
syntax (note the colon
) when passing the library
, so the linker won't add any prefixes or suffixes
as well
.
3431 See
[`
-l namespec`
](https
://sourceware.org/binutils/docs/ld/Options.html) in ld documentation for more details.
3432 For linkers not supporting any verbatim
modifiers (e
.g
. `link
.exe` or `ld64`
) the library name will be passed
as is
.
3434 The
default for this modifier is `
-verbatim`
.
3436 This RFC changes the behavior of `raw
-dylib` linking kind specified by
[RFC
2627](https
://github.com/rust-lang/rfcs/pull/2627). The `.dll` suffix (or other target-specified suffixes for other targets) is now added automatically.
3437 If your DLL doesn't have the `
.dll` suffix
, it can be specified with `
+verbatim`
.
3441 label: "native_link_modifiers_whole_archive
",
3442 description: r##"# `native_link_modifiers_whole_archive`
3444 The tracking issue
for this feature is
: [#81490]
3446 [#81490]: https://github.com/rust-lang/rust/issues/81490
3448 ------------------------
3450 The `native_link_modifiers_whole_archive` feature allows you to
use the `whole
-archive` modifier
.
3452 Only compatible with the `
static` linking kind
. Using any other kind will result
in a compiler error
.
3454 `
+whole
-archive` means that the
static library is linked
as a whole archive without throwing any object files away
.
3456 This modifier translates to `
--whole
-archive`
for `ld`
-like linkers
, to `
/WHOLEARCHIVE`
for `link
.exe`
, and to `
-force_load`
for `ld64`
.
3457 The modifier does nothing
for linkers that don't support it
.
3459 The
default for this modifier is `
-whole
-archive`
.
3463 label: "negative_impls
",
3464 description: r##"# `negative_impls`
3466 The tracking issue
for this feature is
[#68318].
3468 [#68318]: https://github.com/rust-lang/rust/issues/68318
3472 With the feature gate `negative_impls`
, you can write negative impls
as well
as positive ones
:
3475 #![feature(negative_impls)]
3477 impl<T
: ?Sized
> !DerefMut
for &T { }
3480 Negative impls indicate a semver guarantee that the given
trait will not be implemented
for the given types
. Negative impls play an additional purpose
for auto traits
, described below
.
3482 Negative impls have the following characteristics
:
3484 * They
do not have any items
.
3485 * They must obey the orphan rules
as if they were a positive
impl.
3486 * They cannot
"overlap" with any positive impls
.
3488 ## Semver interaction
3490 It is a breaking change to remove a negative
impl. Negative impls are a commitment not to implement the given
trait for the named types
.
3492 ## Orphan and overlap rules
3494 Negative impls must obey the same orphan rules
as a positive
impl. This implies you cannot add a negative
impl for types defined
in upstream crates and so forth
.
3496 Similarly
, negative impls cannot overlap with positive impls
, again using the same
"overlap" check that we ordinarily
use to determine
if two impls overlap
. (Note that positive impls typically cannot overlap with one another either
, except
as permitted by specialization
.)
3498 ## Interaction with auto traits
3500 Declaring a negative
impl `
impl !SomeAutoTrait
for SomeType`
for an
3501 auto-trait serves two purposes
:
3503 * as with any
trait, it declares that `SomeType` will never implement `SomeAutoTrait`
;
3504 * it disables the automatic `SomeType
: SomeAutoTrait`
impl that would otherwise have been generated
.
3506 Note that
, at present
, there is no way to indicate that a given
type
3507 does not implement an
auto trait *but that it may
do so
in the
3508 future
*. For ordinary types
, this is done by simply not declaring any
3509 impl at all
, but that is not an option
for auto traits
. A workaround
3510 is that one could embed a marker
type as one of the fields
, where the
3511 marker
type is `
!AutoTrait`
.
3515 Negative impls are used to declare that `
&T
: !DerefMut` and `
&mut T
: !Clone`
, as required to fix the soundness of `Pin` described
in [#66544](https://github.com/rust-lang/rust/issues/66544).
3517 This serves two purposes
:
3519 * For proving the correctness of
unsafe code
, we can
use that
impl as evidence that no `DerefMut` or `Clone`
impl exists
.
3520 * It prevents downstream crates from creating such impls
.
3524 label: "no_coverage
",
3525 description: r##"# `no_coverage`
3527 The tracking issue
for this feature is
: [#84605]
3529 [#84605]: https://github.com/rust-lang/rust/issues/84605
3533 The `no_coverage` attribute can be used to selectively disable coverage
3534 instrumentation
in an annotated function
. This might be useful to
:
3536 - Avoid instrumentation overhead
in a performance critical function
3537 - Avoid generating coverage
for a function that is not meant to be executed
,
3538 but still target
100% coverage
for the rest of the program
.
3543 #![feature(no_coverage)]
3545 // `foo()` will get coverage instrumentation (by default)
3558 label: "no_sanitize
",
3559 description: r##"# `no_sanitize`
3561 The tracking issue
for this feature is
: [#39699]
3563 [#39699]: https://github.com/rust-lang/rust/issues/39699
3565 ------------------------
3567 The `no_sanitize` attribute can be used to selectively disable sanitizer
3568 instrumentation
in an annotated function
. This might be useful to
: avoid
3569 instrumentation overhead
in a performance critical function
, or avoid
3570 instrumenting code that contains constructs unsupported by given sanitizer
.
3572 The precise effect of this annotation depends on particular sanitizer
in use.
3573 For example
, with `
no_sanitize(thread
)`
, the thread sanitizer will no longer
3574 instrument non
-atomic store
/ load operations
, but it will instrument atomic
3575 operations to avoid reporting
false positives and provide meaning full stack
3581 #![feature(no_sanitize)]
3583 #[no_sanitize(address)]
3592 description: r##"# `plugin`
3594 The tracking issue
for this feature is
: [#29597]
3596 [#29597]: https://github.com/rust-lang/rust/issues/29597
3599 This feature is part of
"compiler plugins." It will often be used with the
3600 `rustc_private` feature
.
3602 ------------------------
3604 `rustc` can load compiler plugins
, which are user
-provided libraries that
3605 extend the compiler's behavior with new lint checks
, etc
.
3607 A plugin is a dynamic library
crate with a designated
*registrar
* function that
3608 registers extensions with `rustc`
. Other crates can load these extensions using
3609 the
crate attribute `
#![plugin(...)]`. See the
3610 `rustc_driver
::plugin` documentation
for more about the
3611 mechanics of defining and loading a plugin
.
3613 In the vast majority of cases
, a plugin should
*only
* be used through
3614 `
#![plugin]` and not through an `extern crate` item. Linking a plugin would
3615 pull
in all of librustc_ast and librustc
as dependencies of your
crate. This is
3616 generally unwanted unless you are building another plugin
.
3618 The usual practice is to put compiler plugins
in their own
crate, separate from
3619 any `macro_rules
!` macros or ordinary Rust code meant to be used by consumers
3624 Plugins can extend
[Rust's lint
3625 infrastructure
](../../reference
/attributes
/diagnostics
.md
#lint-check-attributes) with
3626 additional checks
for code style
, safety
, etc
. Now
let's write a plugin
3627 [`lint
-plugin
-test
.rs`
](https
://github.com/rust-lang/rust/blob/master/tests/ui-fulldeps/auxiliary/lint-plugin-test.rs)
3628 that warns about any item named `lintme`
.
3630 ```rust
,ignore (requires
-stage
-2)
3631 #![feature(box_syntax, rustc_private)]
3633 extern crate rustc_ast
;
3635 // Load rustc as a plugin to get macros
3636 extern crate rustc_driver
;
3638 extern crate rustc_lint
;
3640 extern crate rustc_session
;
3642 use rustc_driver
::plugin
::Registry
;
3643 use rustc_lint
::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}
;
3645 declare_lint
!(TEST_LINT
, Warn
, "Warn about items named 'lintme'");
3647 declare_lint_pass
!(Pass
=> [TEST_LINT
]);
3649 impl EarlyLintPass
for Pass
{
3650 fn check_item(&mut self, cx
: &EarlyContext
, it
: &ast
::Item
) {
3651 if it
.ident
.name
.as_str() == "lintme" {
3652 cx
.lint(TEST_LINT
, |lint
| {
3653 lint
.build("item is named 'lintme'").set_span(it
.span
).emit()
3660 fn __rustc_plugin_registrar(reg
: &mut Registry
) {
3661 reg
.lint_store
.register_lints(&[&TEST_LINT
]);
3662 reg
.lint_store
.register_early_pass(|| box Pass
);
3668 ```rust
,ignore (requires
-plugin
)
3670 #![plugin(lint_plugin_test)]
3675 will produce a compiler warning
:
3678 foo
.rs
:4:1: 4:16 warning
: item is named 'lintme'
, #[warn(test_lint)] on by default
3679 foo
.rs
:4 fn lintme() { }
3683 The components of a lint plugin are
:
3685 * one or more `declare_lint
!` invocations
, which define
static `Lint` structs
;
3687 * a
struct holding any state needed by the lint
pass (here
, none
);
3690 implementation defining how to check each syntax element
. A single
3691 `LintPass` may call `span_lint`
for several different `Lint`s
, but should
3692 register them all through the `get_lints` method
.
3694 Lint passes are syntax traversals
, but they run at a late stage of compilation
3695 where type information is available
. `rustc`'s
[built
-in
3696 lints
](https
://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs)
3697 mostly
use the same infrastructure
as lint plugins
, and provide examples of how
3698 to access
type information
.
3700 Lints defined by plugins are controlled by the usual
[attributes and compiler
3701 flags
](../../reference
/attributes
/diagnostics
.md
#lint-check-attributes), e.g.
3702 `
#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the
3703 first argument to `declare_lint
!`
, with appropriate case and punctuation
3706 You can run `rustc
-W help foo
.rs` to see a list of lints known to `rustc`
,
3707 including those provided by plugins loaded by `foo
.rs`
.
3711 label: "print_internals
",
3712 description: r##"# `print_internals`
3714 This feature is internal to the Rust compiler and is not intended
for general
use.
3716 ------------------------
3720 label: "profiler_runtime
",
3721 description: r##"# `profiler_runtime`
3723 The tracking issue
for this feature is
: [#42524](https://github.com/rust-lang/rust/issues/42524).
3725 ------------------------
3729 label: "profiler_runtime_lib
",
3730 description: r##"# `profiler_runtime_lib`
3732 This feature is internal to the Rust compiler and is not intended
for general
use.
3734 ------------------------
3739 description: r##"# `raw_dylib`
3741 The tracking issue
for this feature is
: [#58713]
3743 [#58713]: https://github.com/rust-lang/rust/issues/58713
3745 ------------------------
3747 The `raw_dylib` feature allows you to link against the implementations of functions
in an `
extern`
3748 block without
, on Windows
, linking against an import library
.
3750 ```rust
,ignore (partial
-example
)
3751 #![feature(raw_dylib)]
3753 #[link(name="library", kind="raw-dylib")]
3755 fn extern_function(x
: i32);
3760 extern_function(14);
3767 Currently
, this feature is only supported on `
-windows
-msvc` targets
. Non
-Windows platforms don't have import
3768 libraries
, and an incompatibility between LLVM and the BFD linker means that it is not currently supported on
3769 `
-windows
-gnu` targets
.
3771 On the `i686
-pc
-windows
-msvc` target
, this feature supports only the `cdecl`
, `stdcall`
, `system`
, and `fastcall`
3772 calling conventions
.
3777 description: r##"# `repr128`
3779 The tracking issue
for this feature is
: [#56071]
3781 [#56071]: https://github.com/rust-lang/rust/issues/56071
3783 ------------------------
3785 The `repr128` feature adds support
for `
#[repr(u128)]` on `enum`s.
3788 #![feature(repr128)]
3799 description: r##"# `rt`
3801 This feature is internal to the Rust compiler and is not intended
for general
use.
3803 ------------------------
3807 label: "rustc_attrs
",
3808 description: r##"# `rustc_attrs`
3810 This feature has no tracking issue
, and is therefore internal to
3811 the compiler
, not being intended
for general
use.
3813 Note
: `rustc_attrs` enables many rustc
-internal attributes and this page
3814 only discuss a few of them
.
3816 ------------------------
3818 The `rustc_attrs` feature allows debugging rustc
type layouts by using
3819 `
#[rustc_layout(...)]` to debug layout at compile time (it even works
3820 with `cargo check`
) as an alternative to `rustc
-Z print
-type-sizes`
3821 that is way more verbose
.
3823 Options provided by `
#[rustc_layout(...)]` are `debug`, `size`, `align`,
3824 `abi`
. Note that it only works on sized types without generics
.
3828 ```rust
,compile_fail
3829 #![feature(rustc_attrs)]
3831 #[rustc_layout(abi, size)]
3838 When that is compiled
, the compiler will error with something like
3841 error
: abi
: Aggregate { sized: true }
3845 5 | | Y(u8, u8, u8),
3850 error
: size
: Size { raw: 16 }
3854 5 | | Y(u8, u8, u8),
3859 error
: aborting due to
2 previous errors
3864 label: "sort_internals
",
3865 description: r##"# `sort_internals`
3867 This feature is internal to the Rust compiler and is not intended
for general
use.
3869 ------------------------
3873 label: "str_internals
",
3874 description: r##"# `str_internals`
3876 This feature is internal to the Rust compiler and is not intended
for general
use.
3878 ------------------------
3883 description: r##"# `test`
3885 The tracking issue
for this feature is
: None
.
3887 ------------------------
3889 The internals of the `test`
crate are unstable
, behind the `test` flag
. The
3890 most widely used part of the `test`
crate are benchmark tests
, which can test
3891 the performance of your code
. Let's make our `src
/lib
.rs` look like this
3899 pub fn add_two(a
: i32) -> i32 {
3910 assert_eq
!(4, add_two(2));
3914 fn bench_add_two(b
: &mut Bencher
) {
3915 b
.iter(|| add_two(2));
3920 Note the `test` feature gate
, which enables this unstable feature
.
3922 We've imported the `test`
crate, which contains our benchmarking support
.
3923 We have a new function
as well
, with the `bench` attribute
. Unlike regular
3924 tests
, which take no arguments
, benchmark tests take a `
&mut Bencher`
. This
3925 `Bencher` provides an `iter` method
, which takes a closure
. This closure
3926 contains the code we'd like to benchmark
.
3928 We can run benchmark tests with `cargo bench`
:
3932 Compiling adder v0
.0
.1 (file
:///home/steve/tmp/adder)
3933 Running target
/release
/adder
-91b3e234d4ed382a
3936 test tests
::it_works
... ignored
3937 test tests
::bench_add_two
... bench
: 1 ns
/iter (+/- 0)
3939 test result
: ok
. 0 passed
; 0 failed
; 1 ignored
; 1 measured
3942 Our non
-benchmark test was ignored
. You may have noticed that `cargo bench`
3943 takes a bit longer than `cargo test`
. This is because Rust runs our benchmark
3944 a number of times
, and then takes the average
. Because we're doing so little
3945 work
in this example
, we have a `
1 ns
/iter (+/- 0)`
, but this would show
3946 the variance
if there was one
.
3948 Advice on writing benchmarks
:
3951 * Move setup code outside the `iter`
loop; only put the part you want to measure inside
3952 * Make the code
do "the same thing" on each iteration
; do not accumulate or change state
3953 * Make the outer function idempotent too
; the benchmark runner is likely to run
3955 * Make the inner `iter`
loop short and fast so benchmark runs are fast and the
3956 calibrator can adjust the run
-length at fine resolution
3957 * Make the code
in the `iter`
loop do something simple
, to assist
in pinpointing
3958 performance
improvements (or regressions
)
3960 ## Gotcha: optimizations
3962 There's another tricky part to writing benchmarks
: benchmarks compiled with
3963 optimizations activated can be dramatically changed by the optimizer so that
3964 the benchmark is no longer benchmarking what one expects
. For example
, the
3965 compiler might recognize that some calculation has no external effects and
3975 fn bench_xor_1000_ints(b
: &mut Bencher
) {
3977 (0..1000).fold(0, |old
, new
| old ^ new
);
3982 gives the following results
3986 test bench_xor_1000_ints
... bench
: 0 ns
/iter (+/- 0)
3988 test result
: ok
. 0 passed
; 0 failed
; 0 ignored
; 1 measured
3991 The benchmarking runner offers two ways to avoid this
. Either
, the closure that
3992 the `iter` method receives can
return an arbitrary value which forces the
3993 optimizer to consider the result used and ensures it cannot remove the
3994 computation entirely
. This could be done
for the example above by adjusting the
3999 # impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
4001 // Note lack of `;` (could also use an explicit `return`).
4002 (0..1000).fold(0, |old
, new
| old ^ new
)
4006 Or
, the other option is to call the generic `test
::black_box` function
, which
4007 is an opaque
"black box" to the optimizer and so forces it to consider any
4017 # impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
4019 let n
= test
::black_box(1000);
4021 (0..n
).fold(0, |a
, b
| a ^ b
)
4026 Neither of these read or modify the value
, and are very cheap
for small values
.
4027 Larger values can be passed indirectly to reduce
overhead (e
.g
.
4028 `
black_box(&huge_struct
)`
).
4030 Performing either of the above changes gives the following benchmarking results
4034 test bench_xor_1000_ints
... bench
: 131 ns
/iter (+/- 3)
4036 test result
: ok
. 0 passed
; 0 failed
; 0 ignored
; 1 measured
4039 However
, the optimizer can still modify a testcase
in an undesirable manner
4040 even when using either of the above
.
4044 label: "thread_local_internals
",
4045 description: r##"# `thread_local_internals`
4047 This feature is internal to the Rust compiler and is not intended
for general
use.
4049 ------------------------
4053 label: "trace_macros
",
4054 description: r##"# `trace_macros`
4056 The tracking issue
for this feature is
[#29598].
4058 [#29598]: https://github.com/rust-lang/rust/issues/29598
4060 ------------------------
4062 With `trace_macros` you can trace the expansion of macros
in your code
.
4067 #![feature(trace_macros)]
4070 trace_macros
!(true);
4071 println
!("Hello, Rust!");
4072 trace_macros
!(false);
4076 The `cargo build` output
:
4082 5 | println
!("Hello, Rust!");
4083 | ^^^^^^^^^^^^^^^^^^^^^^^^^
4085 = note
: expanding `println
! { "Hello, Rust!" }`
4086 = note
: to `print
! ( concat
! ( "Hello, Rust!" , "\n" ) )`
4087 = note
: expanding `print
! { concat ! ( "Hello, Rust!" , "\n" ) }`
4088 = note
: to `$
crate :: io
:: _print ( format_args
! ( concat
! ( "Hello, Rust!" , "\n" ) )
4091 Finished dev
[unoptimized
+ debuginfo
] target(s
) in 0.60 secs
4096 label: "trait_alias
",
4097 description: r##"# `trait_alias`
4099 The tracking issue
for this feature is
: [#41517]
4101 [#41517]: https://github.com/rust-lang/rust/issues/41517
4103 ------------------------
4105 The `trait_alias` feature adds support
for trait aliases
. These allow aliases
4106 to be created
for one or more
traits (currently just a single regular
trait plus
4107 any number of
auto-traits
), and used wherever traits would normally be used
as
4108 either bounds or
trait objects
.
4111 #![feature(trait_alias)]
4113 trait Foo
= std
::fmt
::Debug
+ Send
;
4114 trait Bar
= Foo
+ Sync
;
4116 // Use trait alias as bound on type parameter.
4117 fn foo
<T
: Foo
>(v
: &T
) {
4118 println
!("{:?}", v
);
4124 // Use trait alias for trait objects.
4126 println
!("{:?}", a
);
4127 let b
= Box
::new(456) as Box
<dyn Foo
>;
4128 println
!("{:?}", b
);
4134 label: "trait_upcasting
",
4135 description: r##"# `trait_upcasting`
4137 The tracking issue
for this feature is
: [#65991]
4139 [#65991]: https://github.com/rust-lang/rust/issues/65991
4141 ------------------------
4143 The `trait_upcasting` feature adds support
for trait upcasting coercion
. This allows a
4144 trait object of
type `
dyn Bar` to be cast to a
trait object of
type `
dyn Foo`
4145 so long
as `Bar
: Foo`
.
4148 #![feature(trait_upcasting)]
4149 #![allow(incomplete_features)]
4157 impl<T
: Foo
+ ?Sized
> Bar
for T {}
4159 let bar
: &dyn Bar
= &123;
4160 let foo
: &dyn Foo
= bar
;
4165 label: "transparent_unions
",
4166 description: r##"# `transparent_unions`
4168 The tracking issue
for this feature is
[#60405]
4170 [#60405]: https://github.com/rust-lang/rust/issues/60405
4174 The `transparent_unions` feature allows you mark `
union`s
as
4175 `
#[repr(transparent)]`. A `union` may be `#[repr(transparent)]` in exactly the
4176 same conditions
in which a `
struct` may be `
#[repr(transparent)]` (generally,
4177 this means the `
union` must have exactly one non
-zero
-sized field
). Some
4178 concrete illustrations follow
.
4181 #![feature(transparent_unions)]
4183 // This union has the same representation as `f32`.
4184 #[repr(transparent)]
4185 union SingleFieldUnion
{
4189 // This union has the same representation as `usize`.
4190 #[repr(transparent)]
4191 union MultiFieldUnion
{
4197 For consistency with transparent `
struct`s
, `
union`s must have exactly one
4198 non
-zero
-sized field
. If all fields are zero
-sized
, the `
union` must not be
4199 `
#[repr(transparent)]`:
4202 #![feature(transparent_unions)]
4204 // This (non-transparent) union is already valid in stable Rust:
4205 pub union GoodUnion
{
4209 // Error: transparent union needs exactly one non-zero-sized field, but has 0
4210 // #[repr(transparent)]
4211 // pub union BadUnion {
4216 The one exception is
if the `
union` is generic over `T` and has a field of
type
4217 `T`
, it may be `
#[repr(transparent)]` even if `T` is a zero-sized type:
4220 #![feature(transparent_unions)]
4222 // This union has the same representation as `T`.
4223 #[repr(transparent)]
4224 pub union GenericUnion
<T
: Copy
> { // Unions with non-`Copy` fields are unstable.
4229 // This is okay even though `()` is a zero-sized type.
4230 pub const THIS_IS_OKAY
: GenericUnion
<()> = GenericUnion { field: () }
;
4233 Like transarent `
struct`s
, a transparent `
union` of
type `U` has the same
4234 layout
, size
, and ABI
as its single non
-ZST field
. If it is generic over a
type
4235 `T`
, and all its fields are ZSTs except
for exactly one field of
type `T`
, then
4236 it has the same layout and ABI
as `T`
(even
if `T` is a ZST when monomorphized
).
4238 Like transparent `
struct`s
, transparent `
union`s are FFI
-safe
if and only
if
4239 their underlying representation
type is also FFI
-safe
.
4241 A `
union` may not be eligible
for the same nonnull
-style optimizations that a
4242 `
struct` or `
enum`
(with the same fields
) are eligible
for. Adding
4243 `
#[repr(transparent)]` to `union` does not change this. To give a more concrete
4244 example
, it is unspecified whether `size_of
::<T
>()` is equal to
4245 `size_of
::<Option
<T
>>()`
, where `T` is a `
union`
(regardless of whether or not
4246 it is transparent
). The Rust compiler is free to perform this optimization
if
4247 possible
, but is not required to
, and different compiler versions may differ
in
4248 their application of these optimizations
.
4252 label: "try_blocks
",
4253 description: r##"# `try_blocks`
4255 The tracking issue
for this feature is
: [#31436]
4257 [#31436]: https://github.com/rust-lang/rust/issues/31436
4259 ------------------------
4261 The `try_blocks` feature adds support
for `try` blocks
. A `try`
4262 block creates a new scope one can
use the `?` operator
in.
4265 #![feature(try_blocks)]
4267 use std
::num
::ParseIntError
;
4269 let result
: Result
<i32, ParseIntError
> = try
{
4271 + "2".parse
::<i32>()?
4272 + "3".parse
::<i32>()?
4274 assert_eq
!(result
, Ok(6));
4276 let result
: Result
<i32, ParseIntError
> = try
{
4278 + "foo".parse
::<i32>()?
4279 + "3".parse
::<i32>()?
4281 assert
!(result
.is_err());
4286 label: "type_changing_struct_update
",
4287 description: r##"# `type_changing_struct_update`
4289 The tracking issue
for this feature is
: [#86555]
4291 [#86555]: https://github.com/rust-lang/rust/issues/86555
4293 ------------------------
4295 This implements
[RFC2528
]. When turned on
, you can create instances of the same
struct
4296 that have different generic
type or lifetime parameters
.
4298 [RFC2528
]: https
://github.com/rust-lang/rfcs/blob/master/text/2528-type-changing-struct-update-syntax.md
4301 #![allow(unused_variables, dead_code)]
4302 #![feature(type_changing_struct_update)]
4310 let base
: Foo
<String
, i32> = Foo
{
4311 field1
: String
::from("hello"),
4314 let updated
: Foo
<f64, i32> = Foo
{
4323 label: "unboxed_closures
",
4324 description: r##"# `unboxed_closures`
4326 The tracking issue
for this feature is
[#29625]
4328 See Also
: [`fn_traits`
](../library
-features
/fn-traits
.md
)
4330 [#29625]: https://github.com/rust-lang/rust/issues/29625
4334 The `unboxed_closures` feature allows you to write functions using the `
"rust-call"` ABI
,
4335 required
for implementing the
[`Fn
*`
] family of traits
. `
"rust-call"` functions must have
4336 exactly
one (non
self) argument
, a tuple representing the argument list
.
4338 [`Fn
*`
]: https
://doc.rust-lang.org/std/ops/trait.Fn.html
4341 #![feature(unboxed_closures)]
4343 extern "rust-call" fn add_args(args
: (u32, u32)) -> u32 {
4352 label: "unsized_locals
",
4353 description: r##"# `unsized_locals`
4355 The tracking issue
for this feature is
: [#48055]
4357 [#48055]: https://github.com/rust-lang/rust/issues/48055
4359 ------------------------
4361 This implements
[RFC1909
]. When turned on
, you can have
unsized arguments and locals
:
4363 [RFC1909
]: https
://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md
4366 #![allow(incomplete_features)]
4367 #![feature(unsized_locals, unsized_fn_params)]
4372 let x
: Box
<dyn Any
> = Box
::new(42);
4373 let x
: dyn Any
= *x
;
4374 // ^ unsized local variable
4375 // ^^ unsized temporary
4379 fn foo(_
: dyn Any
) {}
4380 // ^^^^^^ unsized argument
4383 The RFC still forbids the following
unsized expressions
:
4385 ```rust
,compile_fail
4386 #![feature(unsized_locals)]
4390 struct MyStruct
<T
: ?Sized
> {
4394 struct MyTupleStruct
<T
: ?Sized
>(T
);
4396 fn answer() -> Box
<dyn Any
> {
4401 // You CANNOT have unsized statics.
4402 static X
: dyn Any
= *answer(); // ERROR
4403 const Y
: dyn Any
= *answer(); // ERROR
4405 // You CANNOT have struct initialized unsized.
4406 MyStruct { content: *answer() }
; // ERROR
4407 MyTupleStruct(*answer()); // ERROR
4408 (42, *answer()); // ERROR
4410 // You CANNOT have unsized return types.
4411 fn my_function() -> dyn Any { *answer() }
// ERROR
4413 // You CAN have unsized local variables...
4414 let mut x
: dyn Any
= *answer(); // OK
4415 // ...but you CANNOT reassign to them.
4416 x
= *answer(); // ERROR
4418 // You CANNOT even initialize them separately.
4419 let y
: dyn Any
; // OK
4420 y
= *answer(); // ERROR
4422 // Not mentioned in the RFC, but by-move captured variables are also Sized.
4423 let x
: dyn Any
= *answer();
4428 // You CAN create a closure with unsized arguments,
4429 // but you CANNOT call it.
4430 // This is an implementation detail and may be changed in the future.
4431 let f
= |x
: dyn Any
| {}
;
4432 f(*answer()); // ERROR
4436 ## By-value trait objects
4438 With this feature
, you can have by
-value `
self` arguments without `
Self: Sized` bounds
.
4441 #![feature(unsized_fn_params)]
4447 impl<T
: ?Sized
> Foo
for T {}
4450 let slice
: Box
<[i32]> = Box
::new([1, 2, 3]);
4451 <[i32] as Foo
>::foo(*slice
);
4455 And `Foo` will also be object
-safe
.
4458 #![feature(unsized_fn_params)]
4464 impl<T
: ?Sized
> Foo
for T {}
4467 let slice
: Box
<dyn Foo
> = Box
::new([1, 2, 3]);
4468 // doesn't compile yet
4469 <dyn Foo
as Foo
>::foo(*slice
);
4473 One of the objectives of this feature is to allow `Box
<dyn FnOnce
>`
.
4475 ## Variable length arrays
4477 The RFC also describes an extension to the array literal syntax
: `
[e
; dyn n
]`
. In the syntax
, `n` isn't necessarily a constant expression
. The array is dynamically allocated on the stack and has the
type of `
[T
]`
, instead of `
[T
; n
]`
.
4479 ```rust
,ignore (not
-yet
-implemented
)
4480 #![feature(unsized_locals)]
4482 fn mergesort
<T
: Ord
>(a
: &mut [T
]) {
4483 let mut tmp
= [T
; dyn a
.len()];
4488 let mut a
= [3, 1, 5, 6];
4490 assert_eq
!(a
, [1, 3, 5, 6]);
4494 VLAs are not implemented yet
. The syntax isn't
final, either
. We may need an alternative syntax
for Rust
2015 because
, in Rust
2015, expressions like `
[e
; dyn(1)]` would be ambiguous
. One possible alternative proposed
in the RFC is `
[e
; n
]`
: if `n` captures one or more local variables
, then it is considered
as `
[e
; dyn n
]`
.
4496 ## Advisory on stack usage
4498 It's advised not to casually
use the `
#![feature(unsized_locals)]` feature. Typical use-cases are:
4500 - When you need a by
-value
trait objects
.
4501 - When you really need a fast allocation of small temporary arrays
.
4503 Another pitfall is repetitive allocation and temporaries
. Currently the compiler simply extends the stack frame every time it encounters an
unsized assignment
. So
for example
, the code
4506 #![feature(unsized_locals)]
4509 let x
: Box
<[i32]> = Box
::new([1, 2, 3, 4, 5]);
4510 let _x
= {{{{{{{{{{*x}
}}}}}}}}};
4517 #![feature(unsized_locals)]
4521 let x
: Box
<[i32]> = Box
::new([1, 2, 3, 4, 5]);
4527 will unnecessarily extend the stack frame
.
4531 label: "unsized_tuple_coercion
",
4532 description: r##"# `unsized_tuple_coercion`
4534 The tracking issue
for this feature is
: [#42877]
4536 [#42877]: https://github.com/rust-lang/rust/issues/42877
4538 ------------------------
4540 This is a part of
[RFC0401
]. According to the RFC
, there should be an implementation like this
:
4542 ```rust
,ignore (partial
-example
)
4543 impl<..., T
, U
: ?Sized
> Unsized
<(..., U
)> for (..., T
) where T
: Unsized
<U
> {}
4546 This implementation is currently gated behind `
#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this:
4549 #![feature(unsized_tuple_coercion)]
4552 let x
: ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]);
4553 let y
: &([i32; 3], [i32]) = &x
;
4554 assert_eq
!(y
.1[0], 4);
4558 [RFC0401
]: https
://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
4562 label: "update_panic_count
",
4563 description: r##"# `update_panic_count`
4565 This feature is internal to the Rust compiler and is not intended
for general
use.
4567 ------------------------
4572 description: r##"# `windows_c`
4574 This feature is internal to the Rust compiler and is not intended
for general
use.
4576 ------------------------
4580 label: "windows_handle
",
4581 description: r##"# `windows_handle`
4583 This feature is internal to the Rust compiler and is not intended
for general
use.
4585 ------------------------
4589 label: "windows_net
",
4590 description: r##"# `windows_net`
4592 This feature is internal to the Rust compiler and is not intended
for general
use.
4594 ------------------------
4598 label: "windows_stdio
",
4599 description: r##"# `windows_stdio`
4601 This feature is internal to the Rust compiler and is not intended
for general
use.
4603 ------------------------
4608 pub const CLIPPY_LINTS: &[Lint] = &[
4610 label: "clippy
::absurd_extreme_comparisons
",
4611 description: r##"Checks
for comparisons
where one side of the relation is
4612 either the minimum or maximum value
for its
type and warns
if it involves a
4613 case that is always
true or always
false. Only integer and boolean types are
4617 label: "clippy
::almost_swapped
",
4618 description: r##"Checks
for `foo
= bar
; bar
= foo` sequences
."##,
4621 label: "clippy
::approx_constant
",
4622 description: r##"Checks
for floating point literals that approximate
4623 constants which are defined
in
4624 [`std
::f32::consts`
](https
://doc.rust-lang.org/stable/std/f32/consts/#constants)
4626 [`std
::f64::consts`
](https
://doc.rust-lang.org/stable/std/f64/consts/#constants),
4627 respectively
, suggesting to
use the predefined constant
."##,
4630 label: "clippy
::as_conversions
",
4631 description: r##"Checks
for usage of `
as` conversions
.
4633 Note that this lint is specialized
in linting
*every single
* use of `
as`
4634 regardless of whether good alternatives exist or not
.
4635 If you want more precise lints
for `
as`
, please consider using these separate lints
:
4636 `unnecessary_cast`
, `cast_lossless
/possible_truncation
/possible_wrap
/precision_loss
/sign_loss`
,
4637 `
fn_to_numeric_cast(_with_truncation
)`
, `char_lit_as_u8`
, `ref_to_mut` and `ptr_as_ptr`
.
4638 There is a good explanation the reason why this lint should work
in this way and how it is useful
4639 [in this issue
](https
://github.com/rust-lang/rust-clippy/issues/5122)."##,
4642 label
: "clippy::assertions_on_constants",
4643 description
: r
##"Checks for `assert!(true)` and `assert!(false)` calls."##,
4646 label
: "clippy::assign_op_pattern",
4647 description
: r
##"Checks for `a = a op b` or `a = b commutative_op a`
4651 label
: "clippy::assign_ops",
4652 description
: r
##"Nothing. This lint has been deprecated."##,
4655 label
: "clippy::async_yields_async",
4656 description
: r
##"Checks for async blocks that yield values of types
4657 that can themselves be awaited."##,
4660 label
: "clippy::await_holding_lock",
4661 description
: r
##"Checks for calls to await while holding a
4662 non-async-aware MutexGuard."##,
4665 label
: "clippy::await_holding_refcell_ref",
4666 description
: r
##"Checks for calls to await while holding a
4667 `RefCell` `Ref` or `RefMut`."##,
4670 label
: "clippy::bad_bit_mask",
4671 description
: r
##"Checks for incompatible bit masks in comparisons.
4673 The formula for detecting if an expression of the type `_ <bit_op> m
4674 <cmp_op> c` (where `<bit_op>` is one of {`&`, `|`} and `<cmp_op>` is one of
4675 {`!=`, `>=`, `>`, `!=`, `>=`, `>`}) can be determined from the following
4678 |Comparison |Bit Op|Example |is always|Formula |
4679 |------------|------|------------|---------|----------------------|
4680 |`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` |
4681 |`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` |
4682 |`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` |
4683 |`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` |
4684 |`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` |
4685 |`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` |"##,
4688 label
: "clippy::bind_instead_of_map",
4689 description
: r
##"Checks for usage of `_.and_then(|x| Some(y))`, `_.and_then(|x| Ok(y))` or
4690 `_.or_else(|x| Err(y))`."##,
4693 label
: "clippy::blacklisted_name",
4694 description
: r
##"Checks for usage of blacklisted names for variables, such
4698 label
: "clippy::blanket_clippy_restriction_lints",
4699 description
: r
##"Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category."##,
4702 label
: "clippy::blocks_in_if_conditions",
4703 description
: r
##"Checks for `if` conditions that use blocks containing an
4704 expression, statements or conditions that use closures with blocks."##,
4707 label
: "clippy::bool_assert_comparison",
4708 description
: r
##"This lint warns about boolean comparisons in assert-like macros."##,
4711 label
: "clippy::bool_comparison",
4712 description
: r
##"Checks for expressions of the form `x == true`,
4713 `x != true` and order comparisons such as `x < true` (or vice versa) and
4714 suggest using the variable directly."##,
4717 label
: "clippy::borrow_interior_mutable_const",
4718 description
: r
##"Checks if `const` items which is interior mutable (e.g.,
4719 contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.) has been borrowed directly."##,
4722 label
: "clippy::borrowed_box",
4723 description
: r
##"Checks for use of `&Box<T>` anywhere in the code.
4724 Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##,
4727 label
: "clippy::box_collection",
4728 description
: r
##"Checks for use of `Box<T>` where T is a collection such as Vec anywhere in the code.
4729 Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##,
4732 label
: "clippy::boxed_local",
4733 description
: r
##"Checks for usage of `Box<T>` where an unboxed `T` would
4737 label
: "clippy::branches_sharing_code",
4738 description
: r
##"Checks if the `if` and `else` block contain shared code that can be
4739 moved out of the blocks."##,
4742 label
: "clippy::builtin_type_shadow",
4743 description
: r
##"Warns if a generic shadows a built-in type."##,
4746 label
: "clippy::bytes_nth",
4747 description
: r
##"Checks for the use of `.bytes().nth()`."##,
4750 label
: "clippy::cargo_common_metadata",
4751 description
: r
##"Checks to see if all common metadata is defined in
4752 `Cargo.toml`. See: https://rust-lang-nursery.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata"##,
4755 label
: "clippy::case_sensitive_file_extension_comparisons",
4756 description
: r
##"Checks for calls to `ends_with` with possible file extensions
4757 and suggests to use a case-insensitive approach instead."##,
4760 label
: "clippy::cast_lossless",
4761 description
: r
##"Checks for casts between numerical types that may
4762 be replaced by safe conversion functions."##,
4765 label
: "clippy::cast_possible_truncation",
4766 description
: r
##"Checks for casts between numerical types that may
4767 truncate large values. This is expected behavior, so the cast is `Allow` by
4771 label
: "clippy::cast_possible_wrap",
4772 description
: r
##"Checks for casts from an unsigned type to a signed type of
4773 the same size. Performing such a cast is a 'no-op' for the compiler,
4774 i.e., nothing is changed at the bit level, and the binary representation of
4775 the value is reinterpreted. This can cause wrapping if the value is too big
4776 for the target signed type. However, the cast works as defined, so this lint
4777 is `Allow` by default."##,
4780 label
: "clippy::cast_precision_loss",
4781 description
: r
##"Checks for casts from any numerical to a float type where
4782 the receiving type cannot store all values from the original type without
4783 rounding errors. This possible rounding is to be expected, so this lint is
4786 Basically, this warns on casting any integer with 32 or more bits to `f32`
4787 or any 64-bit integer to `f64`."##,
4790 label
: "clippy::cast_ptr_alignment",
4791 description
: r
##"Checks for casts, using `as` or `pointer::cast`,
4792 from a less-strictly-aligned pointer to a more-strictly-aligned pointer"##,
4795 label
: "clippy::cast_ref_to_mut",
4796 description
: r
##"Checks for casts of `&T` to `&mut T` anywhere in the code."##,
4799 label
: "clippy::cast_sign_loss",
4800 description
: r
##"Checks for casts from a signed to an unsigned numerical
4801 type. In this case, negative values wrap around to large positive values,
4802 which can be quite surprising in practice. However, as the cast works as
4803 defined, this lint is `Allow` by default."##,
4806 label
: "clippy::char_lit_as_u8",
4807 description
: r
##"Checks for expressions where a character literal is cast
4808 to `u8` and suggests using a byte literal instead."##,
4811 label
: "clippy::chars_last_cmp",
4812 description
: r
##"Checks for usage of `_.chars().last()` or
4813 `_.chars().next_back()` on a `str` to check if it ends with a given char."##,
4816 label
: "clippy::chars_next_cmp",
4817 description
: r
##"Checks for usage of `.chars().next()` on a `str` to check
4818 if it starts with a given char."##,
4821 label
: "clippy::checked_conversions",
4822 description
: r
##"Checks for explicit bounds checking when casting."##,
4825 label
: "clippy::clone_double_ref",
4826 description
: r
##"Checks for usage of `.clone()` on an `&&T`."##,
4829 label
: "clippy::clone_on_copy",
4830 description
: r
##"Checks for usage of `.clone()` on a `Copy` type."##,
4833 label
: "clippy::clone_on_ref_ptr",
4834 description
: r
##"Checks for usage of `.clone()` on a ref-counted pointer,
4835 (`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified
4836 function syntax instead (e.g., `Rc::clone(foo)`)."##,
4839 label
: "clippy::cloned_instead_of_copied",
4840 description
: r
##"Checks for usages of `cloned()` on an `Iterator` or `Option` where
4841 `copied()` could be used instead."##,
4843 Lint { label: "clippy::cmp_nan", description: r##"Checks for comparisons to NaN."## }
,
4845 label
: "clippy::cmp_null",
4846 description
: r
##"This lint checks for equality comparisons with `ptr::null`"##,
4849 label
: "clippy::cmp_owned",
4850 description
: r
##"Checks for conversions to owned values just for the sake
4851 of a comparison."##,
4854 label
: "clippy::cognitive_complexity",
4855 description
: r
##"Checks for methods with high cognitive complexity."##,
4858 label
: "clippy::collapsible_else_if",
4859 description
: r
##"Checks for collapsible `else { if ... }` expressions
4860 that can be collapsed to `else if ...`."##,
4863 label
: "clippy::collapsible_if",
4864 description
: r
##"Checks for nested `if` statements which can be collapsed
4865 by `&&`-combining their conditions."##,
4868 label
: "clippy::collapsible_match",
4869 description
: r
##"Finds nested `match` or `if let` expressions where the patterns may be collapsed together
4870 without adding any branches.
4872 Note that this lint is not intended to find _all_ cases where nested match patterns can be merged, but only
4873 cases where merging would most likely make the code more readable."##,
4876 label
: "clippy::comparison_chain",
4877 description
: r
##"Checks comparison chains written with `if` that can be
4878 rewritten with `match` and `cmp`."##,
4881 label
: "clippy::comparison_to_empty",
4882 description
: r
##"Checks for comparing to an empty slice such as `` or `[]`,
4883 and suggests using `.is_empty()` where applicable."##,
4886 label
: "clippy::copy_iterator",
4887 description
: r
##"Checks for types that implement `Copy` as well as
4891 label
: "clippy::create_dir",
4892 description
: r
##"Checks usage of `std::fs::create_dir` and suggest using `std::fs::create_dir_all` instead."##,
4895 label
: "clippy::crosspointer_transmute",
4896 description
: r
##"Checks for transmutes between a type `T` and `*T`."##,
4898 Lint { label: "clippy::dbg_macro", description: r##"Checks for usage of dbg!() macro."## }
,
4900 label
: "clippy::debug_assert_with_mut_call",
4901 description
: r
##"Checks for function/method calls with a mutable
4902 parameter in `debug_assert!`, `debug_assert_eq!` and `debug_assert_ne!` macros."##,
4905 label
: "clippy::decimal_literal_representation",
4906 description
: r
##"Warns if there is a better representation for a numeric literal."##,
4909 label
: "clippy::declare_interior_mutable_const",
4910 description
: r
##"Checks for declaration of `const` items which is interior
4911 mutable (e.g., contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.)."##,
4914 label
: "clippy::default_numeric_fallback",
4915 description
: r
##"Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type
4918 Default numeric fallback means that if numeric types have not yet been bound to concrete
4919 types at the end of type inference, then integer type is bound to `i32`, and similarly
4920 floating type is bound to `f64`.
4922 See [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback."##,
4925 label
: "clippy::default_trait_access",
4926 description
: r
##"Checks for literal calls to `Default::default()`."##,
4929 label
: "clippy::deprecated_cfg_attr",
4930 description
: r
##"Checks for `#[cfg_attr(rustfmt, rustfmt_skip)]` and suggests to replace it
4931 with `#[rustfmt::skip]`."##,
4934 label
: "clippy::deprecated_semver",
4935 description
: r
##"Checks for `#[deprecated]` annotations with a `since`
4936 field that is not a valid semantic version."##,
4939 label
: "clippy::deref_addrof",
4940 description
: r
##"Checks for usage of `*&` and `*&mut` in expressions."##,
4943 label
: "clippy::derivable_impls",
4944 description
: r
##"Detects manual `std::default::Default` implementations that are identical to a derived implementation."##,
4947 label
: "clippy::derive_hash_xor_eq",
4948 description
: r
##"Checks for deriving `Hash` but implementing `PartialEq`
4949 explicitly or vice versa."##,
4952 label
: "clippy::derive_ord_xor_partial_ord",
4953 description
: r
##"Checks for deriving `Ord` but implementing `PartialOrd`
4954 explicitly or vice versa."##,
4957 label
: "clippy::disallowed_methods",
4958 description
: r
##"Denies the configured methods and functions in clippy.toml"##,
4961 label
: "clippy::disallowed_script_idents",
4962 description
: r
##"Checks for usage of unicode scripts other than those explicitly allowed
4965 This lint doesn't take into account non-text scripts such as `Unknown` and `Linear_A`.
4966 It also ignores the `Common` script type.
4967 While configuring, be sure to use official script name [aliases] from
4968 [the list of supported scripts][supported_scripts].
4970 See also: [`non_ascii_idents`].
4972 [aliases]: http://www.unicode.org/reports/tr24/tr24-31.html#Script_Value_Aliases
4973 [supported_scripts]: https://www.unicode.org/iso15924/iso15924-codes.html"##,
4976 label
: "clippy::disallowed_types",
4977 description
: r
##"Denies the configured types in clippy.toml."##,
4980 label
: "clippy::diverging_sub_expression",
4981 description
: r
##"Checks for diverging calls that are not match arms or
4985 label
: "clippy::doc_markdown",
4986 description
: r
##"Checks for the presence of `_`, `::` or camel-case words
4987 outside ticks in documentation."##,
4990 label
: "clippy::double_comparisons",
4991 description
: r
##"Checks for double comparisons that could be simplified to a single expression."##,
4994 label
: "clippy::double_must_use",
4995 description
: r
##"Checks for a `#[must_use]` attribute without
4996 further information on functions and methods that return a type already
4997 marked as `#[must_use]`."##,
5000 label
: "clippy::double_neg",
5001 description
: r
##"Detects expressions of the form `--x`."##,
5004 label
: "clippy::double_parens",
5005 description
: r
##"Checks for unnecessary double parentheses."##,
5008 label
: "clippy::drop_copy",
5009 description
: r
##"Checks for calls to `std::mem::drop` with a value
5010 that derives the Copy trait"##,
5013 label
: "clippy::drop_ref",
5014 description
: r
##"Checks for calls to `std::mem::drop` with a reference
5015 instead of an owned value."##,
5018 label
: "clippy::duplicate_underscore_argument",
5019 description
: r
##"Checks for function arguments having the similar names
5020 differing by an underscore."##,
5023 label
: "clippy::duration_subsec",
5024 description
: r
##"Checks for calculation of subsecond microseconds or milliseconds
5025 from other `Duration` methods."##,
5028 label
: "clippy::else_if_without_else",
5029 description
: r
##"Checks for usage of if expressions with an `else if` branch,
5030 but without a final `else` branch."##,
5033 label
: "clippy::empty_enum",
5034 description
: r
##"Checks for `enum`s with no variants.
5036 As of this writing, the `never_type` is still a
5037 nightly-only experimental API. Therefore, this lint is only triggered
5038 if the `never_type` is enabled."##,
5041 label
: "clippy::empty_line_after_outer_attr",
5042 description
: r
##"Checks for empty lines after outer attributes"##,
5044 Lint { label: "clippy::empty_loop", description: r##"Checks for empty `loop` expressions."## }
,
5046 label
: "clippy::enum_clike_unportable_variant",
5047 description
: r
##"Checks for C-like enumerations that are
5048 `repr(isize/usize)` and have values that don't fit into an `i32`."##,
5050 Lint { label: "clippy::enum_glob_use", description: r##"Checks for `use Enum::*`."## }
,
5052 label
: "clippy::enum_variant_names",
5053 description
: r
##"Detects enumeration variants that are prefixed or suffixed
5054 by the same characters."##,
5057 label
: "clippy::eq_op",
5058 description
: r
##"Checks for equal operands to comparison, logical and
5059 bitwise, difference and division binary operators (`==`, `>`, etc., `&&`,
5060 `||`, `&`, `|`, `^`, `-` and `/`)."##,
5063 label
: "clippy::equatable_if_let",
5064 description
: r
##"Checks for pattern matchings that can be expressed using equality."##,
5067 label
: "clippy::erasing_op",
5068 description
: r
##"Checks for erasing operations, e.g., `x * 0`."##,
5071 label
: "clippy::eval_order_dependence",
5072 description
: r
##"Checks for a read and a write to the same variable where
5073 whether the read occurs before or after the write depends on the evaluation
5074 order of sub-expressions."##,
5077 label
: "clippy::excessive_precision",
5078 description
: r
##"Checks for float literals with a precision greater
5079 than that supported by the underlying type."##,
5082 label
: "clippy::exhaustive_enums",
5083 description
: r
##"Warns on any exported `enum`s that are not tagged `#[non_exhaustive]`"##,
5086 label
: "clippy::exhaustive_structs",
5087 description
: r
##"Warns on any exported `structs`s that are not tagged `#[non_exhaustive]`"##,
5090 label
: "clippy::exit",
5091 description
: r
##"`exit()` terminates the program and doesn't provide a
5095 label
: "clippy::expect_fun_call",
5096 description
: r
##"Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`,
5097 etc., and suggests to use `unwrap_or_else` instead"##,
5100 label
: "clippy::expect_used",
5101 description
: r
##"Checks for `.expect()` calls on `Option`s and `Result`s."##,
5104 label
: "clippy::expl_impl_clone_on_copy",
5105 description
: r
##"Checks for explicit `Clone` implementations for `Copy`
5109 label
: "clippy::explicit_counter_loop",
5110 description
: r
##"Checks `for` loops over slices with an explicit counter
5111 and suggests the use of `.enumerate()`."##,
5114 label
: "clippy::explicit_deref_methods",
5115 description
: r
##"Checks for explicit `deref()` or `deref_mut()` method calls."##,
5118 label
: "clippy::explicit_into_iter_loop",
5119 description
: r
##"Checks for loops on `y.into_iter()` where `y` will do, and
5120 suggests the latter."##,
5123 label
: "clippy::explicit_iter_loop",
5124 description
: r
##"Checks for loops on `x.iter()` where `&x` will do, and
5125 suggests the latter."##,
5128 label
: "clippy::explicit_write",
5129 description
: r
##"Checks for usage of `write!()` / `writeln()!` which can be
5130 replaced with `(e)print!()` / `(e)println!()`"##,
5133 label
: "clippy::extend_from_slice",
5134 description
: r
##"Nothing. This lint has been deprecated."##,
5137 label
: "clippy::extend_with_drain",
5138 description
: r
##"Checks for occurrences where one vector gets extended instead of append"##,
5141 label
: "clippy::extra_unused_lifetimes",
5142 description
: r
##"Checks for lifetimes in generics that are never used
5146 label
: "clippy::fallible_impl_from",
5147 description
: r
##"Checks for impls of `From<..>` that contain `panic!()` or `unwrap()`"##,
5150 label
: "clippy::field_reassign_with_default",
5151 description
: r
##"Checks for immediate reassignment of fields initialized
5152 with Default::default()."##,
5155 label
: "clippy::filetype_is_file",
5156 description
: r
##"Checks for `FileType::is_file()`."##,
5159 label
: "clippy::filter_map",
5160 description
: r
##"Nothing. This lint has been deprecated."##,
5163 label
: "clippy::filter_map_identity",
5164 description
: r
##"Checks for usage of `filter_map(|x| x)`."##,
5167 label
: "clippy::filter_map_next",
5168 description
: r
##"Checks for usage of `_.filter_map(_).next()`."##,
5171 label
: "clippy::filter_next",
5172 description
: r
##"Checks for usage of `_.filter(_).next()`."##,
5174 Lint { label: "clippy::find_map", description: r##"Nothing. This lint has been deprecated."## }
,
5176 label
: "clippy::flat_map_identity",
5177 description
: r
##"Checks for usage of `flat_map(|x| x)`."##,
5180 label
: "clippy::flat_map_option",
5181 description
: r
##"Checks for usages of `Iterator::flat_map()` where `filter_map()` could be
5184 Lint { label: "clippy::float_arithmetic", description: r##"Checks for float arithmetic."## }
,
5186 label
: "clippy::float_cmp",
5187 description
: r
##"Checks for (in-)equality comparisons on floating-point
5188 values (apart from zero), except in functions called `*eq*` (which probably
5189 implement equality for a type involving floats)."##,
5192 label
: "clippy::float_cmp_const",
5193 description
: r
##"Checks for (in-)equality comparisons on floating-point
5194 value and constant, except in functions called `*eq*` (which probably
5195 implement equality for a type involving floats)."##,
5198 label
: "clippy::float_equality_without_abs",
5199 description
: r
##"Checks for statements of the form `(a - b) < f32::EPSILON` or
5200 `(a - b) < f64::EPSILON`. Notes the missing `.abs()`."##,
5203 label
: "clippy::fn_address_comparisons",
5204 description
: r
##"Checks for comparisons with an address of a function item."##,
5207 label
: "clippy::fn_params_excessive_bools",
5208 description
: r
##"Checks for excessive use of
5209 bools in function definitions."##,
5212 label
: "clippy::fn_to_numeric_cast",
5213 description
: r
##"Checks for casts of function pointers to something other than usize"##,
5216 label
: "clippy::fn_to_numeric_cast_any",
5217 description
: r
##"Checks for casts of a function pointer to any integer type."##,
5220 label
: "clippy::fn_to_numeric_cast_with_truncation",
5221 description
: r
##"Checks for casts of a function pointer to a numeric type not wide enough to
5225 label
: "clippy::for_kv_map",
5226 description
: r
##"Checks for iterating a map (`HashMap` or `BTreeMap`) and
5227 ignoring either the keys or values."##,
5230 label
: "clippy::for_loops_over_fallibles",
5231 description
: r
##"Checks for `for` loops over `Option` or `Result` values."##,
5234 label
: "clippy::forget_copy",
5235 description
: r
##"Checks for calls to `std::mem::forget` with a value that
5236 derives the Copy trait"##,
5239 label
: "clippy::forget_ref",
5240 description
: r
##"Checks for calls to `std::mem::forget` with a reference
5241 instead of an owned value."##,
5244 label
: "clippy::format_in_format_args",
5245 description
: r
##"Detects `format!` within the arguments of another macro that does
5246 formatting such as `format!` itself, `write!` or `println!`. Suggests
5247 inlining the `format!` call."##,
5250 label
: "clippy::from_iter_instead_of_collect",
5251 description
: r
##"Checks for `from_iter()` function calls on types that implement the `FromIterator`
5255 label
: "clippy::from_over_into",
5256 description
: r
##"Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead."##,
5259 label
: "clippy::from_str_radix_10",
5260 description
: r
##"Checks for function invocations of the form `primitive::from_str_radix(s, 10)`"##,
5263 label
: "clippy::future_not_send",
5264 description
: r
##"This lint requires Future implementations returned from
5265 functions and methods to implement the `Send` marker trait. It is mostly
5266 used by library authors (public and internal) that target an audience where
5267 multithreaded executors are likely to be used for running these Futures."##,
5270 label
: "clippy::get_last_with_len",
5271 description
: r
##"Checks for using `x.get(x.len() - 1)` instead of
5275 label
: "clippy::get_unwrap",
5276 description
: r
##"Checks for use of `.get().unwrap()` (or
5277 `.get_mut().unwrap`) on a standard library type which implements `Index`"##,
5280 label
: "clippy::identity_op",
5281 description
: r
##"Checks for identity operations, e.g., `x + 0`."##,
5284 label
: "clippy::if_let_mutex",
5285 description
: r
##"Checks for `Mutex::lock` calls in `if let` expression
5286 with lock calls in any of the else blocks."##,
5289 label
: "clippy::if_let_redundant_pattern_matching",
5290 description
: r
##"Nothing. This lint has been deprecated."##,
5293 label
: "clippy::if_not_else",
5294 description
: r
##"Checks for usage of `!` or `!=` in an if condition with an
5298 label
: "clippy::if_same_then_else",
5299 description
: r
##"Checks for `if/else` with the same body as the *then* part
5300 and the *else* part."##,
5303 label
: "clippy::if_then_some_else_none",
5304 description
: r
##"Checks for if-else that could be written to `bool::then`."##,
5307 label
: "clippy::ifs_same_cond",
5308 description
: r
##"Checks for consecutive `if`s with the same condition."##,
5311 label
: "clippy::implicit_clone",
5312 description
: r
##"Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer."##,
5315 label
: "clippy::implicit_hasher",
5316 description
: r
##"Checks for public `impl` or `fn` missing generalization
5317 over different hashers and implicitly defaulting to the default hashing
5318 algorithm (`SipHash`)."##,
5321 label
: "clippy::implicit_return",
5322 description
: r
##"Checks for missing return statements at the end of a block."##,
5325 label
: "clippy::implicit_saturating_sub",
5326 description
: r
##"Checks for implicit saturating subtraction."##,
5329 label
: "clippy::imprecise_flops",
5330 description
: r
##"Looks for floating-point expressions that
5331 can be expressed using built-in methods to improve accuracy
5332 at the cost of performance."##,
5335 label
: "clippy::inconsistent_digit_grouping",
5336 description
: r
##"Warns if an integral or floating-point constant is
5337 grouped inconsistently with underscores."##,
5340 label
: "clippy::inconsistent_struct_constructor",
5341 description
: r
##"Checks for struct constructors where all fields are shorthand and
5342 the order of the field init shorthand in the constructor is inconsistent
5343 with the order in the struct definition."##,
5346 label
: "clippy::index_refutable_slice",
5347 description
: r
##"The lint checks for slice bindings in patterns that are only used to
5348 access individual slice values."##,
5351 label
: "clippy::indexing_slicing",
5352 description
: r
##"Checks for usage of indexing or slicing. Arrays are special cases, this lint
5353 does report on arrays if we can tell that slicing operations are in bounds and does not
5354 lint on constant `usize` indexing on arrays because that is handled by rustc's `const_err` lint."##,
5357 label
: "clippy::ineffective_bit_mask",
5358 description
: r
##"Checks for bit masks in comparisons which can be removed
5359 without changing the outcome. The basic structure can be seen in the
5362 |Comparison| Bit Op |Example |equals |
5363 |----------|---------|-----------|-------|
5364 |`>` / `<=`|`|` / `^`|`x | 2 > 3`|`x > 3`|
5365 |`<` / `>=`|`|` / `^`|`x ^ 1 < 4`|`x < 4`|"##,
5368 label
: "clippy::inefficient_to_string",
5369 description
: r
##"Checks for usage of `.to_string()` on an `&&T` where
5370 `T` implements `ToString` directly (like `&&str` or `&&String`)."##,
5373 label
: "clippy::infallible_destructuring_match",
5374 description
: r
##"Checks for matches being used to destructure a single-variant enum
5375 or tuple struct where a `let` will suffice."##,
5378 label
: "clippy::infinite_iter",
5379 description
: r
##"Checks for iteration that is guaranteed to be infinite."##,
5382 label
: "clippy::inherent_to_string",
5383 description
: r
##"Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`."##,
5386 label
: "clippy::inherent_to_string_shadow_display",
5387 description
: r
##"Checks for the definition of inherent methods with a signature of `to_string(&self) -> String` and if the type implementing this method also implements the `Display` trait."##,
5390 label
: "clippy::inline_always",
5391 description
: r
##"Checks for items annotated with `#[inline(always)]`,
5392 unless the annotated function is empty or simply panics."##,
5395 label
: "clippy::inline_asm_x86_att_syntax",
5396 description
: r
##"Checks for usage of AT&T x86 assembly syntax."##,
5399 label
: "clippy::inline_asm_x86_intel_syntax",
5400 description
: r
##"Checks for usage of Intel x86 assembly syntax."##,
5403 label
: "clippy::inline_fn_without_body",
5404 description
: r
##"Checks for `#[inline]` on trait methods without bodies"##,
5407 label
: "clippy::inspect_for_each",
5408 description
: r
##"Checks for usage of `inspect().for_each()`."##,
5411 label
: "clippy::int_plus_one",
5412 description
: r
##"Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block"##,
5415 label
: "clippy::integer_arithmetic",
5416 description
: r
##"Checks for integer arithmetic operations which could overflow or panic.
5418 Specifically, checks for any operators (`+`, `-`, `*`, `<<`, etc) which are capable
5419 of overflowing according to the [Rust
5420 Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow),
5421 or which can panic (`/`, `%`). No bounds analysis or sophisticated reasoning is
5424 Lint { label: "clippy::integer_division", description: r##"Checks for division of integers"## }
,
5426 label
: "clippy::into_iter_on_ref",
5427 description
: r
##"Checks for `into_iter` calls on references which should be replaced by `iter`
5431 label
: "clippy::invalid_null_ptr_usage",
5432 description
: r
##"This lint checks for invalid usages of `ptr::null`."##,
5435 label
: "clippy::invalid_regex",
5436 description
: r
##"Checks [regex](https://crates.io/crates/regex) creation
5437 (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`) for correct
5441 label
: "clippy::invalid_upcast_comparisons",
5442 description
: r
##"Checks for comparisons where the relation is always either
5443 true or false, but where one side has been upcast so that the comparison is
5444 necessary. Only integer types are checked."##,
5447 label
: "clippy::invisible_characters",
5448 description
: r
##"Checks for invisible Unicode characters in the code."##,
5451 label
: "clippy::items_after_statements",
5452 description
: r
##"Checks for items declared after some statement in a block."##,
5455 label
: "clippy::iter_cloned_collect",
5456 description
: r
##"Checks for the use of `.cloned().collect()` on slice to
5460 label
: "clippy::iter_count",
5461 description
: r
##"Checks for the use of `.iter().count()`."##,
5463 Lint { label: "clippy::iter_next_loop", description: r##"Checks for loops on `x.next()`."## }
,
5465 label
: "clippy::iter_next_slice",
5466 description
: r
##"Checks for usage of `iter().next()` on a Slice or an Array"##,
5469 label
: "clippy::iter_not_returning_iterator",
5470 description
: r
##"Detects methods named `iter` or `iter_mut` that do not have a return type that implements `Iterator`."##,
5473 label
: "clippy::iter_nth",
5474 description
: r
##"Checks for use of `.iter().nth()` (and the related
5475 `.iter_mut().nth()`) on standard library types with *O*(1) element access."##,
5478 label
: "clippy::iter_nth_zero",
5479 description
: r
##"Checks for the use of `iter.nth(0)`."##,
5482 label
: "clippy::iter_skip_next",
5483 description
: r
##"Checks for use of `.skip(x).next()` on iterators."##,
5486 label
: "clippy::iterator_step_by_zero",
5487 description
: r
##"Checks for calling `.step_by(0)` on iterators which panics."##,
5490 label
: "clippy::just_underscores_and_digits",
5491 description
: r
##"Checks if you have variables whose name consists of just
5492 underscores and digits."##,
5495 label
: "clippy::large_const_arrays",
5496 description
: r
##"Checks for large `const` arrays that should
5497 be defined as `static` instead."##,
5500 label
: "clippy::large_digit_groups",
5501 description
: r
##"Warns if the digits of an integral or floating-point
5502 constant are grouped into groups that
5506 label
: "clippy::large_enum_variant",
5507 description
: r
##"Checks for large size differences between variants on
5511 label
: "clippy::large_stack_arrays",
5512 description
: r
##"Checks for local arrays that may be too large."##,
5515 label
: "clippy::large_types_passed_by_value",
5516 description
: r
##"Checks for functions taking arguments by value, where
5517 the argument type is `Copy` and large enough to be worth considering
5518 passing by reference. Does not trigger if the function is being exported,
5519 because that might induce API breakage, if the parameter is declared as mutable,
5520 or if the argument is a `self`."##,
5523 label
: "clippy::len_without_is_empty",
5524 description
: r
##"Checks for items that implement `.len()` but not
5528 label
: "clippy::len_zero",
5529 description
: r
##"Checks for getting the length of something via `.len()`
5530 just to compare to zero, and suggests using `.is_empty()` where applicable."##,
5533 label
: "clippy::let_and_return",
5534 description
: r
##"Checks for `let`-bindings, which are subsequently
5538 label
: "clippy::let_underscore_drop",
5539 description
: r
##"Checks for `let _ = <expr>`
5540 where expr has a type that implements `Drop`"##,
5543 label
: "clippy::let_underscore_lock",
5544 description
: r
##"Checks for `let _ = sync_lock`.
5545 This supports `mutex` and `rwlock` in `std::sync` and `parking_lot`."##,
5548 label
: "clippy::let_underscore_must_use",
5549 description
: r
##"Checks for `let _ = <expr>` where expr is `#[must_use]`"##,
5551 Lint { label: "clippy::let_unit_value", description: r##"Checks for binding a unit value."## }
,
5553 label
: "clippy::linkedlist",
5554 description
: r
##"Checks for usage of any `LinkedList`, suggesting to use a
5555 `Vec` or a `VecDeque` (formerly called `RingBuf`)."##,
5558 label
: "clippy::logic_bug",
5559 description
: r
##"Checks for boolean expressions that contain terminals that
5560 can be eliminated."##,
5563 label
: "clippy::lossy_float_literal",
5564 description
: r
##"Checks for whole number float literals that
5565 cannot be represented as the underlying type without loss."##,
5568 label
: "clippy::macro_use_imports",
5569 description
: r
##"Checks for `#[macro_use] use...`."##,
5572 label
: "clippy::main_recursion",
5573 description
: r
##"Checks for recursion using the entrypoint."##,
5576 label
: "clippy::manual_assert",
5577 description
: r
##"Detects `if`-then-`panic!` that can be replaced with `assert!`."##,
5580 label
: "clippy::manual_async_fn",
5581 description
: r
##"It checks for manual implementations of `async` functions."##,
5584 label
: "clippy::manual_filter_map",
5585 description
: r
##"Checks for usage of `_.filter(_).map(_)` that can be written more simply
5586 as `filter_map(_)`."##,
5589 label
: "clippy::manual_find_map",
5590 description
: r
##"Checks for usage of `_.find(_).map(_)` that can be written more simply
5591 as `find_map(_)`."##,
5594 label
: "clippy::manual_flatten",
5595 description
: r
##"Check for unnecessary `if let` usage in a for loop
5596 where only the `Some` or `Ok` variant of the iterator element is used."##,
5599 label
: "clippy::manual_map",
5600 description
: r
##"Checks for usages of `match` which could be implemented using `map`"##,
5603 label
: "clippy::manual_memcpy",
5604 description
: r
##"Checks for for-loops that manually copy items between
5605 slices that could be optimized by having a memcpy."##,
5608 label
: "clippy::manual_non_exhaustive",
5609 description
: r
##"Checks for manual implementations of the non-exhaustive pattern."##,
5612 label
: "clippy::manual_ok_or",
5613 description
: r
##"Finds patterns that reimplement `Option::ok_or`."##,
5616 label
: "clippy::manual_range_contains",
5617 description
: r
##"Checks for expressions like `x >= 3 && x < 8` that could
5618 be more readably expressed as `(3..8).contains(x)`."##,
5621 label
: "clippy::manual_saturating_arithmetic",
5622 description
: r
##"Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`."##,
5625 label
: "clippy::manual_split_once",
5626 description
: r
##"Checks for usages of `str::splitn(2, _)`"##,
5629 label
: "clippy::manual_str_repeat",
5630 description
: r
##"Checks for manual implementations of `str::repeat`"##,
5633 label
: "clippy::manual_strip",
5634 description
: r
##"Suggests using `strip_{prefix,suffix}` over `str::{starts,ends}_with` and slicing using
5635 the pattern's length."##,
5637 Lint { label: "clippy::manual_swap", description: r##"Checks for manual swapping."## }
,
5639 label
: "clippy::manual_unwrap_or",
5640 description
: r
##"Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`."##,
5643 label
: "clippy::many_single_char_names",
5644 description
: r
##"Checks for too many variables whose name consists of a
5645 single character."##,
5648 label
: "clippy::map_clone",
5649 description
: r
##"Checks for usage of `map(|x| x.clone())` or
5650 dereferencing closures for `Copy` types, on `Iterator` or `Option`,
5651 and suggests `cloned()` or `copied()` instead"##,
5654 label
: "clippy::map_collect_result_unit",
5655 description
: r
##"Checks for usage of `_.map(_).collect::<Result<(), _>()`."##,
5658 label
: "clippy::map_entry",
5659 description
: r
##"Checks for uses of `contains_key` + `insert` on `HashMap`
5663 label
: "clippy::map_err_ignore",
5664 description
: r
##"Checks for instances of `map_err(|_| Some::Enum)`"##,
5667 label
: "clippy::map_flatten",
5668 description
: r
##"Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option`"##,
5671 label
: "clippy::map_identity",
5672 description
: r
##"Checks for instances of `map(f)` where `f` is the identity function."##,
5675 label
: "clippy::map_unwrap_or",
5676 description
: r
##"Checks for usage of `option.map(_).unwrap_or(_)` or `option.map(_).unwrap_or_else(_)` or
5677 `result.map(_).unwrap_or_else(_)`."##,
5680 label
: "clippy::match_as_ref",
5681 description
: r
##"Checks for match which is used to add a reference to an
5685 label
: "clippy::match_bool",
5686 description
: r
##"Checks for matches where match expression is a `bool`. It
5687 suggests to replace the expression with an `if...else` block."##,
5690 label
: "clippy::match_like_matches_macro",
5691 description
: r
##"Checks for `match` or `if let` expressions producing a
5692 `bool` that could be written using `matches!`"##,
5695 label
: "clippy::match_on_vec_items",
5696 description
: r
##"Checks for `match vec[idx]` or `match vec[n..m]`."##,
5699 label
: "clippy::match_overlapping_arm",
5700 description
: r
##"Checks for overlapping match arms."##,
5703 label
: "clippy::match_ref_pats",
5704 description
: r
##"Checks for matches where all arms match a reference,
5705 suggesting to remove the reference and deref the matched expression
5706 instead. It also checks for `if let &foo = bar` blocks."##,
5709 label
: "clippy::match_result_ok",
5710 description
: r
##"Checks for unnecessary `ok()` in `while let`."##,
5713 label
: "clippy::match_same_arms",
5714 description
: r
##"Checks for `match` with identical arm bodies."##,
5717 label
: "clippy::match_single_binding",
5718 description
: r
##"Checks for useless match that binds to only one value."##,
5721 label
: "clippy::match_str_case_mismatch",
5722 description
: r
##"Checks for `match` expressions modifying the case of a string with non-compliant arms"##,
5725 label
: "clippy::match_wild_err_arm",
5726 description
: r
##"Checks for arm which matches all errors with `Err(_)`
5727 and take drastic actions like `panic!`."##,
5730 label
: "clippy::match_wildcard_for_single_variants",
5731 description
: r
##"Checks for wildcard enum matches for a single variant."##,
5734 label
: "clippy::maybe_infinite_iter",
5735 description
: r
##"Checks for iteration that may be infinite."##,
5738 label
: "clippy::mem_forget",
5739 description
: r
##"Checks for usage of `std::mem::forget(t)` where `t` is
5743 label
: "clippy::mem_replace_option_with_none",
5744 description
: r
##"Checks for `mem::replace()` on an `Option` with
5748 label
: "clippy::mem_replace_with_default",
5749 description
: r
##"Checks for `std::mem::replace` on a value of type
5750 `T` with `T::default()`."##,
5753 label
: "clippy::mem_replace_with_uninit",
5754 description
: r
##"Checks for `mem::replace(&mut _, mem::uninitialized())`
5755 and `mem::replace(&mut _, mem::zeroed())`."##,
5758 label
: "clippy::min_max",
5759 description
: r
##"Checks for expressions where `std::cmp::min` and `max` are
5760 used to clamp values, but switched so that the result is constant."##,
5763 label
: "clippy::misaligned_transmute",
5764 description
: r
##"Nothing. This lint has been deprecated."##,
5767 label
: "clippy::mismatched_target_os",
5768 description
: r
##"Checks for cfg attributes having operating systems used in target family position."##,
5771 label
: "clippy::misrefactored_assign_op",
5772 description
: r
##"Checks for `a op= a op b` or `a op= b op a` patterns."##,
5775 label
: "clippy::missing_const_for_fn",
5776 description
: r
##"Suggests the use of `const` in functions and methods where possible."##,
5779 label
: "clippy::missing_docs_in_private_items",
5780 description
: r
##"Warns if there is missing doc for any documentable item
5781 (public or private)."##,
5784 label
: "clippy::missing_enforced_import_renames",
5785 description
: r
##"Checks for imports that do not rename the item as specified
5786 in the `enforce-import-renames` config option."##,
5789 label
: "clippy::missing_errors_doc",
5790 description
: r
##"Checks the doc comments of publicly visible functions that
5791 return a `Result` type and warns if there is no `# Errors` section."##,
5794 label
: "clippy::missing_inline_in_public_items",
5795 description
: r
##"It lints if an exported function, method, trait method with default impl,
5796 or trait method impl is not `#[inline]`."##,
5799 label
: "clippy::missing_panics_doc",
5800 description
: r
##"Checks the doc comments of publicly visible functions that
5801 may panic and warns if there is no `# Panics` section."##,
5804 label
: "clippy::missing_safety_doc",
5805 description
: r
##"Checks for the doc comments of publicly visible
5806 unsafe functions and warns if there is no `# Safety` section."##,
5809 label
: "clippy::mistyped_literal_suffixes",
5810 description
: r
##"Warns for mistyped suffix in literals"##,
5813 label
: "clippy::mixed_case_hex_literals",
5814 description
: r
##"Warns on hexadecimal literals with mixed-case letter
5818 label
: "clippy::mod_module_files",
5819 description
: r
##"Checks that module layout uses only self named module files, bans mod.rs files."##,
5822 label
: "clippy::module_inception",
5823 description
: r
##"Checks for modules that have the same name as their
5827 label
: "clippy::module_name_repetitions",
5828 description
: r
##"Detects type names that are prefixed or suffixed by the
5829 containing module's name."##,
5831 Lint { label: "clippy::modulo_arithmetic", description: r##"Checks for modulo arithmetic."## }
,
5833 label
: "clippy::modulo_one",
5834 description
: r
##"Checks for getting the remainder of a division by one or minus
5838 label
: "clippy::multiple_crate_versions",
5839 description
: r
##"Checks to see if multiple versions of a crate are being
5843 label
: "clippy::multiple_inherent_impl",
5844 description
: r
##"Checks for multiple inherent implementations of a struct"##,
5847 label
: "clippy::must_use_candidate",
5848 description
: r
##"Checks for public functions that have no
5849 `#[must_use]` attribute, but return something not already marked
5850 must-use, have no mutable arg and mutate no statics."##,
5853 label
: "clippy::must_use_unit",
5854 description
: r
##"Checks for a `#[must_use]` attribute on
5855 unit-returning functions and methods."##,
5858 label
: "clippy::mut_from_ref",
5859 description
: r
##"This lint checks for functions that take immutable
5860 references and return mutable ones."##,
5863 label
: "clippy::mut_mut",
5864 description
: r
##"Checks for instances of `mut mut` references."##,
5867 label
: "clippy::mut_mutex_lock",
5868 description
: r
##"Checks for `&mut Mutex::lock` calls"##,
5871 label
: "clippy::mut_range_bound",
5872 description
: r
##"Checks for loops which have a range bound that is a mutable variable"##,
5875 label
: "clippy::mutable_key_type",
5876 description
: r
##"Checks for sets/maps with mutable key types."##,
5879 label
: "clippy::mutex_atomic",
5880 description
: r
##"Checks for usages of `Mutex<X>` where an atomic will do."##,
5883 label
: "clippy::mutex_integer",
5884 description
: r
##"Checks for usages of `Mutex<X>` where `X` is an integral
5887 Lint { label: "clippy::naive_bytecount", description: r##"Checks for naive byte counts"## }
,
5889 label
: "clippy::needless_arbitrary_self_type",
5890 description
: r
##"The lint checks for `self` in fn parameters that
5891 specify the `Self`-type explicitly"##,
5894 label
: "clippy::needless_bitwise_bool",
5895 description
: r
##"Checks for uses of bitwise and/or operators between booleans, where performance may be improved by using
5899 label
: "clippy::needless_bool",
5900 description
: r
##"Checks for expressions of the form `if c { true } else {
5901 false }` (or vice versa) and suggests using the condition directly."##,
5904 label
: "clippy::needless_borrow",
5905 description
: r
##"Checks for address of operations (`&`) that are going to
5906 be dereferenced immediately by the compiler."##,
5909 label
: "clippy::needless_borrowed_reference",
5910 description
: r
##"Checks for bindings that destructure a reference and borrow the inner
5911 value with `&ref`."##,
5914 label
: "clippy::needless_collect",
5915 description
: r
##"Checks for functions collecting an iterator when collect
5919 label
: "clippy::needless_continue",
5920 description
: r
##"The lint checks for `if`-statements appearing in loops
5921 that contain a `continue` statement in either their main blocks or their
5922 `else`-blocks, when omitting the `else`-block possibly with some
5923 rearrangement of code can make the code easier to understand."##,
5926 label
: "clippy::needless_doctest_main",
5927 description
: r
##"Checks for `fn main() { .. }` in doctests"##,
5930 label
: "clippy::needless_for_each",
5931 description
: r
##"Checks for usage of `for_each` that would be more simply written as a
5935 label
: "clippy::needless_late_init",
5936 description
: r
##"Checks for late initializations that can be replaced by a `let` statement
5937 with an initializer."##,
5940 label
: "clippy::needless_lifetimes",
5941 description
: r
##"Checks for lifetime annotations which can be removed by
5942 relying on lifetime elision."##,
5945 label
: "clippy::needless_option_as_deref",
5946 description
: r
##"Checks for no-op uses of Option::{as_deref,as_deref_mut},
5947 for example, `Option<&T>::as_deref()` returns the same type."##,
5950 label
: "clippy::needless_pass_by_value",
5951 description
: r
##"Checks for functions taking arguments by value, but not
5952 consuming them in its
5956 label
: "clippy::needless_question_mark",
5957 description
: r
##"Suggests alternatives for useless applications of `?` in terminating expressions"##,
5960 label
: "clippy::needless_range_loop",
5961 description
: r
##"Checks for looping over the range of `0..len` of some
5962 collection just to get the values by index."##,
5965 label
: "clippy::needless_return",
5966 description
: r
##"Checks for return statements at the end of a block."##,
5969 label
: "clippy::needless_splitn",
5970 description
: r
##"Checks for usages of `str::splitn` (or `str::rsplitn`) where using `str::split` would be the same."##,
5973 label
: "clippy::needless_update",
5974 description
: r
##"Checks for needlessly including a base struct on update
5975 when all fields are changed anyway.
5977 This lint is not applied to structs marked with
5978 [non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html)."##,
5981 label
: "clippy::neg_cmp_op_on_partial_ord",
5982 description
: r
##"Checks for the usage of negated comparison operators on types which only implement
5983 `PartialOrd` (e.g., `f64`)."##,
5986 label
: "clippy::neg_multiply",
5987 description
: r
##"Checks for multiplication by -1 as a form of negation."##,
5990 label
: "clippy::negative_feature_names",
5991 description
: r
##"Checks for negative feature names with prefix `no-` or `not-`"##,
5994 label
: "clippy::never_loop",
5995 description
: r
##"Checks for loops that will always `break`, `return` or
5996 `continue` an outer loop."##,
5999 label
: "clippy::new_ret_no_self",
6000 description
: r
##"Checks for `new` not returning a type that contains `Self`."##,
6003 label
: "clippy::new_without_default",
6004 description
: r
##"Checks for types with a `fn new() -> Self` method and no
6006 [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)."##,
6009 label
: "clippy::no_effect",
6010 description
: r
##"Checks for statements which have no effect."##,
6013 label
: "clippy::no_effect_underscore_binding",
6014 description
: r
##"Checks for binding to underscore prefixed variable without side-effects."##,
6017 label
: "clippy::non_ascii_literal",
6018 description
: r
##"Checks for non-ASCII characters in string and char literals."##,
6021 label
: "clippy::non_octal_unix_permissions",
6022 description
: r
##"Checks for non-octal values used to set Unix file permissions."##,
6025 label
: "clippy::non_send_fields_in_send_ty",
6026 description
: r
##"This lint warns about a `Send` implementation for a type that
6027 contains fields that are not safe to be sent across threads.
6028 It tries to detect fields that can cause a soundness issue
6029 when sent to another thread (e.g., `Rc`) while allowing `!Send` fields
6030 that are expected to exist in a `Send` type, such as raw pointers."##,
6033 label
: "clippy::nonminimal_bool",
6034 description
: r
##"Checks for boolean expressions that can be written more
6038 label
: "clippy::nonsensical_open_options",
6039 description
: r
##"Checks for duplicate open options as well as combinations
6040 that make no sense."##,
6043 label
: "clippy::nonstandard_macro_braces",
6044 description
: r
##"Checks that common macros are used with consistent bracing."##,
6047 label
: "clippy::not_unsafe_ptr_arg_deref",
6048 description
: r
##"Checks for public functions that dereference raw pointer
6049 arguments but are not marked `unsafe`."##,
6052 label
: "clippy::octal_escapes",
6053 description
: r
##"Checks for `\\0` escapes in string and byte literals that look like octal
6054 character escapes in C."##,
6056 Lint { label: "clippy::ok_expect", description: r##"Checks for usage of `ok().expect(..)`."## }
,
6058 label
: "clippy::op_ref",
6059 description
: r
##"Checks for arguments to `==` which have their address
6060 taken to satisfy a bound
6061 and suggests to dereference the other argument instead"##,
6064 label
: "clippy::option_as_ref_deref",
6065 description
: r
##"Checks for usage of `_.as_ref().map(Deref::deref)` or it's aliases (such as String::as_str)."##,
6068 label
: "clippy::option_env_unwrap",
6069 description
: r
##"Checks for usage of `option_env!(...).unwrap()` and
6070 suggests usage of the `env!` macro."##,
6073 label
: "clippy::option_filter_map",
6074 description
: r
##"Checks for indirect collection of populated `Option`"##,
6077 label
: "clippy::option_if_let_else",
6078 description
: r
##"Lints usage of `if let Some(v) = ... { y } else { x }` which is more
6079 idiomatically done with `Option::map_or` (if the else bit is a pure
6080 expression) or `Option::map_or_else` (if the else bit is an impure
6084 label
: "clippy::option_map_or_none",
6085 description
: r
##"Checks for usage of `_.map_or(None, _)`."##,
6088 label
: "clippy::option_map_unit_fn",
6089 description
: r
##"Checks for usage of `option.map(f)` where f is a function
6090 or closure that returns the unit type `()`."##,
6093 label
: "clippy::option_option",
6094 description
: r
##"Checks for use of `Option<Option<_>>` in function signatures and type
6098 label
: "clippy::or_fun_call",
6099 description
: r
##"Checks for calls to `.or(foo(..))`, `.unwrap_or(foo(..))`,
6100 etc., and suggests to use `or_else`, `unwrap_or_else`, etc., or
6101 `unwrap_or_default` instead."##,
6104 label
: "clippy::out_of_bounds_indexing",
6105 description
: r
##"Checks for out of bounds array indexing with a constant
6109 label
: "clippy::overflow_check_conditional",
6110 description
: r
##"Detects classic underflow/overflow checks."##,
6112 Lint { label: "clippy::panic", description: r##"Checks for usage of `panic!`."## }
,
6114 label
: "clippy::panic_in_result_fn",
6115 description
: r
##"Checks for usage of `panic!`, `unimplemented!`, `todo!`, `unreachable!` or assertions in a function of type result."##,
6118 label
: "clippy::panicking_unwrap",
6119 description
: r
##"Checks for calls of `unwrap[_err]()` that will always fail."##,
6122 label
: "clippy::partialeq_ne_impl",
6123 description
: r
##"Checks for manual re-implementations of `PartialEq::ne`."##,
6126 label
: "clippy::path_buf_push_overwrite",
6127 description
: r
##"* Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)
6128 calls on `PathBuf` that can cause overwrites."##,
6131 label
: "clippy::pattern_type_mismatch",
6132 description
: r
##"Checks for patterns that aren't exact representations of the types
6133 they are applied to.
6135 To satisfy this lint, you will have to adjust either the expression that is matched
6136 against or the pattern itself, as well as the bindings that are introduced by the
6137 adjusted patterns. For matching you will have to either dereference the expression
6138 with the `*` operator, or amend the patterns to explicitly match against `&<pattern>`
6139 or `&mut <pattern>` depending on the reference mutability. For the bindings you need
6140 to use the inverse. You can leave them as plain bindings if you wish for the value
6141 to be copied, but you must use `ref mut <variable>` or `ref <variable>` to construct
6142 a reference into the matched structure.
6144 If you are looking for a way to learn about ownership semantics in more detail, it
6145 is recommended to look at IDE options available to you to highlight types, lifetimes
6146 and reference semantics in your code. The available tooling would expose these things
6147 in a general way even outside of the various pattern matching mechanics. Of course
6148 this lint can still be used to highlight areas of interest and ensure a good understanding
6149 of ownership semantics."##,
6152 label
: "clippy::possible_missing_comma",
6153 description
: r
##"Checks for possible missing comma in an array. It lints if
6154 an array element is a binary operator expression and it lies on two lines."##,
6157 label
: "clippy::precedence",
6158 description
: r
##"Checks for operations where precedence may be unclear
6159 and suggests to add parentheses. Currently it catches the following:
6160 * mixed usage of arithmetic and bit shifting/combining operators without
6162 * a negative numeric literal (which is really a unary `-` followed by a
6164 followed by a method call"##,
6167 label
: "clippy::print_literal",
6168 description
: r
##"This lint warns about the use of literals as `print!`/`println!` args."##,
6171 label
: "clippy::print_stderr",
6172 description
: r
##"Checks for printing on *stderr*. The purpose of this lint
6173 is to catch debugging remnants."##,
6176 label
: "clippy::print_stdout",
6177 description
: r
##"Checks for printing on *stdout*. The purpose of this lint
6178 is to catch debugging remnants."##,
6181 label
: "clippy::print_with_newline",
6182 description
: r
##"This lint warns when you use `print!()` with a format
6183 string that ends in a newline."##,
6186 label
: "clippy::println_empty_string",
6187 description
: r
##"This lint warns when you use `println!()` to
6188 print a newline."##,
6191 label
: "clippy::ptr_arg",
6192 description
: r
##"This lint checks for function arguments of type `&String`
6193 or `&Vec` unless the references are mutable. It will also suggest you
6194 replace `.clone()` calls with the appropriate `.to_owned()`/`to_string()`
6198 label
: "clippy::ptr_as_ptr",
6199 description
: r
##"Checks for `as` casts between raw pointers without changing its mutability,
6200 namely `*const T` to `*const U` and `*mut T` to `*mut U`."##,
6202 Lint { label: "clippy::ptr_eq", description: r##"Use `std::ptr::eq` when applicable"## }
,
6204 label
: "clippy::ptr_offset_with_cast",
6205 description
: r
##"Checks for usage of the `offset` pointer method with a `usize` casted to an
6209 label
: "clippy::pub_enum_variant_names",
6210 description
: r
##"Nothing. This lint has been deprecated."##,
6213 label
: "clippy::question_mark",
6214 description
: r
##"Checks for expressions that could be replaced by the question mark operator."##,
6217 label
: "clippy::range_minus_one",
6218 description
: r
##"Checks for inclusive ranges where 1 is subtracted from
6219 the upper bound, e.g., `x..=(y-1)`."##,
6222 label
: "clippy::range_plus_one",
6223 description
: r
##"Checks for exclusive ranges where 1 is added to the
6224 upper bound, e.g., `x..(y+1)`."##,
6227 label
: "clippy::range_step_by_zero",
6228 description
: r
##"Nothing. This lint has been deprecated."##,
6231 label
: "clippy::range_zip_with_len",
6232 description
: r
##"Checks for zipping a collection with the range of
6236 label
: "clippy::rc_buffer",
6237 description
: r
##"Checks for `Rc<T>` and `Arc<T>` when `T` is a mutable buffer type such as `String` or `Vec`."##,
6239 Lint { label: "clippy::rc_mutex", description: r##"Checks for `Rc<Mutex<T>>`."## }
,
6241 label
: "clippy::redundant_allocation",
6242 description
: r
##"Checks for use of redundant allocations anywhere in the code."##,
6245 label
: "clippy::redundant_clone",
6246 description
: r
##"Checks for a redundant `clone()` (and its relatives) which clones an owned
6247 value that is going to be dropped without further use."##,
6250 label
: "clippy::redundant_closure",
6251 description
: r
##"Checks for closures which just call another function where
6252 the function can be called directly. `unsafe` functions or calls where types
6253 get adjusted are ignored."##,
6256 label
: "clippy::redundant_closure_call",
6257 description
: r
##"Detects closures called in the same expression where they
6261 label
: "clippy::redundant_closure_for_method_calls",
6262 description
: r
##"Checks for closures which only invoke a method on the closure
6263 argument and can be replaced by referencing the method directly."##,
6266 label
: "clippy::redundant_else",
6267 description
: r
##"Checks for `else` blocks that can be removed without changing semantics."##,
6270 label
: "clippy::redundant_feature_names",
6271 description
: r
##"Checks for feature names with prefix `use-`, `with-` or suffix `-support`"##,
6274 label
: "clippy::redundant_field_names",
6275 description
: r
##"Checks for fields in struct literals where shorthands
6279 label
: "clippy::redundant_pattern",
6280 description
: r
##"Checks for patterns in the form `name @ _`."##,
6283 label
: "clippy::redundant_pattern_matching",
6284 description
: r
##"Lint for redundant pattern matching over `Result`, `Option`,
6285 `std::task::Poll` or `std::net::IpAddr`"##,
6288 label
: "clippy::redundant_pub_crate",
6289 description
: r
##"Checks for items declared `pub(crate)` that are not crate visible because they
6290 are inside a private module."##,
6293 label
: "clippy::redundant_slicing",
6294 description
: r
##"Checks for redundant slicing expressions which use the full range, and
6295 do not change the type."##,
6298 label
: "clippy::redundant_static_lifetimes",
6299 description
: r
##"Checks for constants and statics with an explicit `'static` lifetime."##,
6302 label
: "clippy::ref_binding_to_reference",
6303 description
: r
##"Checks for `ref` bindings which create a reference to a reference."##,
6306 label
: "clippy::ref_in_deref",
6307 description
: r
##"Checks for references in expressions that use
6308 auto dereference."##,
6311 label
: "clippy::ref_option_ref",
6312 description
: r
##"Checks for usage of `&Option<&T>`."##,
6315 label
: "clippy::regex_macro",
6316 description
: r
##"Nothing. This lint has been deprecated."##,
6319 label
: "clippy::repeat_once",
6320 description
: r
##"Checks for usage of `.repeat(1)` and suggest the following method for each types.
6321 - `.to_string()` for `str`
6322 - `.clone()` for `String`
6323 - `.to_vec()` for `slice`
6325 The lint will evaluate constant expressions and values as arguments of `.repeat(..)` and emit a message if
6326 they are equivalent to `1`. (Related discussion in [rust-clippy#7306](https://github.com/rust-lang/rust-clippy/issues/7306))"##,
6329 label
: "clippy::replace_consts",
6330 description
: r
##"Nothing. This lint has been deprecated."##,
6333 label
: "clippy::rest_pat_in_fully_bound_structs",
6334 description
: r
##"Checks for unnecessary '..' pattern binding on struct when all fields are explicitly matched."##,
6337 label
: "clippy::result_map_or_into_option",
6338 description
: r
##"Checks for usage of `_.map_or(None, Some)`."##,
6341 label
: "clippy::result_map_unit_fn",
6342 description
: r
##"Checks for usage of `result.map(f)` where f is a function
6343 or closure that returns the unit type `()`."##,
6346 label
: "clippy::result_unit_err",
6347 description
: r
##"Checks for public functions that return a `Result`
6348 with an `Err` type of `()`. It suggests using a custom type that
6349 implements `std::error::Error`."##,
6352 label
: "clippy::return_self_not_must_use",
6353 description
: r
##"This lint warns when a method returning `Self` doesn't have the `#[must_use]` attribute."##,
6356 label
: "clippy::reversed_empty_ranges",
6357 description
: r
##"Checks for range expressions `x..y` where both `x` and `y`
6358 are constant and `x` is greater or equal to `y`."##,
6361 label
: "clippy::same_functions_in_if_condition",
6362 description
: r
##"Checks for consecutive `if`s with the same function call."##,
6365 label
: "clippy::same_item_push",
6366 description
: r
##"Checks whether a for loop is being used to push a constant
6367 value into a Vec."##,
6370 label
: "clippy::same_name_method",
6371 description
: r
##"It lints if a struct has two methods with the same name:
6372 one from a trait, another not from trait."##,
6375 label
: "clippy::search_is_some",
6376 description
: r
##"Checks for an iterator or string search (such as `find()`,
6377 `position()`, or `rposition()`) followed by a call to `is_some()` or `is_none()`."##,
6380 label
: "clippy::self_assignment",
6381 description
: r
##"Checks for explicit self-assignments."##,
6384 label
: "clippy::self_named_constructors",
6385 description
: r
##"Warns when constructors have the same name as their types."##,
6388 label
: "clippy::self_named_module_files",
6389 description
: r
##"Checks that module layout uses only mod.rs files."##,
6392 label
: "clippy::semicolon_if_nothing_returned",
6393 description
: r
##"Looks for blocks of expressions and fires if the last expression returns
6394 `()` but is not followed by a semicolon."##,
6397 label
: "clippy::separated_literal_suffix",
6398 description
: r
##"Warns if literal suffixes are separated by an underscore.
6399 To enforce separated literal suffix style,
6400 see the `unseparated_literal_suffix` lint."##,
6403 label
: "clippy::serde_api_misuse",
6404 description
: r
##"Checks for mis-uses of the serde API."##,
6407 label
: "clippy::shadow_reuse",
6408 description
: r
##"Checks for bindings that shadow other bindings already in
6409 scope, while reusing the original value."##,
6412 label
: "clippy::shadow_same",
6413 description
: r
##"Checks for bindings that shadow other bindings already in
6414 scope, while just changing reference level or mutability."##,
6417 label
: "clippy::shadow_unrelated",
6418 description
: r
##"Checks for bindings that shadow other bindings already in
6419 scope, either without an initialization or with one that does not even use
6420 the original value."##,
6423 label
: "clippy::short_circuit_statement",
6424 description
: r
##"Checks for the use of short circuit boolean conditions as
6429 label
: "clippy::should_assert_eq",
6430 description
: r
##"Nothing. This lint has been deprecated."##,
6433 label
: "clippy::should_implement_trait",
6434 description
: r
##"Checks for methods that should live in a trait
6435 implementation of a `std` trait (see [llogiq's blog
6436 post](http://llogiq.github.io/2015/07/30/traits.html) for further
6437 information) instead of an inherent implementation."##,
6440 label
: "clippy::similar_names",
6441 description
: r
##"Checks for names that are very similar and thus confusing."##,
6444 label
: "clippy::single_char_add_str",
6445 description
: r
##"Warns when using `push_str`/`insert_str` with a single-character string literal
6446 where `push`/`insert` with a `char` would work fine."##,
6449 label
: "clippy::single_char_pattern",
6450 description
: r
##"Checks for string methods that receive a single-character
6451 `str` as an argument, e.g., `_.split(x)`."##,
6454 label
: "clippy::single_component_path_imports",
6455 description
: r
##"Checking for imports with single component use path."##,
6458 label
: "clippy::single_element_loop",
6459 description
: r
##"Checks whether a for loop has a single element."##,
6462 label
: "clippy::single_match",
6463 description
: r
##"Checks for matches with a single arm where an `if let`
6464 will usually suffice."##,
6467 label
: "clippy::single_match_else",
6468 description
: r
##"Checks for matches with two arms where an `if let else` will
6469 usually suffice."##,
6472 label
: "clippy::size_of_in_element_count",
6473 description
: r
##"Detects expressions where
6474 `size_of::<T>` or `size_of_val::<T>` is used as a
6475 count of elements of type `T`"##,
6478 label
: "clippy::skip_while_next",
6479 description
: r
##"Checks for usage of `_.skip_while(condition).next()`."##,
6482 label
: "clippy::slow_vector_initialization",
6483 description
: r
##"Checks slow zero-filled vector initialization"##,
6486 label
: "clippy::stable_sort_primitive",
6487 description
: r
##"When sorting primitive values (integers, bools, chars, as well
6488 as arrays, slices, and tuples of such items), it is better to
6489 use an unstable sort than a stable sort."##,
6492 label
: "clippy::str_to_string",
6493 description
: r
##"This lint checks for `.to_string()` method calls on values of type `&str`."##,
6496 label
: "clippy::string_add",
6497 description
: r
##"Checks for all instances of `x + _` where `x` is of type
6498 `String`, but only if [`string_add_assign`](#string_add_assign) does *not*
6502 label
: "clippy::string_add_assign",
6503 description
: r
##"Checks for string appends of the form `x = x + y` (without
6507 label
: "clippy::string_extend_chars",
6508 description
: r
##"Checks for the use of `.extend(s.chars())` where s is a
6509 `&str` or `String`."##,
6512 label
: "clippy::string_from_utf8_as_bytes",
6513 description
: r
##"Check if the string is transformed to byte array and casted back to string."##,
6516 label
: "clippy::string_lit_as_bytes",
6517 description
: r
##"Checks for the `as_bytes` method called on string literals
6518 that contain only ASCII characters."##,
6521 label
: "clippy::string_slice",
6522 description
: r
##"Checks for slice operations on strings"##,
6525 label
: "clippy::string_to_string",
6526 description
: r
##"This lint checks for `.to_string()` method calls on values of type `String`."##,
6529 label
: "clippy::strlen_on_c_strings",
6530 description
: r
##"Checks for usage of `libc::strlen` on a `CString` or `CStr` value,
6531 and suggest calling `as_bytes().len()` or `to_bytes().len()` respectively instead."##,
6534 label
: "clippy::struct_excessive_bools",
6535 description
: r
##"Checks for excessive
6536 use of bools in structs."##,
6539 label
: "clippy::suboptimal_flops",
6540 description
: r
##"Looks for floating-point expressions that
6541 can be expressed using built-in methods to improve both
6542 accuracy and performance."##,
6545 label
: "clippy::suspicious_arithmetic_impl",
6546 description
: r
##"Lints for suspicious operations in impls of arithmetic operators, e.g.
6547 subtracting elements in an Add impl."##,
6550 label
: "clippy::suspicious_assignment_formatting",
6551 description
: r
##"Checks for use of the non-existent `=*`, `=!` and `=-`
6555 label
: "clippy::suspicious_else_formatting",
6556 description
: r
##"Checks for formatting of `else`. It lints if the `else`
6557 is followed immediately by a newline or the `else` seems to be missing."##,
6560 label
: "clippy::suspicious_map",
6561 description
: r
##"Checks for calls to `map` followed by a `count`."##,
6564 label
: "clippy::suspicious_op_assign_impl",
6565 description
: r
##"Lints for suspicious operations in impls of OpAssign, e.g.
6566 subtracting elements in an AddAssign impl."##,
6569 label
: "clippy::suspicious_operation_groupings",
6570 description
: r
##"Checks for unlikely usages of binary operators that are almost
6571 certainly typos and/or copy/paste errors, given the other usages
6572 of binary operators nearby."##,
6575 label
: "clippy::suspicious_splitn",
6576 description
: r
##"Checks for calls to [`splitn`]
6577 (https://doc.rust-lang.org/std/primitive.str.html#method.splitn) and
6578 related functions with either zero or one splits."##,
6581 label
: "clippy::suspicious_unary_op_formatting",
6582 description
: r
##"Checks the formatting of a unary operator on the right hand side
6583 of a binary operator. It lints if there is no space between the binary and unary operators,
6584 but there is a space between the unary and its operand."##,
6587 label
: "clippy::tabs_in_doc_comments",
6588 description
: r
##"Checks doc comments for usage of tab characters."##,
6591 label
: "clippy::temporary_assignment",
6592 description
: r
##"Checks for construction of a structure or tuple just to
6593 assign a value in it."##,
6596 label
: "clippy::to_digit_is_some",
6597 description
: r
##"Checks for `.to_digit(..).is_some()` on `char`s."##,
6600 label
: "clippy::to_string_in_display",
6601 description
: r
##"Checks for uses of `to_string()` in `Display` traits."##,
6604 label
: "clippy::to_string_in_format_args",
6605 description
: r
##"Checks for [`ToString::to_string`](https://doc.rust-lang.org/std/string/trait.ToString.html#tymethod.to_string)
6606 applied to a type that implements [`Display`](https://doc.rust-lang.org/std/fmt/trait.Display.html)
6607 in a macro that does formatting."##,
6609 Lint { label: "clippy::todo", description: r##"Checks for usage of `todo!`."## }
,
6611 label
: "clippy::too_many_arguments",
6612 description
: r
##"Checks for functions with too many parameters."##,
6615 label
: "clippy::too_many_lines",
6616 description
: r
##"Checks for functions with a large amount of lines."##,
6619 label
: "clippy::toplevel_ref_arg",
6620 description
: r
##"Checks for function arguments and let bindings denoted as
6624 label
: "clippy::trailing_empty_array",
6625 description
: r
##"Displays a warning when a struct with a trailing zero-sized array is declared without a `repr` attribute."##,
6628 label
: "clippy::trait_duplication_in_bounds",
6629 description
: r
##"Checks for cases where generics are being used and multiple
6630 syntax specifications for trait bounds are used simultaneously."##,
6633 label
: "clippy::transmute_bytes_to_str",
6634 description
: r
##"Checks for transmutes from a `&[u8]` to a `&str`."##,
6637 label
: "clippy::transmute_float_to_int",
6638 description
: r
##"Checks for transmutes from a float to an integer."##,
6641 label
: "clippy::transmute_int_to_bool",
6642 description
: r
##"Checks for transmutes from an integer to a `bool`."##,
6645 label
: "clippy::transmute_int_to_char",
6646 description
: r
##"Checks for transmutes from an integer to a `char`."##,
6649 label
: "clippy::transmute_int_to_float",
6650 description
: r
##"Checks for transmutes from an integer to a float."##,
6653 label
: "clippy::transmute_num_to_bytes",
6654 description
: r
##"Checks for transmutes from a number to an array of `u8`"##,
6657 label
: "clippy::transmute_ptr_to_ptr",
6658 description
: r
##"Checks for transmutes from a pointer to a pointer, or
6659 from a reference to a reference."##,
6662 label
: "clippy::transmute_ptr_to_ref",
6663 description
: r
##"Checks for transmutes from a pointer to a reference."##,
6666 label
: "clippy::transmutes_expressible_as_ptr_casts",
6667 description
: r
##"Checks for transmutes that could be a pointer cast."##,
6670 label
: "clippy::transmuting_null",
6671 description
: r
##"Checks for transmute calls which would receive a null pointer."##,
6674 label
: "clippy::trivial_regex",
6675 description
: r
##"Checks for trivial [regex](https://crates.io/crates/regex)
6676 creation (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`)."##,
6679 label
: "clippy::trivially_copy_pass_by_ref",
6680 description
: r
##"Checks for functions taking arguments by reference, where
6681 the argument type is `Copy` and small enough to be more efficient to always
6684 Lint { label: "clippy::try_err", description: r##"Checks for usages of `Err(x)?`."## }
,
6686 label
: "clippy::type_complexity",
6687 description
: r
##"Checks for types used in structs, parameters and `let`
6688 declarations above a certain complexity threshold."##,
6691 label
: "clippy::type_repetition_in_bounds",
6692 description
: r
##"This lint warns about unnecessary type repetitions in trait bounds"##,
6695 label
: "clippy::undocumented_unsafe_blocks",
6696 description
: r
##"Checks for `unsafe` blocks without a `// Safety: ` comment
6697 explaining why the unsafe operations performed inside
6698 the block are safe."##,
6701 label
: "clippy::undropped_manually_drops",
6702 description
: r
##"Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`."##,
6705 label
: "clippy::unicode_not_nfc",
6706 description
: r
##"Checks for string literals that contain Unicode in a form
6707 that is not equal to its
6708 [NFC-recomposition](http://www.unicode.org/reports/tr15/#Norm_Forms)."##,
6711 label
: "clippy::unimplemented",
6712 description
: r
##"Checks for usage of `unimplemented!`."##,
6715 label
: "clippy::uninit_assumed_init",
6716 description
: r
##"Checks for `MaybeUninit::uninit().assume_init()`."##,
6719 label
: "clippy::uninit_vec",
6720 description
: r
##"Checks for `set_len()` call that creates `Vec` with uninitialized elements.
6721 This is commonly caused by calling `set_len()` right after allocating or
6722 reserving a buffer with `new()`, `default()`, `with_capacity()`, or `reserve()`."##,
6725 label
: "clippy::unit_arg",
6726 description
: r
##"Checks for passing a unit value as an argument to a function without using a
6727 unit literal (`()`)."##,
6730 label
: "clippy::unit_cmp",
6731 description
: r
##"Checks for comparisons to unit. This includes all binary
6732 comparisons (like `==` and `<`) and asserts."##,
6734 Lint { label: "clippy::unit_hash", description: r##"Detects `().hash(_)`."## }
,
6736 label
: "clippy::unit_return_expecting_ord",
6737 description
: r
##"Checks for functions that expect closures of type
6738 Fn(...) -> Ord where the implemented closure returns the unit type.
6739 The lint also suggests to remove the semi-colon at the end of the statement if present."##,
6742 label
: "clippy::unnecessary_cast",
6743 description
: r
##"Checks for casts to the same type, casts of int literals to integer types
6744 and casts of float literals to float types."##,
6747 label
: "clippy::unnecessary_filter_map",
6748 description
: r
##"Checks for `filter_map` calls which could be replaced by `filter` or `map`.
6749 More specifically it checks if the closure provided is only performing one of the
6750 filter or map operations and suggests the appropriate option."##,
6753 label
: "clippy::unnecessary_fold",
6754 description
: r
##"Checks for using `fold` when a more succinct alternative exists.
6755 Specifically, this checks for `fold`s which could be replaced by `any`, `all`,
6756 `sum` or `product`."##,
6759 label
: "clippy::unnecessary_lazy_evaluations",
6760 description
: r
##"As the counterpart to `or_fun_call`, this lint looks for unnecessary
6761 lazily evaluated closures on `Option` and `Result`.
6763 This lint suggests changing the following functions, when eager evaluation results in
6765 - `unwrap_or_else` to `unwrap_or`
6766 - `and_then` to `and`
6768 - `get_or_insert_with` to `get_or_insert`
6769 - `ok_or_else` to `ok_or`"##,
6772 label
: "clippy::unnecessary_mut_passed",
6773 description
: r
##"Detects passing a mutable reference to a function that only
6774 requires an immutable reference."##,
6777 label
: "clippy::unnecessary_operation",
6778 description
: r
##"Checks for expression statements that can be reduced to a
6782 label
: "clippy::unnecessary_self_imports",
6783 description
: r
##"Checks for imports ending in `::{self}`."##,
6786 label
: "clippy::unnecessary_sort_by",
6787 description
: r
##"Detects uses of `Vec::sort_by` passing in a closure
6788 which compares the two arguments, either directly or indirectly."##,
6791 label
: "clippy::unnecessary_to_owned",
6792 description
: r
##"Checks for unnecessary calls to [`ToOwned::to_owned`](https://doc.rust-lang.org/std/borrow/trait.ToOwned.html#tymethod.to_owned)
6793 and other `to_owned`-like functions."##,
6796 label
: "clippy::unnecessary_unwrap",
6797 description
: r
##"Checks for calls of `unwrap[_err]()` that cannot fail."##,
6800 label
: "clippy::unnecessary_wraps",
6801 description
: r
##"Checks for private functions that only return `Ok` or `Some`."##,
6804 label
: "clippy::unneeded_field_pattern",
6805 description
: r
##"Checks for structure field patterns bound to wildcards."##,
6808 label
: "clippy::unneeded_wildcard_pattern",
6809 description
: r
##"Checks for tuple patterns with a wildcard
6810 pattern (`_`) is next to a rest pattern (`..`).
6812 _NOTE_: While `_, ..` means there is at least one element left, `..`
6813 means there are 0 or more elements left. This can make a difference
6814 when refactoring, but shouldn't result in errors in the refactored code,
6815 since the wildcard pattern isn't used anyway."##,
6818 label
: "clippy::unnested_or_patterns",
6819 description
: r
##"Checks for unnested or-patterns, e.g., `Some(0) | Some(2)` and
6820 suggests replacing the pattern with a nested one, `Some(0 | 2)`.
6822 Another way to think of this is that it rewrites patterns in
6823 *disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*."##,
6825 Lint { label: "clippy::unreachable", description: r##"Checks for usage of `unreachable!`."## }
,
6827 label
: "clippy::unreadable_literal",
6828 description
: r
##"Warns if a long integral or floating-point constant does
6829 not contain underscores."##,
6832 label
: "clippy::unsafe_derive_deserialize",
6833 description
: r
##"Checks for deriving `serde::Deserialize` on a type that
6834 has methods using `unsafe`."##,
6837 label
: "clippy::unsafe_removed_from_name",
6838 description
: r
##"Checks for imports that remove unsafe from an item's
6842 label
: "clippy::unsafe_vector_initialization",
6843 description
: r
##"Nothing. This lint has been deprecated."##,
6846 label
: "clippy::unseparated_literal_suffix",
6847 description
: r
##"Warns if literal suffixes are not separated by an
6849 To enforce unseparated literal suffix style,
6850 see the `separated_literal_suffix` lint."##,
6853 label
: "clippy::unsound_collection_transmute",
6854 description
: r
##"Checks for transmutes between collections whose
6855 types have different ABI, size or alignment."##,
6858 label
: "clippy::unstable_as_mut_slice",
6859 description
: r
##"Nothing. This lint has been deprecated."##,
6862 label
: "clippy::unstable_as_slice",
6863 description
: r
##"Nothing. This lint has been deprecated."##,
6866 label
: "clippy::unused_async",
6867 description
: r
##"Checks for functions that are declared `async` but have no `.await`s inside of them."##,
6870 label
: "clippy::unused_collect",
6871 description
: r
##"Nothing. This lint has been deprecated."##,
6874 label
: "clippy::unused_io_amount",
6875 description
: r
##"Checks for unused written/read amount."##,
6878 label
: "clippy::unused_self",
6879 description
: r
##"Checks methods that contain a `self` argument but don't use it"##,
6882 label
: "clippy::unused_unit",
6883 description
: r
##"Checks for unit (`()`) expressions that can be removed."##,
6886 label
: "clippy::unusual_byte_groupings",
6887 description
: r
##"Warns if hexadecimal or binary literals are not grouped
6888 by nibble or byte."##,
6891 label
: "clippy::unwrap_in_result",
6892 description
: r
##"Checks for functions of type `Result` that contain `expect()` or `unwrap()`"##,
6895 label
: "clippy::unwrap_or_else_default",
6896 description
: r
##"Checks for usages of `_.unwrap_or_else(Default::default)` on `Option` and
6897 `Result` values."##,
6900 label
: "clippy::unwrap_used",
6901 description
: r
##"Checks for `.unwrap()` calls on `Option`s and on `Result`s."##,
6904 label
: "clippy::upper_case_acronyms",
6905 description
: r
##"Checks for fully capitalized names and optionally names containing a capitalized acronym."##,
6908 label
: "clippy::use_debug",
6909 description
: r
##"Checks for use of `Debug` formatting. The purpose of this
6910 lint is to catch debugging remnants."##,
6913 label
: "clippy::use_self",
6914 description
: r
##"Checks for unnecessary repetition of structure name when a
6915 replacement with `Self` is applicable."##,
6918 label
: "clippy::used_underscore_binding",
6919 description
: r
##"Checks for the use of bindings with a single leading
6923 label
: "clippy::useless_asref",
6924 description
: r
##"Checks for usage of `.as_ref()` or `.as_mut()` where the
6925 types before and after the call are the same."##,
6928 label
: "clippy::useless_attribute",
6929 description
: r
##"Checks for `extern crate` and `use` items annotated with
6932 This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]`,
6933 `#[allow(unreachable_pub)]`, `#[allow(clippy::wildcard_imports)]` and
6934 `#[allow(clippy::enum_glob_use)]` on `use` items and `#[allow(unused_imports)]` on
6935 `extern crate` items with a `#[macro_use]` attribute."##,
6938 label
: "clippy::useless_conversion",
6939 description
: r
##"Checks for `Into`, `TryInto`, `From`, `TryFrom`, or `IntoIter` calls
6940 which uselessly convert to the same type."##,
6943 label
: "clippy::useless_format",
6944 description
: r
##"Checks for the use of `format!(string literal with no
6945 argument)` and `format!({}, foo)` where `foo` is a string."##,
6948 label
: "clippy::useless_let_if_seq",
6949 description
: r
##"Checks for variable declarations immediately followed by a
6950 conditional affectation."##,
6953 label
: "clippy::useless_transmute",
6954 description
: r
##"Checks for transmutes to the original type of the object
6955 and transmutes that could be a cast."##,
6958 label
: "clippy::useless_vec",
6959 description
: r
##"Checks for usage of `&vec![..]` when using `&[..]` would
6963 label
: "clippy::vec_box",
6964 description
: r
##"Checks for use of `Vec<Box<T>>` where T: Sized anywhere in the code.
6965 Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##,
6968 label
: "clippy::vec_init_then_push",
6969 description
: r
##"Checks for calls to `push` immediately after creating a new `Vec`."##,
6972 label
: "clippy::vec_resize_to_zero",
6973 description
: r
##"Finds occurrences of `Vec::resize(0, an_int)`"##,
6976 label
: "clippy::verbose_bit_mask",
6977 description
: r
##"Checks for bit masks that can be replaced by a call
6978 to `trailing_zeros`"##,
6981 label
: "clippy::verbose_file_reads",
6982 description
: r
##"Checks for use of File::read_to_end and File::read_to_string."##,
6985 label
: "clippy::vtable_address_comparisons",
6986 description
: r
##"Checks for comparisons with an address of a trait vtable."##,
6989 label
: "clippy::while_immutable_condition",
6990 description
: r
##"Checks whether variables used within while loop condition
6991 can be (and are) mutated in the body."##,
6994 label
: "clippy::while_let_loop",
6995 description
: r
##"Detects `loop + match` combinations that are easier
6996 written as a `while let` loop."##,
6999 label
: "clippy::while_let_on_iterator",
7000 description
: r
##"Checks for `while let` expressions on iterators."##,
7003 label
: "clippy::wildcard_dependencies",
7004 description
: r
##"Checks for wildcard dependencies in the `Cargo.toml`."##,
7007 label
: "clippy::wildcard_enum_match_arm",
7008 description
: r
##"Checks for wildcard enum matches using `_`."##,
7011 label
: "clippy::wildcard_imports",
7012 description
: r
##"Checks for wildcard imports `use _::*`."##,
7015 label
: "clippy::wildcard_in_or_patterns",
7016 description
: r
##"Checks for wildcard pattern used with others patterns in same match arm."##,
7019 label
: "clippy::write_literal",
7020 description
: r
##"This lint warns about the use of literals as `write!`/`writeln!` args."##,
7023 label
: "clippy::write_with_newline",
7024 description
: r
##"This lint warns when you use `write!()` with a format
7026 ends in a newline."##,
7029 label
: "clippy::writeln_empty_string",
7030 description
: r
##"This lint warns when you use `writeln!(buf, )` to
7031 print a newline."##,
7034 label
: "clippy::wrong_pub_self_convention",
7035 description
: r
##"Nothing. This lint has been deprecated."##,
7038 label
: "clippy::wrong_self_convention",
7039 description
: r
##"Checks for methods with certain name prefixes and which
7040 doesn't match how self is taken. The actual rules are:
7042 |Prefix |Postfix |`self` taken | `self` type |
7043 |-------|------------|-----------------------|--------------|
7044 |`as_` | none |`&self` or `&mut self` | any |
7045 |`from_`| none | none | any |
7046 |`into_`| none |`self` | any |
7047 |`is_` | none |`&self` or none | any |
7048 |`to_` | `_mut` |`&mut self` | any |
7049 |`to_` | not `_mut` |`self` | `Copy` |
7050 |`to_` | not `_mut` |`&self` | not `Copy` |
7052 Note: Clippy doesn't trigger methods with `to_` prefix in:
7053 - Traits definition.
7054 Clippy can not tell if a type that implements a trait is `Copy` or not.
7055 - Traits implementation, when `&self` is taken.
7056 The method signature is controlled by the trait and often `&self` is required for all types that implement the trait
7057 (see e.g. the `std::string::ToString` trait).
7059 Clippy allows `Pin<&Self>` and `Pin<&mut Self>` if `&self` and `&mut self` is required.
7061 Please find more info here:
7062 https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv"##,
7065 label
: "clippy::wrong_transmute",
7066 description
: r
##"Checks for transmutes that can't ever be correct on any
7069 Lint { label: "clippy::zero_divided_by_zero", description: r##"Checks for `0.0 / 0.0`."## }
,
7071 label
: "clippy::zero_prefixed_literal",
7072 description
: r
##"Warns if an integral constant literal starts with `0`."##,
7075 label
: "clippy::zero_ptr",
7076 description
: r
##"Catch casts from `0` to some pointer type"##,
7079 label
: "clippy::zero_sized_map_values",
7080 description
: r
##"Checks for maps with zero-sized value types anywhere in the code."##,
7083 label
: "clippy::zst_offset",
7084 description
: r
##"Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to
7085 zero-sized types"##,
7088 pub const CLIPPY_LINT_GROUPS
: &[LintGroup
] = &[
7091 label
: "clippy::cargo",
7092 description
: r
##"lint group for: clippy::cargo_common_metadata, clippy::multiple_crate_versions, clippy::negative_feature_names, clippy::redundant_feature_names, clippy::wildcard_dependencies"##,
7095 "clippy::cargo_common_metadata",
7096 "clippy::multiple_crate_versions",
7097 "clippy::negative_feature_names",
7098 "clippy::redundant_feature_names",
7099 "clippy::wildcard_dependencies",
7104 label
: "clippy::complexity",
7105 description
: r
##"lint group for: clippy::bind_instead_of_map, clippy::bool_comparison, clippy::borrowed_box, clippy::char_lit_as_u8, clippy::clone_on_copy, clippy::crosspointer_transmute, clippy::deprecated_cfg_attr, clippy::deref_addrof, clippy::derivable_impls, clippy::diverging_sub_expression, clippy::double_comparisons, clippy::double_parens, clippy::duration_subsec, clippy::explicit_counter_loop, clippy::explicit_write, clippy::extra_unused_lifetimes, clippy::filter_map_identity, clippy::filter_next, clippy::flat_map_identity, clippy::get_last_with_len, clippy::identity_op, clippy::inspect_for_each, clippy::int_plus_one, clippy::iter_count, clippy::manual_filter_map, clippy::manual_find_map, clippy::manual_flatten, clippy::manual_split_once, clippy::manual_strip, clippy::manual_swap, clippy::manual_unwrap_or, clippy::map_flatten, clippy::map_identity, clippy::match_as_ref, clippy::match_single_binding, clippy::needless_arbitrary_self_type, clippy::needless_bool, clippy::needless_borrowed_reference, clippy::needless_lifetimes, clippy::needless_option_as_deref, clippy::needless_question_mark, clippy::needless_splitn, clippy::needless_update, clippy::neg_cmp_op_on_partial_ord, clippy::no_effect, clippy::nonminimal_bool, clippy::option_as_ref_deref, clippy::option_filter_map, clippy::option_map_unit_fn, clippy::overflow_check_conditional, clippy::partialeq_ne_impl, clippy::precedence, clippy::ptr_offset_with_cast, clippy::range_zip_with_len, clippy::redundant_closure_call, clippy::redundant_slicing, clippy::ref_in_deref, clippy::repeat_once, clippy::result_map_unit_fn, clippy::search_is_some, clippy::short_circuit_statement, clippy::single_element_loop, clippy::skip_while_next, clippy::string_from_utf8_as_bytes, clippy::strlen_on_c_strings, clippy::temporary_assignment, clippy::too_many_arguments, clippy::transmute_bytes_to_str, clippy::transmute_float_to_int, clippy::transmute_int_to_bool, clippy::transmute_int_to_char, clippy::transmute_int_to_float, clippy::transmute_num_to_bytes, clippy::transmute_ptr_to_ref, clippy::transmutes_expressible_as_ptr_casts, clippy::type_complexity, clippy::unit_arg, clippy::unnecessary_cast, clippy::unnecessary_filter_map, clippy::unnecessary_operation, clippy::unnecessary_sort_by, clippy::unnecessary_unwrap, clippy::unneeded_wildcard_pattern, clippy::useless_asref, clippy::useless_conversion, clippy::useless_format, clippy::vec_box, clippy::while_let_loop, clippy::wildcard_in_or_patterns, clippy::zero_divided_by_zero, clippy::zero_prefixed_literal"##,
7108 "clippy::bind_instead_of_map",
7109 "clippy::bool_comparison",
7110 "clippy::borrowed_box",
7111 "clippy::char_lit_as_u8",
7112 "clippy::clone_on_copy",
7113 "clippy::crosspointer_transmute",
7114 "clippy::deprecated_cfg_attr",
7115 "clippy::deref_addrof",
7116 "clippy::derivable_impls",
7117 "clippy::diverging_sub_expression",
7118 "clippy::double_comparisons",
7119 "clippy::double_parens",
7120 "clippy::duration_subsec",
7121 "clippy::explicit_counter_loop",
7122 "clippy::explicit_write",
7123 "clippy::extra_unused_lifetimes",
7124 "clippy::filter_map_identity",
7125 "clippy::filter_next",
7126 "clippy::flat_map_identity",
7127 "clippy::get_last_with_len",
7128 "clippy::identity_op",
7129 "clippy::inspect_for_each",
7130 "clippy::int_plus_one",
7131 "clippy::iter_count",
7132 "clippy::manual_filter_map",
7133 "clippy::manual_find_map",
7134 "clippy::manual_flatten",
7135 "clippy::manual_split_once",
7136 "clippy::manual_strip",
7137 "clippy::manual_swap",
7138 "clippy::manual_unwrap_or",
7139 "clippy::map_flatten",
7140 "clippy::map_identity",
7141 "clippy::match_as_ref",
7142 "clippy::match_single_binding",
7143 "clippy::needless_arbitrary_self_type",
7144 "clippy::needless_bool",
7145 "clippy::needless_borrowed_reference",
7146 "clippy::needless_lifetimes",
7147 "clippy::needless_option_as_deref",
7148 "clippy::needless_question_mark",
7149 "clippy::needless_splitn",
7150 "clippy::needless_update",
7151 "clippy::neg_cmp_op_on_partial_ord",
7152 "clippy::no_effect",
7153 "clippy::nonminimal_bool",
7154 "clippy::option_as_ref_deref",
7155 "clippy::option_filter_map",
7156 "clippy::option_map_unit_fn",
7157 "clippy::overflow_check_conditional",
7158 "clippy::partialeq_ne_impl",
7159 "clippy::precedence",
7160 "clippy::ptr_offset_with_cast",
7161 "clippy::range_zip_with_len",
7162 "clippy::redundant_closure_call",
7163 "clippy::redundant_slicing",
7164 "clippy::ref_in_deref",
7165 "clippy::repeat_once",
7166 "clippy::result_map_unit_fn",
7167 "clippy::search_is_some",
7168 "clippy::short_circuit_statement",
7169 "clippy::single_element_loop",
7170 "clippy::skip_while_next",
7171 "clippy::string_from_utf8_as_bytes",
7172 "clippy::strlen_on_c_strings",
7173 "clippy::temporary_assignment",
7174 "clippy::too_many_arguments",
7175 "clippy::transmute_bytes_to_str",
7176 "clippy::transmute_float_to_int",
7177 "clippy::transmute_int_to_bool",
7178 "clippy::transmute_int_to_char",
7179 "clippy::transmute_int_to_float",
7180 "clippy::transmute_num_to_bytes",
7181 "clippy::transmute_ptr_to_ref",
7182 "clippy::transmutes_expressible_as_ptr_casts",
7183 "clippy::type_complexity",
7185 "clippy::unnecessary_cast",
7186 "clippy::unnecessary_filter_map",
7187 "clippy::unnecessary_operation",
7188 "clippy::unnecessary_sort_by",
7189 "clippy::unnecessary_unwrap",
7190 "clippy::unneeded_wildcard_pattern",
7191 "clippy::useless_asref",
7192 "clippy::useless_conversion",
7193 "clippy::useless_format",
7195 "clippy::while_let_loop",
7196 "clippy::wildcard_in_or_patterns",
7197 "clippy::zero_divided_by_zero",
7198 "clippy::zero_prefixed_literal",
7203 label
: "clippy::correctness",
7204 description
: r
##"lint group for: clippy::absurd_extreme_comparisons, clippy::almost_swapped, clippy::approx_constant, clippy::async_yields_async, clippy::bad_bit_mask, clippy::cast_ref_to_mut, clippy::clone_double_ref, clippy::cmp_nan, clippy::deprecated_semver, clippy::derive_hash_xor_eq, clippy::derive_ord_xor_partial_ord, clippy::drop_copy, clippy::drop_ref, clippy::enum_clike_unportable_variant, clippy::eq_op, clippy::erasing_op, clippy::fn_address_comparisons, clippy::forget_copy, clippy::forget_ref, clippy::if_let_mutex, clippy::if_same_then_else, clippy::ifs_same_cond, clippy::ineffective_bit_mask, clippy::infinite_iter, clippy::inherent_to_string_shadow_display, clippy::inline_fn_without_body, clippy::invalid_null_ptr_usage, clippy::invalid_regex, clippy::invisible_characters, clippy::iter_next_loop, clippy::iterator_step_by_zero, clippy::let_underscore_lock, clippy::logic_bug, clippy::match_str_case_mismatch, clippy::mem_replace_with_uninit, clippy::min_max, clippy::mismatched_target_os, clippy::mistyped_literal_suffixes, clippy::modulo_one, clippy::mut_from_ref, clippy::never_loop, clippy::non_octal_unix_permissions, clippy::nonsensical_open_options, clippy::not_unsafe_ptr_arg_deref, clippy::option_env_unwrap, clippy::out_of_bounds_indexing, clippy::panicking_unwrap, clippy::possible_missing_comma, clippy::reversed_empty_ranges, clippy::self_assignment, clippy::serde_api_misuse, clippy::size_of_in_element_count, clippy::suspicious_splitn, clippy::to_string_in_display, clippy::transmuting_null, clippy::undropped_manually_drops, clippy::uninit_assumed_init, clippy::uninit_vec, clippy::unit_cmp, clippy::unit_hash, clippy::unit_return_expecting_ord, clippy::unsound_collection_transmute, clippy::unused_io_amount, clippy::useless_attribute, clippy::vec_resize_to_zero, clippy::vtable_address_comparisons, clippy::while_immutable_condition, clippy::wrong_transmute, clippy::zst_offset"##,
7207 "clippy::absurd_extreme_comparisons",
7208 "clippy::almost_swapped",
7209 "clippy::approx_constant",
7210 "clippy::async_yields_async",
7211 "clippy::bad_bit_mask",
7212 "clippy::cast_ref_to_mut",
7213 "clippy::clone_double_ref",
7215 "clippy::deprecated_semver",
7216 "clippy::derive_hash_xor_eq",
7217 "clippy::derive_ord_xor_partial_ord",
7218 "clippy::drop_copy",
7220 "clippy::enum_clike_unportable_variant",
7222 "clippy::erasing_op",
7223 "clippy::fn_address_comparisons",
7224 "clippy::forget_copy",
7225 "clippy::forget_ref",
7226 "clippy::if_let_mutex",
7227 "clippy::if_same_then_else",
7228 "clippy::ifs_same_cond",
7229 "clippy::ineffective_bit_mask",
7230 "clippy::infinite_iter",
7231 "clippy::inherent_to_string_shadow_display",
7232 "clippy::inline_fn_without_body",
7233 "clippy::invalid_null_ptr_usage",
7234 "clippy::invalid_regex",
7235 "clippy::invisible_characters",
7236 "clippy::iter_next_loop",
7237 "clippy::iterator_step_by_zero",
7238 "clippy::let_underscore_lock",
7239 "clippy::logic_bug",
7240 "clippy::match_str_case_mismatch",
7241 "clippy::mem_replace_with_uninit",
7243 "clippy::mismatched_target_os",
7244 "clippy::mistyped_literal_suffixes",
7245 "clippy::modulo_one",
7246 "clippy::mut_from_ref",
7247 "clippy::never_loop",
7248 "clippy::non_octal_unix_permissions",
7249 "clippy::nonsensical_open_options",
7250 "clippy::not_unsafe_ptr_arg_deref",
7251 "clippy::option_env_unwrap",
7252 "clippy::out_of_bounds_indexing",
7253 "clippy::panicking_unwrap",
7254 "clippy::possible_missing_comma",
7255 "clippy::reversed_empty_ranges",
7256 "clippy::self_assignment",
7257 "clippy::serde_api_misuse",
7258 "clippy::size_of_in_element_count",
7259 "clippy::suspicious_splitn",
7260 "clippy::to_string_in_display",
7261 "clippy::transmuting_null",
7262 "clippy::undropped_manually_drops",
7263 "clippy::uninit_assumed_init",
7264 "clippy::uninit_vec",
7266 "clippy::unit_hash",
7267 "clippy::unit_return_expecting_ord",
7268 "clippy::unsound_collection_transmute",
7269 "clippy::unused_io_amount",
7270 "clippy::useless_attribute",
7271 "clippy::vec_resize_to_zero",
7272 "clippy::vtable_address_comparisons",
7273 "clippy::while_immutable_condition",
7274 "clippy::wrong_transmute",
7275 "clippy::zst_offset",
7280 label
: "clippy::deprecated",
7281 description
: r
##"lint group for: clippy::assign_ops, clippy::extend_from_slice, clippy::filter_map, clippy::find_map, clippy::if_let_redundant_pattern_matching, clippy::misaligned_transmute, clippy::pub_enum_variant_names, clippy::range_step_by_zero, clippy::regex_macro, clippy::replace_consts, clippy::should_assert_eq, clippy::unsafe_vector_initialization, clippy::unstable_as_mut_slice, clippy::unstable_as_slice, clippy::unused_collect, clippy::wrong_pub_self_convention"##,
7284 "clippy::assign_ops",
7285 "clippy::extend_from_slice",
7286 "clippy::filter_map",
7288 "clippy::if_let_redundant_pattern_matching",
7289 "clippy::misaligned_transmute",
7290 "clippy::pub_enum_variant_names",
7291 "clippy::range_step_by_zero",
7292 "clippy::regex_macro",
7293 "clippy::replace_consts",
7294 "clippy::should_assert_eq",
7295 "clippy::unsafe_vector_initialization",
7296 "clippy::unstable_as_mut_slice",
7297 "clippy::unstable_as_slice",
7298 "clippy::unused_collect",
7299 "clippy::wrong_pub_self_convention",
7304 label
: "clippy::nursery",
7305 description
: r
##"lint group for: clippy::branches_sharing_code, clippy::cognitive_complexity, clippy::debug_assert_with_mut_call, clippy::disallowed_methods, clippy::disallowed_types, clippy::empty_line_after_outer_attr, clippy::equatable_if_let, clippy::fallible_impl_from, clippy::future_not_send, clippy::imprecise_flops, clippy::index_refutable_slice, clippy::missing_const_for_fn, clippy::mutex_integer, clippy::non_send_fields_in_send_ty, clippy::nonstandard_macro_braces, clippy::option_if_let_else, clippy::path_buf_push_overwrite, clippy::redundant_pub_crate, clippy::string_lit_as_bytes, clippy::suboptimal_flops, clippy::suspicious_operation_groupings, clippy::trailing_empty_array, clippy::trivial_regex, clippy::use_self, clippy::useless_let_if_seq, clippy::useless_transmute"##,
7308 "clippy::branches_sharing_code",
7309 "clippy::cognitive_complexity",
7310 "clippy::debug_assert_with_mut_call",
7311 "clippy::disallowed_methods",
7312 "clippy::disallowed_types",
7313 "clippy::empty_line_after_outer_attr",
7314 "clippy::equatable_if_let",
7315 "clippy::fallible_impl_from",
7316 "clippy::future_not_send",
7317 "clippy::imprecise_flops",
7318 "clippy::index_refutable_slice",
7319 "clippy::missing_const_for_fn",
7320 "clippy::mutex_integer",
7321 "clippy::non_send_fields_in_send_ty",
7322 "clippy::nonstandard_macro_braces",
7323 "clippy::option_if_let_else",
7324 "clippy::path_buf_push_overwrite",
7325 "clippy::redundant_pub_crate",
7326 "clippy::string_lit_as_bytes",
7327 "clippy::suboptimal_flops",
7328 "clippy::suspicious_operation_groupings",
7329 "clippy::trailing_empty_array",
7330 "clippy::trivial_regex",
7332 "clippy::useless_let_if_seq",
7333 "clippy::useless_transmute",
7338 label
: "clippy::pedantic",
7339 description
: r
##"lint group for: clippy::await_holding_lock, clippy::await_holding_refcell_ref, clippy::case_sensitive_file_extension_comparisons, clippy::cast_lossless, clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_precision_loss, clippy::cast_ptr_alignment, clippy::cast_sign_loss, clippy::checked_conversions, clippy::cloned_instead_of_copied, clippy::copy_iterator, clippy::default_trait_access, clippy::doc_markdown, clippy::empty_enum, clippy::enum_glob_use, clippy::expl_impl_clone_on_copy, clippy::explicit_deref_methods, clippy::explicit_into_iter_loop, clippy::explicit_iter_loop, clippy::filter_map_next, clippy::flat_map_option, clippy::float_cmp, clippy::fn_params_excessive_bools, clippy::from_iter_instead_of_collect, clippy::if_not_else, clippy::implicit_clone, clippy::implicit_hasher, clippy::implicit_saturating_sub, clippy::inconsistent_struct_constructor, clippy::inefficient_to_string, clippy::inline_always, clippy::invalid_upcast_comparisons, clippy::items_after_statements, clippy::iter_not_returning_iterator, clippy::large_digit_groups, clippy::large_stack_arrays, clippy::large_types_passed_by_value, clippy::let_underscore_drop, clippy::let_unit_value, clippy::linkedlist, clippy::macro_use_imports, clippy::manual_assert, clippy::manual_ok_or, clippy::many_single_char_names, clippy::map_unwrap_or, clippy::match_bool, clippy::match_on_vec_items, clippy::match_same_arms, clippy::match_wild_err_arm, clippy::match_wildcard_for_single_variants, clippy::maybe_infinite_iter, clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::module_name_repetitions, clippy::must_use_candidate, clippy::mut_mut, clippy::naive_bytecount, clippy::needless_bitwise_bool, clippy::needless_continue, clippy::needless_for_each, clippy::needless_pass_by_value, clippy::no_effect_underscore_binding, clippy::option_option, clippy::ptr_as_ptr, clippy::range_minus_one, clippy::range_plus_one, clippy::redundant_closure_for_method_calls, clippy::redundant_else, clippy::ref_binding_to_reference, clippy::ref_option_ref, clippy::same_functions_in_if_condition, clippy::semicolon_if_nothing_returned, clippy::similar_names, clippy::single_match_else, clippy::string_add_assign, clippy::struct_excessive_bools, clippy::too_many_lines, clippy::trait_duplication_in_bounds, clippy::transmute_ptr_to_ptr, clippy::trivially_copy_pass_by_ref, clippy::type_repetition_in_bounds, clippy::unicode_not_nfc, clippy::unnecessary_wraps, clippy::unnested_or_patterns, clippy::unreadable_literal, clippy::unsafe_derive_deserialize, clippy::unused_async, clippy::unused_self, clippy::used_underscore_binding, clippy::verbose_bit_mask, clippy::wildcard_imports, clippy::zero_sized_map_values"##,
7342 "clippy::await_holding_lock",
7343 "clippy::await_holding_refcell_ref",
7344 "clippy::case_sensitive_file_extension_comparisons",
7345 "clippy::cast_lossless",
7346 "clippy::cast_possible_truncation",
7347 "clippy::cast_possible_wrap",
7348 "clippy::cast_precision_loss",
7349 "clippy::cast_ptr_alignment",
7350 "clippy::cast_sign_loss",
7351 "clippy::checked_conversions",
7352 "clippy::cloned_instead_of_copied",
7353 "clippy::copy_iterator",
7354 "clippy::default_trait_access",
7355 "clippy::doc_markdown",
7356 "clippy::empty_enum",
7357 "clippy::enum_glob_use",
7358 "clippy::expl_impl_clone_on_copy",
7359 "clippy::explicit_deref_methods",
7360 "clippy::explicit_into_iter_loop",
7361 "clippy::explicit_iter_loop",
7362 "clippy::filter_map_next",
7363 "clippy::flat_map_option",
7364 "clippy::float_cmp",
7365 "clippy::fn_params_excessive_bools",
7366 "clippy::from_iter_instead_of_collect",
7367 "clippy::if_not_else",
7368 "clippy::implicit_clone",
7369 "clippy::implicit_hasher",
7370 "clippy::implicit_saturating_sub",
7371 "clippy::inconsistent_struct_constructor",
7372 "clippy::inefficient_to_string",
7373 "clippy::inline_always",
7374 "clippy::invalid_upcast_comparisons",
7375 "clippy::items_after_statements",
7376 "clippy::iter_not_returning_iterator",
7377 "clippy::large_digit_groups",
7378 "clippy::large_stack_arrays",
7379 "clippy::large_types_passed_by_value",
7380 "clippy::let_underscore_drop",
7381 "clippy::let_unit_value",
7382 "clippy::linkedlist",
7383 "clippy::macro_use_imports",
7384 "clippy::manual_assert",
7385 "clippy::manual_ok_or",
7386 "clippy::many_single_char_names",
7387 "clippy::map_unwrap_or",
7388 "clippy::match_bool",
7389 "clippy::match_on_vec_items",
7390 "clippy::match_same_arms",
7391 "clippy::match_wild_err_arm",
7392 "clippy::match_wildcard_for_single_variants",
7393 "clippy::maybe_infinite_iter",
7394 "clippy::missing_errors_doc",
7395 "clippy::missing_panics_doc",
7396 "clippy::module_name_repetitions",
7397 "clippy::must_use_candidate",
7399 "clippy::naive_bytecount",
7400 "clippy::needless_bitwise_bool",
7401 "clippy::needless_continue",
7402 "clippy::needless_for_each",
7403 "clippy::needless_pass_by_value",
7404 "clippy::no_effect_underscore_binding",
7405 "clippy::option_option",
7406 "clippy::ptr_as_ptr",
7407 "clippy::range_minus_one",
7408 "clippy::range_plus_one",
7409 "clippy::redundant_closure_for_method_calls",
7410 "clippy::redundant_else",
7411 "clippy::ref_binding_to_reference",
7412 "clippy::ref_option_ref",
7413 "clippy::same_functions_in_if_condition",
7414 "clippy::semicolon_if_nothing_returned",
7415 "clippy::similar_names",
7416 "clippy::single_match_else",
7417 "clippy::string_add_assign",
7418 "clippy::struct_excessive_bools",
7419 "clippy::too_many_lines",
7420 "clippy::trait_duplication_in_bounds",
7421 "clippy::transmute_ptr_to_ptr",
7422 "clippy::trivially_copy_pass_by_ref",
7423 "clippy::type_repetition_in_bounds",
7424 "clippy::unicode_not_nfc",
7425 "clippy::unnecessary_wraps",
7426 "clippy::unnested_or_patterns",
7427 "clippy::unreadable_literal",
7428 "clippy::unsafe_derive_deserialize",
7429 "clippy::unused_async",
7430 "clippy::unused_self",
7431 "clippy::used_underscore_binding",
7432 "clippy::verbose_bit_mask",
7433 "clippy::wildcard_imports",
7434 "clippy::zero_sized_map_values",
7439 label
: "clippy::perf",
7440 description
: r
##"lint group for: clippy::box_collection, clippy::boxed_local, clippy::cmp_owned, clippy::expect_fun_call, clippy::extend_with_drain, clippy::format_in_format_args, clippy::iter_nth, clippy::large_const_arrays, clippy::large_enum_variant, clippy::manual_memcpy, clippy::manual_str_repeat, clippy::map_entry, clippy::mutex_atomic, clippy::needless_collect, clippy::or_fun_call, clippy::redundant_allocation, clippy::redundant_clone, clippy::single_char_pattern, clippy::slow_vector_initialization, clippy::stable_sort_primitive, clippy::to_string_in_format_args, clippy::unnecessary_to_owned, clippy::useless_vec, clippy::vec_init_then_push"##,
7443 "clippy::box_collection",
7444 "clippy::boxed_local",
7445 "clippy::cmp_owned",
7446 "clippy::expect_fun_call",
7447 "clippy::extend_with_drain",
7448 "clippy::format_in_format_args",
7450 "clippy::large_const_arrays",
7451 "clippy::large_enum_variant",
7452 "clippy::manual_memcpy",
7453 "clippy::manual_str_repeat",
7454 "clippy::map_entry",
7455 "clippy::mutex_atomic",
7456 "clippy::needless_collect",
7457 "clippy::or_fun_call",
7458 "clippy::redundant_allocation",
7459 "clippy::redundant_clone",
7460 "clippy::single_char_pattern",
7461 "clippy::slow_vector_initialization",
7462 "clippy::stable_sort_primitive",
7463 "clippy::to_string_in_format_args",
7464 "clippy::unnecessary_to_owned",
7465 "clippy::useless_vec",
7466 "clippy::vec_init_then_push",
7471 label
: "clippy::restriction",
7472 description
: r
##"lint group for: clippy::as_conversions, clippy::clone_on_ref_ptr, clippy::create_dir, clippy::dbg_macro, clippy::decimal_literal_representation, clippy::default_numeric_fallback, clippy::disallowed_script_idents, clippy::else_if_without_else, clippy::exhaustive_enums, clippy::exhaustive_structs, clippy::exit, clippy::expect_used, clippy::filetype_is_file, clippy::float_arithmetic, clippy::float_cmp_const, clippy::fn_to_numeric_cast_any, clippy::get_unwrap, clippy::if_then_some_else_none, clippy::implicit_return, clippy::indexing_slicing, clippy::inline_asm_x86_att_syntax, clippy::inline_asm_x86_intel_syntax, clippy::integer_arithmetic, clippy::integer_division, clippy::let_underscore_must_use, clippy::lossy_float_literal, clippy::map_err_ignore, clippy::mem_forget, clippy::missing_docs_in_private_items, clippy::missing_enforced_import_renames, clippy::missing_inline_in_public_items, clippy::mod_module_files, clippy::modulo_arithmetic, clippy::multiple_inherent_impl, clippy::non_ascii_literal, clippy::panic, clippy::panic_in_result_fn, clippy::pattern_type_mismatch, clippy::print_stderr, clippy::print_stdout, clippy::rc_buffer, clippy::rc_mutex, clippy::rest_pat_in_fully_bound_structs, clippy::same_name_method, clippy::self_named_module_files, clippy::separated_literal_suffix, clippy::shadow_reuse, clippy::shadow_same, clippy::shadow_unrelated, clippy::str_to_string, clippy::string_add, clippy::string_slice, clippy::string_to_string, clippy::todo, clippy::undocumented_unsafe_blocks, clippy::unimplemented, clippy::unnecessary_self_imports, clippy::unneeded_field_pattern, clippy::unreachable, clippy::unseparated_literal_suffix, clippy::unwrap_in_result, clippy::unwrap_used, clippy::use_debug, clippy::verbose_file_reads, clippy::wildcard_enum_match_arm"##,
7475 "clippy::as_conversions",
7476 "clippy::clone_on_ref_ptr",
7477 "clippy::create_dir",
7478 "clippy::dbg_macro",
7479 "clippy::decimal_literal_representation",
7480 "clippy::default_numeric_fallback",
7481 "clippy::disallowed_script_idents",
7482 "clippy::else_if_without_else",
7483 "clippy::exhaustive_enums",
7484 "clippy::exhaustive_structs",
7486 "clippy::expect_used",
7487 "clippy::filetype_is_file",
7488 "clippy::float_arithmetic",
7489 "clippy::float_cmp_const",
7490 "clippy::fn_to_numeric_cast_any",
7491 "clippy::get_unwrap",
7492 "clippy::if_then_some_else_none",
7493 "clippy::implicit_return",
7494 "clippy::indexing_slicing",
7495 "clippy::inline_asm_x86_att_syntax",
7496 "clippy::inline_asm_x86_intel_syntax",
7497 "clippy::integer_arithmetic",
7498 "clippy::integer_division",
7499 "clippy::let_underscore_must_use",
7500 "clippy::lossy_float_literal",
7501 "clippy::map_err_ignore",
7502 "clippy::mem_forget",
7503 "clippy::missing_docs_in_private_items",
7504 "clippy::missing_enforced_import_renames",
7505 "clippy::missing_inline_in_public_items",
7506 "clippy::mod_module_files",
7507 "clippy::modulo_arithmetic",
7508 "clippy::multiple_inherent_impl",
7509 "clippy::non_ascii_literal",
7511 "clippy::panic_in_result_fn",
7512 "clippy::pattern_type_mismatch",
7513 "clippy::print_stderr",
7514 "clippy::print_stdout",
7515 "clippy::rc_buffer",
7517 "clippy::rest_pat_in_fully_bound_structs",
7518 "clippy::same_name_method",
7519 "clippy::self_named_module_files",
7520 "clippy::separated_literal_suffix",
7521 "clippy::shadow_reuse",
7522 "clippy::shadow_same",
7523 "clippy::shadow_unrelated",
7524 "clippy::str_to_string",
7525 "clippy::string_add",
7526 "clippy::string_slice",
7527 "clippy::string_to_string",
7529 "clippy::undocumented_unsafe_blocks",
7530 "clippy::unimplemented",
7531 "clippy::unnecessary_self_imports",
7532 "clippy::unneeded_field_pattern",
7533 "clippy::unreachable",
7534 "clippy::unseparated_literal_suffix",
7535 "clippy::unwrap_in_result",
7536 "clippy::unwrap_used",
7537 "clippy::use_debug",
7538 "clippy::verbose_file_reads",
7539 "clippy::wildcard_enum_match_arm",
7544 label
: "clippy::style",
7545 description
: r
##"lint group for: clippy::assertions_on_constants, clippy::assign_op_pattern, clippy::blacklisted_name, clippy::blocks_in_if_conditions, clippy::bool_assert_comparison, clippy::borrow_interior_mutable_const, clippy::builtin_type_shadow, clippy::bytes_nth, clippy::chars_last_cmp, clippy::chars_next_cmp, clippy::cmp_null, clippy::collapsible_else_if, clippy::collapsible_if, clippy::collapsible_match, clippy::comparison_chain, clippy::comparison_to_empty, clippy::declare_interior_mutable_const, clippy::double_must_use, clippy::double_neg, clippy::duplicate_underscore_argument, clippy::enum_variant_names, clippy::excessive_precision, clippy::field_reassign_with_default, clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation, clippy::for_kv_map, clippy::from_over_into, clippy::from_str_radix_10, clippy::inconsistent_digit_grouping, clippy::infallible_destructuring_match, clippy::inherent_to_string, clippy::into_iter_on_ref, clippy::iter_cloned_collect, clippy::iter_next_slice, clippy::iter_nth_zero, clippy::iter_skip_next, clippy::just_underscores_and_digits, clippy::len_without_is_empty, clippy::len_zero, clippy::let_and_return, clippy::main_recursion, clippy::manual_async_fn, clippy::manual_map, clippy::manual_non_exhaustive, clippy::manual_range_contains, clippy::manual_saturating_arithmetic, clippy::map_clone, clippy::map_collect_result_unit, clippy::match_like_matches_macro, clippy::match_overlapping_arm, clippy::match_ref_pats, clippy::match_result_ok, clippy::mem_replace_option_with_none, clippy::mem_replace_with_default, clippy::missing_safety_doc, clippy::mixed_case_hex_literals, clippy::module_inception, clippy::must_use_unit, clippy::mut_mutex_lock, clippy::needless_borrow, clippy::needless_doctest_main, clippy::needless_late_init, clippy::needless_range_loop, clippy::needless_return, clippy::neg_multiply, clippy::new_ret_no_self, clippy::new_without_default, clippy::ok_expect, clippy::op_ref, clippy::option_map_or_none, clippy::print_literal, clippy::print_with_newline, clippy::println_empty_string, clippy::ptr_arg, clippy::ptr_eq, clippy::question_mark, clippy::redundant_closure, clippy::redundant_field_names, clippy::redundant_pattern, clippy::redundant_pattern_matching, clippy::redundant_static_lifetimes, clippy::result_map_or_into_option, clippy::result_unit_err, clippy::same_item_push, clippy::self_named_constructors, clippy::should_implement_trait, clippy::single_char_add_str, clippy::single_component_path_imports, clippy::single_match, clippy::string_extend_chars, clippy::tabs_in_doc_comments, clippy::to_digit_is_some, clippy::toplevel_ref_arg, clippy::try_err, clippy::unnecessary_fold, clippy::unnecessary_lazy_evaluations, clippy::unnecessary_mut_passed, clippy::unsafe_removed_from_name, clippy::unused_unit, clippy::unusual_byte_groupings, clippy::unwrap_or_else_default, clippy::upper_case_acronyms, clippy::while_let_on_iterator, clippy::write_literal, clippy::write_with_newline, clippy::writeln_empty_string, clippy::wrong_self_convention, clippy::zero_ptr"##,
7548 "clippy::assertions_on_constants",
7549 "clippy::assign_op_pattern",
7550 "clippy::blacklisted_name",
7551 "clippy::blocks_in_if_conditions",
7552 "clippy::bool_assert_comparison",
7553 "clippy::borrow_interior_mutable_const",
7554 "clippy::builtin_type_shadow",
7555 "clippy::bytes_nth",
7556 "clippy::chars_last_cmp",
7557 "clippy::chars_next_cmp",
7559 "clippy::collapsible_else_if",
7560 "clippy::collapsible_if",
7561 "clippy::collapsible_match",
7562 "clippy::comparison_chain",
7563 "clippy::comparison_to_empty",
7564 "clippy::declare_interior_mutable_const",
7565 "clippy::double_must_use",
7566 "clippy::double_neg",
7567 "clippy::duplicate_underscore_argument",
7568 "clippy::enum_variant_names",
7569 "clippy::excessive_precision",
7570 "clippy::field_reassign_with_default",
7571 "clippy::fn_to_numeric_cast",
7572 "clippy::fn_to_numeric_cast_with_truncation",
7573 "clippy::for_kv_map",
7574 "clippy::from_over_into",
7575 "clippy::from_str_radix_10",
7576 "clippy::inconsistent_digit_grouping",
7577 "clippy::infallible_destructuring_match",
7578 "clippy::inherent_to_string",
7579 "clippy::into_iter_on_ref",
7580 "clippy::iter_cloned_collect",
7581 "clippy::iter_next_slice",
7582 "clippy::iter_nth_zero",
7583 "clippy::iter_skip_next",
7584 "clippy::just_underscores_and_digits",
7585 "clippy::len_without_is_empty",
7587 "clippy::let_and_return",
7588 "clippy::main_recursion",
7589 "clippy::manual_async_fn",
7590 "clippy::manual_map",
7591 "clippy::manual_non_exhaustive",
7592 "clippy::manual_range_contains",
7593 "clippy::manual_saturating_arithmetic",
7594 "clippy::map_clone",
7595 "clippy::map_collect_result_unit",
7596 "clippy::match_like_matches_macro",
7597 "clippy::match_overlapping_arm",
7598 "clippy::match_ref_pats",
7599 "clippy::match_result_ok",
7600 "clippy::mem_replace_option_with_none",
7601 "clippy::mem_replace_with_default",
7602 "clippy::missing_safety_doc",
7603 "clippy::mixed_case_hex_literals",
7604 "clippy::module_inception",
7605 "clippy::must_use_unit",
7606 "clippy::mut_mutex_lock",
7607 "clippy::needless_borrow",
7608 "clippy::needless_doctest_main",
7609 "clippy::needless_late_init",
7610 "clippy::needless_range_loop",
7611 "clippy::needless_return",
7612 "clippy::neg_multiply",
7613 "clippy::new_ret_no_self",
7614 "clippy::new_without_default",
7615 "clippy::ok_expect",
7617 "clippy::option_map_or_none",
7618 "clippy::print_literal",
7619 "clippy::print_with_newline",
7620 "clippy::println_empty_string",
7623 "clippy::question_mark",
7624 "clippy::redundant_closure",
7625 "clippy::redundant_field_names",
7626 "clippy::redundant_pattern",
7627 "clippy::redundant_pattern_matching",
7628 "clippy::redundant_static_lifetimes",
7629 "clippy::result_map_or_into_option",
7630 "clippy::result_unit_err",
7631 "clippy::same_item_push",
7632 "clippy::self_named_constructors",
7633 "clippy::should_implement_trait",
7634 "clippy::single_char_add_str",
7635 "clippy::single_component_path_imports",
7636 "clippy::single_match",
7637 "clippy::string_extend_chars",
7638 "clippy::tabs_in_doc_comments",
7639 "clippy::to_digit_is_some",
7640 "clippy::toplevel_ref_arg",
7642 "clippy::unnecessary_fold",
7643 "clippy::unnecessary_lazy_evaluations",
7644 "clippy::unnecessary_mut_passed",
7645 "clippy::unsafe_removed_from_name",
7646 "clippy::unused_unit",
7647 "clippy::unusual_byte_groupings",
7648 "clippy::unwrap_or_else_default",
7649 "clippy::upper_case_acronyms",
7650 "clippy::while_let_on_iterator",
7651 "clippy::write_literal",
7652 "clippy::write_with_newline",
7653 "clippy::writeln_empty_string",
7654 "clippy::wrong_self_convention",
7660 label
: "clippy::suspicious",
7661 description
: r
##"lint group for: clippy::blanket_clippy_restriction_lints, clippy::empty_loop, clippy::eval_order_dependence, clippy::float_equality_without_abs, clippy::for_loops_over_fallibles, clippy::misrefactored_assign_op, clippy::mut_range_bound, clippy::mutable_key_type, clippy::octal_escapes, clippy::return_self_not_must_use, clippy::suspicious_arithmetic_impl, clippy::suspicious_assignment_formatting, clippy::suspicious_else_formatting, clippy::suspicious_map, clippy::suspicious_op_assign_impl, clippy::suspicious_unary_op_formatting"##,
7664 "clippy::blanket_clippy_restriction_lints",
7665 "clippy::empty_loop",
7666 "clippy::eval_order_dependence",
7667 "clippy::float_equality_without_abs",
7668 "clippy::for_loops_over_fallibles",
7669 "clippy::misrefactored_assign_op",
7670 "clippy::mut_range_bound",
7671 "clippy::mutable_key_type",
7672 "clippy::octal_escapes",
7673 "clippy::return_self_not_must_use",
7674 "clippy::suspicious_arithmetic_impl",
7675 "clippy::suspicious_assignment_formatting",
7676 "clippy::suspicious_else_formatting",
7677 "clippy::suspicious_map",
7678 "clippy::suspicious_op_assign_impl",
7679 "clippy::suspicious_unary_op_formatting",