1 //! Generated by `sourcegen_lints`, do not edit by hand. 2 3 #[derive(Clone)] 4 pub struct Lint { 5 pub label: &'static str, 6 pub description: &'static str, 7 } 8 pub struct LintGroup { 9 pub lint: Lint, 10 pub children: &'static [&'static str], 11 } 12 pub const DEFAULT_LINTS: &[Lint] = &[ 13 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"##, 16 }, 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"## }, 20 Lint { 21 label: "array_into_iter", 22 description: r##"detects calling `into_iter` on arrays in Rust 2015 and 2018"##, 23 }, 24 Lint { 25 label: "asm_sub_register", 26 description: r##"using only a subset of a register for inline asm inputs"##, 27 }, 28 Lint { label: "bad_asm_style", description: r##"incorrect use of inline assembly"## }, 29 Lint { 30 label: "bare_trait_objects", 31 description: r##"suggest using `dyn Trait` for trait objects"##, 32 }, 33 Lint { 34 label: "bindings_with_variant_name", 35 description: r##"detects pattern bindings with the same name as one of the matched variants"##, 36 }, 37 Lint { label: "box_pointers", description: r##"use of owned (Box type) heap memory"## }, 38 Lint { 39 label: "break_with_label_and_loop", 40 description: r##"`break` expression with label and unlabeled loop as value expression"##, 41 }, 42 Lint { 43 label: "cenum_impl_drop_cast", 44 description: r##"a C-like enum implementing Drop is cast"##, 45 }, 46 Lint { 47 label: "clashing_extern_declarations", 48 description: r##"detects when an extern fn has been declared with the same name but different types"##, 49 }, 50 Lint { 51 label: "coherence_leak_check", 52 description: r##"distinct impls distinguished only by the leak-check code"##, 53 }, 54 Lint { 55 label: "conflicting_repr_hints", 56 description: r##"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice"##, 57 }, 58 Lint { 59 label: "confusable_idents", 60 description: r##"detects visually confusable pairs between identifiers"##, 61 }, 62 Lint { 63 label: "const_err", 64 description: r##"constant evaluation encountered erroneous expression"##, 65 }, 66 Lint { 67 label: "const_evaluatable_unchecked", 68 description: r##"detects a generic constant is used in a type without a emitting a warning"##, 69 }, 70 Lint { 71 label: "const_item_mutation", 72 description: r##"detects attempts to mutate a `const` item"##, 73 }, 74 Lint { label: "dead_code", description: r##"detect unused, unexported items"## }, 75 Lint { label: "deprecated", description: r##"detects use of deprecated items"## }, 76 Lint { 77 label: "deprecated_in_future", 78 description: r##"detects use of items that will be deprecated in a future version"##, 79 }, 80 Lint { 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"##, 83 }, 84 Lint { 85 label: "deref_nullptr", 86 description: r##"detects when an null pointer is dereferenced"##, 87 }, 88 Lint { 89 label: "drop_bounds", 90 description: r##"bounds of the form `T: Drop` are most likely incorrect"##, 91 }, 92 Lint { 93 label: "dyn_drop", 94 description: r##"trait objects of the form `dyn Drop` are useless"##, 95 }, 96 Lint { 97 label: "elided_lifetimes_in_paths", 98 description: r##"hidden lifetime parameters in types are deprecated"##, 99 }, 100 Lint { 101 label: "ellipsis_inclusive_range_patterns", 102 description: r##"`...` range patterns are deprecated"##, 103 }, 104 Lint { 105 label: "enum_intrinsics_non_enums", 106 description: r##"detects calls to `core::mem::discriminant` and `core::mem::variant_count` with non-enum types"##, 107 }, 108 Lint { 109 label: "explicit_outlives_requirements", 110 description: r##"outlives requirements can be inferred"##, 111 }, 112 Lint { 113 label: "exported_private_dependencies", 114 description: r##"public interface leaks type from a private dependency"##, 115 }, 116 Lint { label: "forbidden_lint_groups", description: r##"applying forbid to lint-groups"## }, 117 Lint { 118 label: "function_item_references", 119 description: r##"suggest casting to a function pointer when attempting to take references to function items"##, 120 }, 121 Lint { 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"##, 124 }, 125 Lint { 126 label: "ill_formed_attribute_input", 127 description: r##"ill-formed attribute inputs that were previously accepted and used in practice"##, 128 }, 129 Lint { 130 label: "illegal_floating_point_literal_pattern", 131 description: r##"floating-point literals cannot be used in patterns"##, 132 }, 133 Lint { 134 label: "improper_ctypes", 135 description: r##"proper use of libc types in foreign modules"##, 136 }, 137 Lint { 138 label: "improper_ctypes_definitions", 139 description: r##"proper use of libc types in foreign item definitions"##, 140 }, 141 Lint { 142 label: "incomplete_features", 143 description: r##"incomplete features that may function improperly in some or all cases"##, 144 }, 145 Lint { label: "incomplete_include", description: r##"trailing content in included file"## }, 146 Lint { 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"##, 149 }, 150 Lint { 151 label: "ineffective_unstable_trait_impl", 152 description: r##"detects `#[unstable]` on stable trait implementations for stable types"##, 153 }, 154 Lint { 155 label: "inline_no_sanitize", 156 description: r##"detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`"##, 157 }, 158 Lint { 159 label: "invalid_atomic_ordering", 160 description: r##"usage of invalid atomic ordering in atomic operations and memory fences"##, 161 }, 162 Lint { 163 label: "invalid_doc_attributes", 164 description: r##"detects invalid `#[doc(...)]` attributes"##, 165 }, 166 Lint { 167 label: "invalid_type_param_default", 168 description: r##"type parameter default erroneously allowed in invalid location"##, 169 }, 170 Lint { 171 label: "invalid_value", 172 description: r##"an invalid value is being created (such as a null reference)"##, 173 }, 174 Lint { 175 label: "irrefutable_let_patterns", 176 description: r##"detects irrefutable patterns in `if let` and `while let` statements"##, 177 }, 178 Lint { 179 label: "keyword_idents", 180 description: r##"detects edition keywords being used as an identifier"##, 181 }, 182 Lint { label: "large_assignments", description: r##"detects large moves or copies"## }, 183 Lint { 184 label: "late_bound_lifetime_arguments", 185 description: r##"detects generic lifetime arguments in path segments with late bound lifetime parameters"##, 186 }, 187 Lint { 188 label: "legacy_derive_helpers", 189 description: r##"detects derive helper attributes that are used before they are introduced"##, 190 }, 191 Lint { 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"##, 194 }, 195 Lint { 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"##, 198 }, 199 Lint { 200 label: "meta_variable_misuse", 201 description: r##"possible meta-variable misuse at macro definition"##, 202 }, 203 Lint { label: "missing_abi", description: r##"No declared ABI for extern declaration"## }, 204 Lint { 205 label: "missing_copy_implementations", 206 description: r##"detects potentially-forgotten implementations of `Copy`"##, 207 }, 208 Lint { 209 label: "missing_debug_implementations", 210 description: r##"detects missing implementations of Debug"##, 211 }, 212 Lint { 213 label: "missing_docs", 214 description: r##"detects missing documentation for public members"##, 215 }, 216 Lint { 217 label: "missing_fragment_specifier", 218 description: r##"detects missing fragment specifiers in unused `macro_rules!` patterns"##, 219 }, 220 Lint { 221 label: "mixed_script_confusables", 222 description: r##"detects Unicode scripts whose mixed script confusables codepoints are solely used"##, 223 }, 224 Lint { 225 label: "must_not_suspend", 226 description: r##"use of a `#[must_not_suspend]` value across a yield point"##, 227 }, 228 Lint { 229 label: "mutable_borrow_reservation_conflict", 230 description: r##"reservation of a two-phased borrow conflicts with other shared borrows"##, 231 }, 232 Lint { 233 label: "mutable_transmutes", 234 description: r##"mutating transmuted &mut T from &T may cause undefined behavior"##, 235 }, 236 Lint { label: "named_asm_labels", description: r##"named labels in inline assembly"## }, 237 Lint { 238 label: "no_mangle_const_items", 239 description: r##"const items will not have their symbols exported"##, 240 }, 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"## }, 243 Lint { 244 label: "non_camel_case_types", 245 description: r##"types, variants, traits and type parameters should have camel case names"##, 246 }, 247 Lint { 248 label: "non_exhaustive_omitted_patterns", 249 description: r##"detect when patterns of types marked `non_exhaustive` are missed"##, 250 }, 251 Lint { 252 label: "non_fmt_panics", 253 description: r##"detect single-argument panic!() invocations in which the argument is not a format string"##, 254 }, 255 Lint { 256 label: "non_shorthand_field_patterns", 257 description: r##"using `Struct { x: x }` instead of `Struct { x }` in a pattern"##, 258 }, 259 Lint { 260 label: "non_snake_case", 261 description: r##"variables, methods, functions, lifetime parameters and modules should have snake case names"##, 262 }, 263 Lint { 264 label: "non_upper_case_globals", 265 description: r##"static constants should have uppercase identifiers"##, 266 }, 267 Lint { 268 label: "nonstandard_style", 269 description: r##"lint group for: non-camel-case-types, non-snake-case, non-upper-case-globals"##, 270 }, 271 Lint { 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"##, 274 }, 275 Lint { 276 label: "noop_method_call", 277 description: r##"detects the use of well-known noop methods"##, 278 }, 279 Lint { 280 label: "order_dependent_trait_objects", 281 description: r##"trait-object types were treated as different depending on marker-trait order"##, 282 }, 283 Lint { label: "overflowing_literals", description: r##"literal out of range for its type"## }, 284 Lint { 285 label: "overlapping_range_endpoints", 286 description: r##"detects range patterns with overlapping endpoints"##, 287 }, 288 Lint { label: "path_statements", description: r##"path statements with no effect"## }, 289 Lint { 290 label: "patterns_in_fns_without_body", 291 description: r##"patterns in functions without body were erroneously allowed"##, 292 }, 293 Lint { 294 label: "pointer_structural_match", 295 description: r##"pointers are not structural-match"##, 296 }, 297 Lint { 298 label: "private_in_public", 299 description: r##"detect private items in public interfaces not caught by the old implementation"##, 300 }, 301 Lint { 302 label: "proc_macro_back_compat", 303 description: r##"detects usage of old versions of certain proc-macro crates"##, 304 }, 305 Lint { 306 label: "proc_macro_derive_resolution_fallback", 307 description: r##"detects proc macro derives using inaccessible names from parent modules"##, 308 }, 309 Lint { 310 label: "pub_use_of_private_extern_crate", 311 description: r##"detect public re-exports of private extern crates"##, 312 }, 313 Lint { 314 label: "redundant_semicolons", 315 description: r##"detects unnecessary trailing semicolons"##, 316 }, 317 Lint { 318 label: "renamed_and_removed_lints", 319 description: r##"lints that have been renamed or removed"##, 320 }, 321 Lint { 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"##, 324 }, 325 Lint { 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"##, 328 }, 329 Lint { 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"##, 332 }, 333 Lint { 334 label: "rust_2021_incompatible_closure_captures", 335 description: r##"detects closures affected by Rust 2021 changes"##, 336 }, 337 Lint { 338 label: "rust_2021_incompatible_or_patterns", 339 description: r##"detects usage of old versions of or-patterns"##, 340 }, 341 Lint { 342 label: "rust_2021_prefixes_incompatible_syntax", 343 description: r##"identifiers that will be parsed as a prefix in Rust 2021"##, 344 }, 345 Lint { 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"##, 348 }, 349 Lint { 350 label: "semicolon_in_expressions_from_macros", 351 description: r##"trailing semicolon in macro body used as expression"##, 352 }, 353 Lint { 354 label: "single_use_lifetimes", 355 description: r##"detects lifetime parameters that are only used once"##, 356 }, 357 Lint { 358 label: "soft_unstable", 359 description: r##"a feature gate that doesn't break dependent crates"##, 360 }, 361 Lint { 362 label: "stable_features", 363 description: r##"stable features found in `#[feature]` directive"##, 364 }, 365 Lint { 366 label: "temporary_cstring_as_ptr", 367 description: r##"detects getting the inner pointer of a temporary `CString`"##, 368 }, 369 Lint { 370 label: "text_direction_codepoint_in_comment", 371 description: r##"invisible directionality-changing codepoints in comment"##, 372 }, 373 Lint { 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"##, 376 }, 377 Lint { 378 label: "trivial_bounds", 379 description: r##"these bounds don't depend on an type parameters"##, 380 }, 381 Lint { 382 label: "trivial_casts", 383 description: r##"detects trivial casts which could be removed"##, 384 }, 385 Lint { 386 label: "trivial_numeric_casts", 387 description: r##"detects trivial casts of numeric types which could be removed"##, 388 }, 389 Lint { 390 label: "type_alias_bounds", 391 description: r##"bounds in type aliases are not enforced"##, 392 }, 393 Lint { 394 label: "tyvar_behind_raw_pointer", 395 description: r##"raw pointer to an inference variable"##, 396 }, 397 Lint { 398 label: "unaligned_references", 399 description: r##"detects unaligned references to fields of packed structs"##, 400 }, 401 Lint { 402 label: "uncommon_codepoints", 403 description: r##"detects uncommon Unicode codepoints in identifiers"##, 404 }, 405 Lint { 406 label: "unconditional_panic", 407 description: r##"operation will cause a panic at runtime"##, 408 }, 409 Lint { 410 label: "unconditional_recursion", 411 description: r##"functions that cannot return without calling themselves"##, 412 }, 413 Lint { label: "uninhabited_static", description: r##"uninhabited static"## }, 414 Lint { 415 label: "unknown_crate_types", 416 description: r##"unknown crate type found in `#[crate_type]` directive"##, 417 }, 418 Lint { label: "unknown_lints", description: r##"unrecognized lint attribute"## }, 419 Lint { 420 label: "unnameable_test_items", 421 description: r##"detects an item that cannot be named being marked as `#[test_case]`"##, 422 }, 423 Lint { label: "unreachable_code", description: r##"detects unreachable code paths"## }, 424 Lint { label: "unreachable_patterns", description: r##"detects unreachable patterns"## }, 425 Lint { 426 label: "unreachable_pub", 427 description: r##"`pub` items not reachable from crate root"##, 428 }, 429 Lint { label: "unsafe_code", description: r##"usage of `unsafe` code"## }, 430 Lint { 431 label: "unsafe_op_in_unsafe_fn", 432 description: r##"unsafe operations in unsafe functions without an explicit unsafe block are deprecated"##, 433 }, 434 Lint { 435 label: "unstable_features", 436 description: r##"enabling unstable features (deprecated. do not use)"##, 437 }, 438 Lint { 439 label: "unstable_name_collisions", 440 description: r##"detects name collision with an existing but unstable method"##, 441 }, 442 Lint { 443 label: "unsupported_calling_conventions", 444 description: r##"use of unsupported calling convention"##, 445 }, 446 Lint { 447 label: "unsupported_naked_functions", 448 description: r##"unsupported naked function definitions"##, 449 }, 450 Lint { 451 label: "unused", 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"##, 453 }, 454 Lint { 455 label: "unused_allocation", 456 description: r##"detects unnecessary allocations that can be eliminated"##, 457 }, 458 Lint { 459 label: "unused_assignments", 460 description: r##"detect assignments that will never be read"##, 461 }, 462 Lint { 463 label: "unused_attributes", 464 description: r##"detects attributes that were not used by the compiler"##, 465 }, 466 Lint { label: "unused_braces", description: r##"unnecessary braces around an expression"## }, 467 Lint { 468 label: "unused_comparisons", 469 description: r##"comparisons made useless by limits of the types involved"##, 470 }, 471 Lint { 472 label: "unused_crate_dependencies", 473 description: r##"crate dependencies that are never used"##, 474 }, 475 Lint { 476 label: "unused_doc_comments", 477 description: r##"detects doc comments that aren't used by rustdoc"##, 478 }, 479 Lint { label: "unused_extern_crates", description: r##"extern crates that are never used"## }, 480 Lint { 481 label: "unused_features", 482 description: r##"unused features found in crate-level `#[feature]` directives"##, 483 }, 484 Lint { 485 label: "unused_import_braces", 486 description: r##"unnecessary braces around an imported item"##, 487 }, 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"## }, 490 Lint { 491 label: "unused_lifetimes", 492 description: r##"detects lifetime parameters that are never used"##, 493 }, 494 Lint { label: "unused_macros", description: r##"detects macros that were not used"## }, 495 Lint { 496 label: "unused_must_use", 497 description: r##"unused result of a type flagged as `#[must_use]`"##, 498 }, 499 Lint { 500 label: "unused_mut", 501 description: r##"detect mut variables which don't need to be mutable"##, 502 }, 503 Lint { 504 label: "unused_parens", 505 description: r##"`if`, `match`, `while` and `return` do not need parentheses"##, 506 }, 507 Lint { 508 label: "unused_qualifications", 509 description: r##"detects unnecessarily qualified names"##, 510 }, 511 Lint { 512 label: "unused_results", 513 description: r##"unused result of an expression in a statement"##, 514 }, 515 Lint { label: "unused_unsafe", description: r##"unnecessary use of an `unsafe` block"## }, 516 Lint { 517 label: "unused_variables", 518 description: r##"detect variables which are not used in any way"##, 519 }, 520 Lint { 521 label: "useless_deprecated", 522 description: r##"detects deprecation attributes with no effect"##, 523 }, 524 Lint { 525 label: "variant_size_differences", 526 description: r##"detects enums with widely varying variant sizes"##, 527 }, 528 Lint { 529 label: "warnings", 530 description: r##"mass-change the level for lints which produce warnings"##, 531 }, 532 Lint { 533 label: "warnings", 534 description: r##"lint group for: all lints that are set to issue warnings"##, 535 }, 536 Lint { 537 label: "where_clauses_object_safety", 538 description: r##"checks the object safety of where clauses"##, 539 }, 540 Lint { 541 label: "while_true", 542 description: r##"suggest using `loop { }` instead of `while true { }`"##, 543 }, 544 ]; 545 pub const DEFAULT_LINT_GROUPS: &[LintGroup] = &[ 546 LintGroup { 547 lint: Lint { 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"##, 550 }, 551 children: &[ 552 "forbidden_lint_groups", 553 "illegal_floating_point_literal_pattern", 554 "private_in_public", 555 "pub_use_of_private_extern_crate", 556 "invalid_type_param_default", 557 "const_err", 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", 575 "soft_unstable", 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", 586 ], 587 }, 588 LintGroup { 589 lint: Lint { 590 label: "nonstandard_style", 591 description: r##"lint group for: non-camel-case-types, non-snake-case, non-upper-case-globals"##, 592 }, 593 children: &["non_camel_case_types", "non_snake_case", "non_upper_case_globals"], 594 }, 595 LintGroup { 596 lint: Lint { 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"##, 599 }, 600 children: &[ 601 "keyword_idents", 602 "anonymous_parameters", 603 "tyvar_behind_raw_pointer", 604 "absolute_paths_not_starting_with_crate", 605 ], 606 }, 607 LintGroup { 608 lint: Lint { 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"##, 611 }, 612 children: &[ 613 "bare_trait_objects", 614 "unused_extern_crates", 615 "ellipsis_inclusive_range_patterns", 616 "elided_lifetimes_in_paths", 617 "explicit_outlives_requirements", 618 ], 619 }, 620 LintGroup { 621 lint: Lint { 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"##, 624 }, 625 children: &[ 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", 632 "array_into_iter", 633 "non_fmt_panics", 634 ], 635 }, 636 LintGroup { 637 lint: Lint { 638 label: "unused", 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"##, 640 }, 641 children: &[ 642 "unused_imports", 643 "unused_variables", 644 "unused_assignments", 645 "dead_code", 646 "unused_mut", 647 "unreachable_code", 648 "unreachable_patterns", 649 "unused_must_use", 650 "unused_unsafe", 651 "path_statements", 652 "unused_attributes", 653 "unused_macros", 654 "unused_allocation", 655 "unused_doc_comments", 656 "unused_extern_crates", 657 "unused_features", 658 "unused_labels", 659 "unused_parens", 660 "unused_braces", 661 "redundant_semicolons", 662 ], 663 }, 664 LintGroup { 665 lint: Lint { 666 label: "warnings", 667 description: r##"lint group for: all lints that are set to issue warnings"##, 668 }, 669 children: &[], 670 }, 671 ]; 672 673 pub const RUSTDOC_LINTS: &[Lint] = &[ 674 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"##, 677 }, 678 Lint { label: "rustdoc::bare_urls", description: r##"detects URLs that are not hyperlinks"## }, 679 Lint { 680 label: "rustdoc::broken_intra_doc_links", 681 description: r##"failures in resolving intra-doc link targets"##, 682 }, 683 Lint { 684 label: "rustdoc::invalid_codeblock_attributes", 685 description: r##"codeblock attribute looks a lot like a known one"##, 686 }, 687 Lint { 688 label: "rustdoc::invalid_html_tags", 689 description: r##"detects invalid HTML tags in doc comments"##, 690 }, 691 Lint { 692 label: "rustdoc::invalid_rust_codeblocks", 693 description: r##"codeblock could not be parsed as valid Rust or is empty"##, 694 }, 695 Lint { 696 label: "rustdoc::missing_crate_level_docs", 697 description: r##"detects crates with no crate-level documentation"##, 698 }, 699 Lint { 700 label: "rustdoc::missing_doc_code_examples", 701 description: r##"detects publicly-exported items without code samples in their documentation"##, 702 }, 703 Lint { 704 label: "rustdoc::private_doc_tests", 705 description: r##"detects code samples in docs of private items not documented by rustdoc"##, 706 }, 707 Lint { 708 label: "rustdoc::private_intra_doc_links", 709 description: r##"linking from a public item to a private one"##, 710 }, 711 ]; 712 pub const RUSTDOC_LINT_GROUPS: &[LintGroup] = &[LintGroup { 713 lint: Lint { 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"##, 716 }, 717 children: &[ 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", 727 ], 728 }]; 729 730 pub const FEATURES: &[Lint] = &[ 731 Lint { 732 label: "abi_c_cmse_nonsecure_call", 733 description: r##"# `abi_c_cmse_nonsecure_call` 734 735 The tracking issue for this feature is: [#81391] 736 737 [#81391]: https://github.com/rust-lang/rust/issues/81391 738 739 ------------------------ 740 741 The [TrustZone-M 742 feature](https://developer.arm.com/documentation/100690/latest/) is available 743 for targets with the Armv8-M architecture profile (`thumbv8m` in their target 744 name). 745 LLVM, the Rust compiler and the linker are providing 746 [support](https://developer.arm.com/documentation/ecm0359818/latest/) for the 747 TrustZone-M feature. 748 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). 753 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 759 760 To avoid using the non-secure stack, the compiler will constrain the number and 761 type of parameters/return value. 762 763 The `extern "C-cmse-nonsecure-call"` ABI is otherwise equivalent to the 764 `extern "C"` ABI. 765 766 <!-- NOTE(ignore) this example is specific to thumbv8m targets --> 767 768 ``` rust,ignore 769 #![no_std] 770 #![feature(abi_c_cmse_nonsecure_call)] 771 772 #[no_mangle] 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() 777 } 778 ``` 779 780 ``` text 781 $ rustc --emit asm --crate-type lib --target thumbv8m.main-none-eabi function.rs 782 783 call_nonsecure_function: 784 .fnstart 785 .save {r7, lr} 786 push {r7, lr} 787 .setfp r7, sp 788 mov r7, sp 789 .pad #16 790 sub sp, #16 791 str r0, [sp, #12] 792 ldr r0, [sp, #12] 793 str r0, [sp, #8] 794 b .LBB0_1 795 .LBB0_1: 796 ldr r0, [sp, #8] 797 push.w {r4, r5, r6, r7, r8, r9, r10, r11} 798 bic r0, r0, #1 799 mov r1, r0 800 mov r2, r0 801 mov r3, r0 802 mov r4, r0 803 mov r5, r0 804 mov r6, r0 805 mov r7, r0 806 mov r8, r0 807 mov r9, r0 808 mov r10, r0 809 mov r11, r0 810 mov r12, r0 811 msr apsr_nzcvq, r0 812 blxns r0 813 pop.w {r4, r5, r6, r7, r8, r9, r10, r11} 814 str r0, [sp, #4] 815 b .LBB0_2 816 .LBB0_2: 817 ldr r0, [sp, #4] 818 add sp, #16 819 pop {r7, pc} 820 ``` 821 "##, 822 }, 823 Lint { 824 label: "abi_msp430_interrupt", 825 description: r##"# `abi_msp430_interrupt` 826 827 The tracking issue for this feature is: [#38487] 828 829 [#38487]: https://github.com/rust-lang/rust/issues/38487 830 831 ------------------------ 832 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. 836 837 <!-- NOTE(ignore) this example is specific to the msp430 target --> 838 839 ``` rust,ignore 840 #![feature(abi_msp430_interrupt)] 841 #![no_std] 842 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"] 846 #[no_mangle] 847 pub static TIM0_VECTOR: extern "msp430-interrupt" fn() = tim0; 848 849 // The interrupt handler 850 extern "msp430-interrupt" fn tim0() { 851 // .. 852 } 853 ``` 854 855 ``` text 856 $ msp430-elf-objdump -CD ./target/msp430/release/app 857 Disassembly of section __interrupt_vector_10: 858 859 0000fff2 <TIM0_VECTOR>: 860 fff2: 00 c0 interrupt service routine at 0xc000 861 862 Disassembly of section .text: 863 864 0000c000 <int::tim0>: 865 c000: 00 13 reti 866 ``` 867 "##, 868 }, 869 Lint { 870 label: "abi_ptx", 871 description: r##"# `abi_ptx` 872 873 The tracking issue for this feature is: [#38788] 874 875 [#38788]: https://github.com/rust-lang/rust/issues/38788 876 877 ------------------------ 878 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! 882 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 885 `"ptx-kernel"` ABI. 886 887 <!-- NOTE(ignore) this example is specific to the nvptx targets --> 888 889 ``` rust,ignore 890 #![feature(abi_ptx)] 891 #![no_std] 892 893 pub unsafe extern "ptx-kernel" fn global_function() { 894 device_function(); 895 } 896 897 pub fn device_function() { 898 // .. 899 } 900 ``` 901 902 ``` text 903 $ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm 904 905 $ cat $(find -name '*.s') 906 // 907 // Generated by LLVM NVPTX Back-End 908 // 909 910 .version 3.2 911 .target sm_20 912 .address_size 64 913 914 // .globl _ZN6kernel15global_function17h46111ebe6516b382E 915 916 .visible .entry _ZN6kernel15global_function17h46111ebe6516b382E() 917 { 918 919 920 ret; 921 } 922 923 // .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E 924 .visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E() 925 { 926 927 928 ret; 929 } 930 ``` 931 "##, 932 }, 933 Lint { 934 label: "abi_thiscall", 935 description: r##"# `abi_thiscall` 936 937 The tracking issue for this feature is: [#42202] 938 939 [#42202]: https://github.com/rust-lang/rust/issues/42202 940 941 ------------------------ 942 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. 947 "##, 948 }, 949 Lint { 950 label: "allocator_api", 951 description: r##"# `allocator_api` 952 953 The tracking issue for this feature is [#32838] 954 955 [#32838]: https://github.com/rust-lang/rust/issues/32838 956 957 ------------------------ 958 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. 964 965 TBD 966 "##, 967 }, 968 Lint { 969 label: "allocator_internals", 970 description: r##"# `allocator_internals` 971 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 974 compiler. 975 976 ------------------------ 977 "##, 978 }, 979 Lint { 980 label: "arbitrary_enum_discriminant", 981 description: r##"# `arbitrary_enum_discriminant` 982 983 The tracking issue for this feature is: [#60553] 984 985 [#60553]: https://github.com/rust-lang/rust/issues/60553 986 987 ------------------------ 988 989 The `arbitrary_enum_discriminant` feature permits tuple-like and 990 struct-like enum variants with `#[repr(<int-type>)]` to have explicit discriminants. 991 992 ## Examples 993 994 ```rust 995 #![feature(arbitrary_enum_discriminant)] 996 997 #[allow(dead_code)] 998 #[repr(u8)] 999 enum Enum { 1000 Unit = 3, 1001 Tuple(u16) = 2, 1002 Struct { 1003 a: u8, 1004 b: u16, 1005 } = 1, 1006 } 1007 1008 impl Enum { 1009 fn tag(&self) -> u8 { 1010 unsafe { *(self as *const Self as *const u8) } 1011 } 1012 } 1013 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()); 1017 ``` 1018 "##, 1019 }, 1020 Lint { 1021 label: "asm_const", 1022 description: r##"# `asm_const` 1023 1024 The tracking issue for this feature is: [#72016] 1025 1026 [#72016]: https://github.com/rust-lang/rust/issues/72016 1027 1028 ------------------------ 1029 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. 1033 "##, 1034 }, 1035 Lint { 1036 label: "asm_experimental_arch", 1037 description: r##"# `asm_experimental_arch` 1038 1039 The tracking issue for this feature is: [#72016] 1040 1041 [#72016]: https://github.com/rust-lang/rust/issues/72016 1042 1043 ------------------------ 1044 1045 This feature tracks `asm!` and `global_asm!` support for the following architectures: 1046 - NVPTX 1047 - PowerPC 1048 - Hexagon 1049 - MIPS32r2 and MIPS64r2 1050 - wasm32 1051 - BPF 1052 - SPIR-V 1053 - AVR 1054 1055 ## Register classes 1056 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` | 1078 1079 > **Notes**: 1080 > - NVPTX doesn't have a fixed register set, so named registers are not supported. 1081 > 1082 > - WebAssembly doesn't have registers, so named registers are not supported. 1083 1084 # Register class supported types 1085 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` | 1106 1107 ## Register aliases 1108 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` | 1119 1120 ## Unsupported registers 1121 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. | 1134 1135 ## Template modifiers 1136 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 | 1148 1149 # Flags covered by `preserves_flags` 1150 1151 These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set: 1152 - AVR 1153 - The status register `SREG`. 1154 "##, 1155 }, 1156 Lint { 1157 label: "asm_sym", 1158 description: r##"# `asm_sym` 1159 1160 The tracking issue for this feature is: [#72016] 1161 1162 [#72016]: https://github.com/rust-lang/rust/issues/72016 1163 1164 ------------------------ 1165 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. 1171 "##, 1172 }, 1173 Lint { 1174 label: "asm_unwind", 1175 description: r##"# `asm_unwind` 1176 1177 The tracking issue for this feature is: [#72016] 1178 1179 [#72016]: https://github.com/rust-lang/rust/issues/72016 1180 1181 ------------------------ 1182 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. 1184 "##, 1185 }, 1186 Lint { 1187 label: "auto_traits", 1188 description: r##"# `auto_traits` 1189 1190 The tracking issue for this feature is [#13231] 1191 1192 [#13231]: https://github.com/rust-lang/rust/issues/13231 1193 1194 ---- 1195 1196 The `auto_traits` feature gate allows you to define auto traits. 1197 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.) 1202 1203 [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html 1204 [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html 1205 1206 ```rust,ignore (partial-example) 1207 impl !Trait for Type {} 1208 ``` 1209 1210 Example: 1211 1212 ```rust 1213 #![feature(negative_impls)] 1214 #![feature(auto_traits)] 1215 1216 auto trait Valid {} 1217 1218 struct True; 1219 struct False; 1220 1221 impl !Valid for False {} 1222 1223 struct MaybeValid<T>(T); 1224 1225 fn must_be_valid<T: Valid>(_t: T) { } 1226 1227 fn main() { 1228 // works 1229 must_be_valid( MaybeValid(True) ); 1230 1231 // compiler error - trait bound not satisfied 1232 // must_be_valid( MaybeValid(False) ); 1233 } 1234 ``` 1235 1236 ## Automatic trait implementations 1237 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`: 1244 1245 ```rust 1246 struct List<T> { 1247 data: T, 1248 next: Option<Box<List<T>>>, 1249 } 1250 ``` 1251 1252 Presuming that there is no explicit impl of `Send` for `List`, the 1253 compiler will supply an automatic impl of the form: 1254 1255 ```rust 1256 struct List<T> { 1257 data: T, 1258 next: Option<Box<List<T>>>, 1259 } 1260 1261 unsafe impl<T> Send for List<T> 1262 where 1263 T: Send, // from the field `data` 1264 Option<Box<List<T>>>: Send, // from the field `next` 1265 { } 1266 ``` 1267 1268 Explicit impls may be either positive or negative. They take the form: 1269 1270 ```rust,ignore (partial-example) 1271 impl<...> AutoTrait for StructName<..> { } 1272 impl<...> !AutoTrait for StructName<..> { } 1273 ``` 1274 1275 ## Coinduction: Auto traits permit cyclic matching 1276 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. 1286 1287 ## Items 1288 1289 Auto traits cannot have any trait items, such as methods or associated types. This ensures that we can generate default implementations. 1290 1291 ## Supertraits 1292 1293 Auto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile. 1294 "##, 1295 }, 1296 Lint { 1297 label: "box_patterns", 1298 description: r##"# `box_patterns` 1299 1300 The tracking issue for this feature is: [#29641] 1301 1302 [#29641]: https://github.com/rust-lang/rust/issues/29641 1303 1304 See also [`box_syntax`](box-syntax.md) 1305 1306 ------------------------ 1307 1308 Box patterns let you match on `Box<T>`s: 1309 1310 1311 ```rust 1312 #![feature(box_patterns)] 1313 1314 fn main() { 1315 let b = Some(Box::new(5)); 1316 match b { 1317 Some(box n) if n < 0 => { 1318 println!("Box contains negative number {}", n); 1319 }, 1320 Some(box n) if n >= 0 => { 1321 println!("Box contains non-negative number {}", n); 1322 }, 1323 None => { 1324 println!("No box"); 1325 }, 1326 _ => unreachable!() 1327 } 1328 } 1329 ``` 1330 "##, 1331 }, 1332 Lint { 1333 label: "box_syntax", 1334 description: r##"# `box_syntax` 1335 1336 The tracking issue for this feature is: [#49733] 1337 1338 [#49733]: https://github.com/rust-lang/rust/issues/49733 1339 1340 See also [`box_patterns`](box-patterns.md) 1341 1342 ------------------------ 1343 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 1347 usage would be: 1348 1349 ```rust 1350 #![feature(box_syntax)] 1351 1352 fn main() { 1353 let b = box 5; 1354 } 1355 ``` 1356 "##, 1357 }, 1358 Lint { 1359 label: "c_unwind", 1360 description: r##"# `c_unwind` 1361 1362 The tracking issue for this feature is: [#74990] 1363 1364 [#74990]: https://github.com/rust-lang/rust/issues/74990 1365 1366 ------------------------ 1367 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. 1371 1372 See [RFC 2945] for more information. 1373 1374 [RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md 1375 "##, 1376 }, 1377 Lint { 1378 label: "c_variadic", 1379 description: r##"# `c_variadic` 1380 1381 The tracking issue for this feature is: [#44930] 1382 1383 [#44930]: https://github.com/rust-lang/rust/issues/44930 1384 1385 ------------------------ 1386 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. 1389 1390 ## Examples 1391 1392 ```rust 1393 #![feature(c_variadic)] 1394 1395 pub unsafe extern "C" fn add(n: usize, mut args: ...) -> usize { 1396 let mut sum = 0; 1397 for _ in 0..n { 1398 sum += args.arg::<usize>(); 1399 } 1400 sum 1401 } 1402 ``` 1403 "##, 1404 }, 1405 Lint { 1406 label: "c_variadic", 1407 description: r##"# `c_variadic` 1408 1409 The tracking issue for this feature is: [#44930] 1410 1411 [#44930]: https://github.com/rust-lang/rust/issues/44930 1412 1413 ------------------------ 1414 1415 The `c_variadic` library feature exposes the `VaList` structure, 1416 Rust's analogue of C's `va_list` type. 1417 1418 ## Examples 1419 1420 ```rust 1421 #![feature(c_variadic)] 1422 1423 use std::ffi::VaList; 1424 1425 pub unsafe extern "C" fn vadd(n: usize, mut args: VaList) -> usize { 1426 let mut sum = 0; 1427 for _ in 0..n { 1428 sum += args.arg::<usize>(); 1429 } 1430 sum 1431 } 1432 ``` 1433 "##, 1434 }, 1435 Lint { 1436 label: "c_void_variant", 1437 description: r##"# `c_void_variant` 1438 1439 This feature is internal to the Rust compiler and is not intended for general use. 1440 1441 ------------------------ 1442 "##, 1443 }, 1444 Lint { 1445 label: "cfg_panic", 1446 description: r##"# `cfg_panic` 1447 1448 The tracking issue for this feature is: [#77443] 1449 1450 [#77443]: https://github.com/rust-lang/rust/issues/77443 1451 1452 ------------------------ 1453 1454 The `cfg_panic` feature makes it possible to execute different code 1455 depending on the panic strategy. 1456 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 1459 future. 1460 1461 ## Examples 1462 1463 ```rust 1464 #![feature(cfg_panic)] 1465 1466 #[cfg(panic = "unwind")] 1467 fn a() { 1468 // ... 1469 } 1470 1471 #[cfg(not(panic = "unwind"))] 1472 fn a() { 1473 // ... 1474 } 1475 1476 fn b() { 1477 if cfg!(panic = "abort") { 1478 // ... 1479 } else { 1480 // ... 1481 } 1482 } 1483 ``` 1484 "##, 1485 }, 1486 Lint { 1487 label: "cfg_sanitize", 1488 description: r##"# `cfg_sanitize` 1489 1490 The tracking issue for this feature is: [#39699] 1491 1492 [#39699]: https://github.com/rust-lang/rust/issues/39699 1493 1494 ------------------------ 1495 1496 The `cfg_sanitize` feature makes it possible to execute different code 1497 depending on whether a particular sanitizer is enabled or not. 1498 1499 ## Examples 1500 1501 ```rust 1502 #![feature(cfg_sanitize)] 1503 1504 #[cfg(sanitize = "thread")] 1505 fn a() { 1506 // ... 1507 } 1508 1509 #[cfg(not(sanitize = "thread"))] 1510 fn a() { 1511 // ... 1512 } 1513 1514 fn b() { 1515 if cfg!(sanitize = "leak") { 1516 // ... 1517 } else { 1518 // ... 1519 } 1520 } 1521 ``` 1522 "##, 1523 }, 1524 Lint { 1525 label: "cfg_version", 1526 description: r##"# `cfg_version` 1527 1528 The tracking issue for this feature is: [#64796] 1529 1530 [#64796]: https://github.com/rust-lang/rust/issues/64796 1531 1532 ------------------------ 1533 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. 1537 1538 ## Examples 1539 1540 ```rust 1541 #![feature(cfg_version)] 1542 1543 #[cfg(version("1.42"))] // 1.42 and above 1544 fn a() { 1545 // ... 1546 } 1547 1548 #[cfg(not(version("1.42")))] // 1.41 and below 1549 fn a() { 1550 // ... 1551 } 1552 1553 fn b() { 1554 if cfg!(version("1.42")) { 1555 // ... 1556 } else { 1557 // ... 1558 } 1559 } 1560 ``` 1561 "##, 1562 }, 1563 Lint { 1564 label: "char_error_internals", 1565 description: r##"# `char_error_internals` 1566 1567 This feature is internal to the Rust compiler and is not intended for general use. 1568 1569 ------------------------ 1570 "##, 1571 }, 1572 Lint { 1573 label: "closure_track_caller", 1574 description: r##"# `closure_track_caller` 1575 1576 The tracking issue for this feature is: [#87417] 1577 1578 [#87417]: https://github.com/rust-lang/rust/issues/87417 1579 1580 ------------------------ 1581 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. 1586 "##, 1587 }, 1588 Lint { 1589 label: "cmse_nonsecure_entry", 1590 description: r##"# `cmse_nonsecure_entry` 1591 1592 The tracking issue for this feature is: [#75835] 1593 1594 [#75835]: https://github.com/rust-lang/rust/issues/75835 1595 1596 ------------------------ 1597 1598 The [TrustZone-M 1599 feature](https://developer.arm.com/documentation/100690/latest/) is available 1600 for targets with the Armv8-M architecture profile (`thumbv8m` in their target 1601 name). 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. 1605 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 1615 information 1616 * use the `BXNS` instruction to return 1617 1618 Because the stack can not be used to pass parameters, there will be compilation 1619 errors if: 1620 * the total size of all parameters is too big (for example more than four 32 1621 bits integers) 1622 * the entry function is not using a C ABI 1623 1624 The special symbol `__acle_se_` will be used by the linker to generate a secure 1625 gateway veneer. 1626 1627 <!-- NOTE(ignore) this example is specific to thumbv8m targets --> 1628 1629 ``` rust,ignore 1630 #![feature(cmse_nonsecure_entry)] 1631 1632 #[no_mangle] 1633 #[cmse_nonsecure_entry] 1634 pub extern "C" fn entry_function(input: u32) -> u32 { 1635 input + 6 1636 } 1637 ``` 1638 1639 ``` text 1640 $ rustc --emit obj --crate-type lib --target thumbv8m.main-none-eabi function.rs 1641 $ arm-none-eabi-objdump -D function.o 1642 1643 00000000 <entry_function>: 1644 0: b580 push {r7, lr} 1645 2: 466f mov r7, sp 1646 4: b082 sub sp, #8 1647 6: 9001 str r0, [sp, #4] 1648 8: 1d81 adds r1, r0, #6 1649 a: 460a mov r2, r1 1650 c: 4281 cmp r1, r0 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] 1655 16: b002 add sp, #8 1656 18: e8bd 4080 ldmia.w sp!, {r7, lr} 1657 1c: 4671 mov r1, lr 1658 1e: 4672 mov r2, lr 1659 20: 4673 mov r3, lr 1660 22: 46f4 mov ip, lr 1661 24: f38e 8800 msr CPSR_f, lr 1662 28: 4774 bxns 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 1670 ``` 1671 "##, 1672 }, 1673 Lint { 1674 label: "compiler_builtins", 1675 description: r##"# `compiler_builtins` 1676 1677 This feature is internal to the Rust compiler and is not intended for general use. 1678 1679 ------------------------ 1680 "##, 1681 }, 1682 Lint { 1683 label: "concat_idents", 1684 description: r##"# `concat_idents` 1685 1686 The tracking issue for this feature is: [#29599] 1687 1688 [#29599]: https://github.com/rust-lang/rust/issues/29599 1689 1690 ------------------------ 1691 1692 The `concat_idents` feature adds a macro for concatenating multiple identifiers 1693 into one identifier. 1694 1695 ## Examples 1696 1697 ```rust 1698 #![feature(concat_idents)] 1699 1700 fn main() { 1701 fn foobar() -> u32 { 23 } 1702 let f = concat_idents!(foo, bar); 1703 assert_eq!(f(), 23); 1704 } 1705 ``` 1706 "##, 1707 }, 1708 Lint { 1709 label: "const_eval_limit", 1710 description: r##"# `const_eval_limit` 1711 1712 The tracking issue for this feature is: [#67217] 1713 1714 [#67217]: https://github.com/rust-lang/rust/issues/67217 1715 1716 The `const_eval_limit` allows someone to limit the evaluation steps the CTFE undertakes to evaluate a `const fn`. 1717 "##, 1718 }, 1719 Lint { 1720 label: "core_intrinsics", 1721 description: r##"# `core_intrinsics` 1722 1723 This feature is internal to the Rust compiler and is not intended for general use. 1724 1725 ------------------------ 1726 "##, 1727 }, 1728 Lint { 1729 label: "core_panic", 1730 description: r##"# `core_panic` 1731 1732 This feature is internal to the Rust compiler and is not intended for general use. 1733 1734 ------------------------ 1735 "##, 1736 }, 1737 Lint { 1738 label: "core_private_bignum", 1739 description: r##"# `core_private_bignum` 1740 1741 This feature is internal to the Rust compiler and is not intended for general use. 1742 1743 ------------------------ 1744 "##, 1745 }, 1746 Lint { 1747 label: "core_private_diy_float", 1748 description: r##"# `core_private_diy_float` 1749 1750 This feature is internal to the Rust compiler and is not intended for general use. 1751 1752 ------------------------ 1753 "##, 1754 }, 1755 Lint { 1756 label: "crate_visibility_modifier", 1757 description: r##"# `crate_visibility_modifier` 1758 1759 The tracking issue for this feature is: [#53120] 1760 1761 [#53120]: https://github.com/rust-lang/rust/issues/53120 1762 1763 ----- 1764 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 1768 other crates. 1769 1770 ```rust 1771 #![feature(crate_visibility_modifier)] 1772 1773 crate struct Foo { 1774 bar: usize, 1775 } 1776 ``` 1777 "##, 1778 }, 1779 Lint { 1780 label: "custom_test_frameworks", 1781 description: r##"# `custom_test_frameworks` 1782 1783 The tracking issue for this feature is: [#50297] 1784 1785 [#50297]: https://github.com/rust-lang/rust/issues/50297 1786 1787 ------------------------ 1788 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. 1792 1793 ```rust 1794 #![feature(custom_test_frameworks)] 1795 #![test_runner(my_runner)] 1796 1797 fn my_runner(tests: &[&i32]) { 1798 for t in tests { 1799 if **t == 0 { 1800 println!("PASSED"); 1801 } else { 1802 println!("FAILED"); 1803 } 1804 } 1805 } 1806 1807 #[test_case] 1808 const WILL_PASS: i32 = 0; 1809 1810 #[test_case] 1811 const WILL_FAIL: i32 = 4; 1812 ``` 1813 "##, 1814 }, 1815 Lint { 1816 label: "dec2flt", 1817 description: r##"# `dec2flt` 1818 1819 This feature is internal to the Rust compiler and is not intended for general use. 1820 1821 ------------------------ 1822 "##, 1823 }, 1824 Lint { 1825 label: "default_free_fn", 1826 description: r##"# `default_free_fn` 1827 1828 The tracking issue for this feature is: [#73014] 1829 1830 [#73014]: https://github.com/rust-lang/rust/issues/73014 1831 1832 ------------------------ 1833 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. 1837 1838 [`Default::default()`]: https://doc.rust-lang.org/nightly/std/default/trait.Default.html#tymethod.default 1839 1840 Here is an example: 1841 1842 ```rust 1843 #![feature(default_free_fn)] 1844 use std::default::default; 1845 1846 #[derive(Default)] 1847 struct AppConfig { 1848 foo: FooConfig, 1849 bar: BarConfig, 1850 } 1851 1852 #[derive(Default)] 1853 struct FooConfig { 1854 foo: i32, 1855 } 1856 1857 #[derive(Default)] 1858 struct BarConfig { 1859 bar: f32, 1860 baz: u8, 1861 } 1862 1863 fn main() { 1864 let options = AppConfig { 1865 foo: default(), 1866 bar: BarConfig { 1867 bar: 10.1, 1868 ..default() 1869 }, 1870 }; 1871 } 1872 ``` 1873 "##, 1874 }, 1875 Lint { 1876 label: "derive_clone_copy", 1877 description: r##"# `derive_clone_copy` 1878 1879 This feature is internal to the Rust compiler and is not intended for general use. 1880 1881 ------------------------ 1882 "##, 1883 }, 1884 Lint { 1885 label: "derive_eq", 1886 description: r##"# `derive_eq` 1887 1888 This feature is internal to the Rust compiler and is not intended for general use. 1889 1890 ------------------------ 1891 "##, 1892 }, 1893 Lint { 1894 label: "doc_cfg", 1895 description: r##"# `doc_cfg` 1896 1897 The tracking issue for this feature is: [#43781] 1898 1899 ------ 1900 1901 The `doc_cfg` feature allows an API be documented as only available in some specific platforms. 1902 This attribute has two effects: 1903 1904 1. In the annotated item's documentation, there will be a message saying "This is supported on 1905 (platform) only". 1906 1907 2. The item's doc-tests will only run on the specific platform. 1908 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 1911 crate. 1912 1913 This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the 1914 standard library be documented. 1915 1916 ```rust 1917 #![feature(doc_cfg)] 1918 1919 #[cfg(any(windows, doc))] 1920 #[doc(cfg(windows))] 1921 /// The application's icon in the notification area (a.k.a. system tray). 1922 /// 1923 /// # Examples 1924 /// 1925 /// ```no_run 1926 /// extern crate my_awesome_ui_library; 1927 /// use my_awesome_ui_library::current_app; 1928 /// use my_awesome_ui_library::windows::notification; 1929 /// 1930 /// let icon = current_app().get::<notification::Icon>(); 1931 /// icon.show(); 1932 /// icon.show_message("Hello"); 1933 /// ``` 1934 pub struct Icon { 1935 // ... 1936 } 1937 ``` 1938 1939 [#43781]: https://github.com/rust-lang/rust/issues/43781 1940 [#43348]: https://github.com/rust-lang/rust/issues/43348 1941 "##, 1942 }, 1943 Lint { 1944 label: "doc_masked", 1945 description: r##"# `doc_masked` 1946 1947 The tracking issue for this feature is: [#44027] 1948 1949 ----- 1950 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: 1953 1954 1. When rustdoc encounters an `extern crate` statement annotated with a `#[doc(masked)]` attribute, 1955 it marks the crate as being masked. 1956 1957 2. When listing traits a given type implements, rustdoc ensures that traits from masked crates are 1958 not emitted into the documentation. 1959 1960 3. When listing types that implement a given trait, rustdoc ensures that types from masked crates 1961 are not emitted into the documentation. 1962 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. 1966 1967 [#44026]: https://github.com/rust-lang/rust/pull/44026 1968 [#44027]: https://github.com/rust-lang/rust/pull/44027 1969 "##, 1970 }, 1971 Lint { 1972 label: "doc_notable_trait", 1973 description: r##"# `doc_notable_trait` 1974 1975 The tracking issue for this feature is: [#45040] 1976 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. 1982 1983 You can do this on your own traits like so: 1984 1985 ``` 1986 #![feature(doc_notable_trait)] 1987 1988 #[doc(notable_trait)] 1989 pub trait MyTrait {} 1990 1991 pub struct MyStruct; 1992 impl MyTrait for MyStruct {} 1993 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 } 1997 ``` 1998 1999 This feature was originally implemented in PR [#45039]. 2000 2001 See also its documentation in [the rustdoc book][rustdoc-book-notable_trait]. 2002 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 2006 "##, 2007 }, 2008 Lint { 2009 label: "exclusive_range_pattern", 2010 description: r##"# `exclusive_range_pattern` 2011 2012 The tracking issue for this feature is: [#37854]. 2013 2014 2015 [#67264]: https://github.com/rust-lang/rust/issues/67264 2016 [#37854]: https://github.com/rust-lang/rust/issues/37854 2017 ----- 2018 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`). 2023 2024 It also enabled RangeFrom patterns but that has since been 2025 stabilized. 2026 2027 ```rust 2028 #![feature(exclusive_range_pattern)] 2029 let x = 5; 2030 match x { 2031 0..10 => println!("single digit"), 2032 10 => println!("ten isn't part of the above range"), 2033 _ => println!("nor is everything else.") 2034 } 2035 ``` 2036 "##, 2037 }, 2038 Lint { 2039 label: "explicit_generic_args_with_impl_trait", 2040 description: r##"# `explicit_generic_args_with_impl_trait` 2041 2042 The tracking issue for this feature is: [#83701] 2043 2044 [#83701]: https://github.com/rust-lang/rust/issues/83701 2045 2046 ------------------------ 2047 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. 2050 2051 A simple example is: 2052 2053 ```rust 2054 #![feature(explicit_generic_args_with_impl_trait)] 2055 2056 fn foo<T: ?Sized>(_f: impl AsRef<T>) {} 2057 2058 fn main() { 2059 foo::<str>("".to_string()); 2060 } 2061 ``` 2062 2063 This is currently rejected: 2064 2065 ```text 2066 error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position 2067 --> src/main.rs:6:11 2068 | 2069 6 | foo::<str>("".to_string()); 2070 | ^^^ explicit generic argument not allowed 2071 2072 ``` 2073 2074 However it would compile if `explicit_generic_args_with_impl_trait` is enabled. 2075 2076 Note that the synthetic type parameters from `impl Trait` are still implicit and you 2077 cannot explicitly specify these: 2078 2079 ```rust,compile_fail 2080 #![feature(explicit_generic_args_with_impl_trait)] 2081 2082 fn foo<T: ?Sized>(_f: impl AsRef<T>) {} 2083 fn bar<T: ?Sized, F: AsRef<T>>(_f: F) {} 2084 2085 fn main() { 2086 bar::<str, _>("".to_string()); // Okay 2087 bar::<str, String>("".to_string()); // Okay 2088 2089 foo::<str>("".to_string()); // Okay 2090 foo::<str, String>("".to_string()); // Error, you cannot specify `impl Trait` explicitly 2091 } 2092 ``` 2093 "##, 2094 }, 2095 Lint { 2096 label: "fd", 2097 description: r##"# `fd` 2098 2099 This feature is internal to the Rust compiler and is not intended for general use. 2100 2101 ------------------------ 2102 "##, 2103 }, 2104 Lint { 2105 label: "fd_read", 2106 description: r##"# `fd_read` 2107 2108 This feature is internal to the Rust compiler and is not intended for general use. 2109 2110 ------------------------ 2111 "##, 2112 }, 2113 Lint { 2114 label: "ffi_const", 2115 description: r##"# `ffi_const` 2116 2117 The tracking issue for this feature is: [#58328] 2118 2119 ------ 2120 2121 The `#[ffi_const]` attribute applies clang's `const` attribute to foreign 2122 functions declarations. 2123 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. 2127 2128 Applying the `#[ffi_const]` attribute to a function that violates these 2129 requirements is undefined behaviour. 2130 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]` 2135 functions). 2136 2137 ## Pitfalls 2138 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. 2143 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. 2147 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]`. 2150 2151 A `#[ffi_const]` function must not diverge, neither via a side effect (e.g. a 2152 call to `abort`) nor by infinite loops. 2153 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]`. 2162 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 2167 "##, 2168 }, 2169 Lint { 2170 label: "ffi_pure", 2171 description: r##"# `ffi_pure` 2172 2173 The tracking issue for this feature is: [#58329] 2174 2175 ------ 2176 2177 The `#[ffi_pure]` attribute applies clang's `pure` attribute to foreign 2178 functions declarations. 2179 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. 2183 2184 Applying the `#[ffi_pure]` attribute to a function that violates these 2185 requirements is undefined behavior. 2186 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`. 2190 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. 2196 2197 ## Pitfalls 2198 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]` 2202 functions. 2203 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. 2206 2207 A `pure` function that returns unit has no effect on the abstract machine's 2208 state. 2209 2210 A `#[ffi_pure]` function must not diverge, neither via a side effect (e.g. a 2211 call to `abort`) nor by infinite loops. 2212 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]`. 2221 2222 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 2227 "##, 2228 }, 2229 Lint { 2230 label: "flt2dec", 2231 description: r##"# `flt2dec` 2232 2233 This feature is internal to the Rust compiler and is not intended for general use. 2234 2235 ------------------------ 2236 "##, 2237 }, 2238 Lint { 2239 label: "fmt_internals", 2240 description: r##"# `fmt_internals` 2241 2242 This feature is internal to the Rust compiler and is not intended for general use. 2243 2244 ------------------------ 2245 "##, 2246 }, 2247 Lint { 2248 label: "fn_traits", 2249 description: r##"# `fn_traits` 2250 2251 The tracking issue for this feature is [#29625] 2252 2253 See Also: [`unboxed_closures`](../language-features/unboxed-closures.md) 2254 2255 [#29625]: https://github.com/rust-lang/rust/issues/29625 2256 2257 ---- 2258 2259 The `fn_traits` feature allows for implementation of the [`Fn*`] traits 2260 for creating custom closure-like types. 2261 2262 [`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html 2263 2264 ```rust 2265 #![feature(unboxed_closures)] 2266 #![feature(fn_traits)] 2267 2268 struct Adder { 2269 a: u32 2270 } 2271 2272 impl FnOnce<(u32, )> for Adder { 2273 type Output = u32; 2274 extern "rust-call" fn call_once(self, b: (u32, )) -> Self::Output { 2275 self.a + b.0 2276 } 2277 } 2278 2279 fn main() { 2280 let adder = Adder { a: 3 }; 2281 assert_eq!(adder(2), 5); 2282 } 2283 ``` 2284 "##, 2285 }, 2286 Lint { 2287 label: "generators", 2288 description: r##"# `generators` 2289 2290 The tracking issue for this feature is: [#43122] 2291 2292 [#43122]: https://github.com/rust-lang/rust/issues/43122 2293 2294 ------------------------ 2295 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. 2303 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. 2310 2311 [RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033 2312 2313 A syntactical example of a generator is: 2314 2315 ```rust 2316 #![feature(generators, generator_trait)] 2317 2318 use std::ops::{Generator, GeneratorState}; 2319 use std::pin::Pin; 2320 2321 fn main() { 2322 let mut generator = || { 2323 yield 1; 2324 return "foo" 2325 }; 2326 2327 match Pin::new(&mut generator).resume(()) { 2328 GeneratorState::Yielded(1) => {} 2329 _ => panic!("unexpected value from resume"), 2330 } 2331 match Pin::new(&mut generator).resume(()) { 2332 GeneratorState::Complete("foo") => {} 2333 _ => panic!("unexpected value from resume"), 2334 } 2335 } 2336 ``` 2337 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. 2343 2344 An example of the control flow of generators is that the following example 2345 prints all numbers in order: 2346 2347 ```rust 2348 #![feature(generators, generator_trait)] 2349 2350 use std::ops::Generator; 2351 use std::pin::Pin; 2352 2353 fn main() { 2354 let mut generator = || { 2355 println!("2"); 2356 yield; 2357 println!("4"); 2358 }; 2359 2360 println!("1"); 2361 Pin::new(&mut generator).resume(()); 2362 println!("3"); 2363 Pin::new(&mut generator).resume(()); 2364 println!("5"); 2365 } 2366 ``` 2367 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! 2372 2373 ### The `Generator` trait 2374 2375 The `Generator` trait in `std::ops` currently looks like: 2376 2377 ```rust 2378 # #![feature(arbitrary_self_types, generator_trait)] 2379 # use std::ops::GeneratorState; 2380 # use std::pin::Pin; 2381 2382 pub trait Generator<R = ()> { 2383 type Yield; 2384 type Return; 2385 fn resume(self: Pin<&mut Self>, resume: R) -> GeneratorState<Self::Yield, Self::Return>; 2386 } 2387 ``` 2388 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. 2394 2395 The return value of `resume`, `GeneratorState`, looks like: 2396 2397 ```rust 2398 pub enum GeneratorState<Y, R> { 2399 Yielded(Y), 2400 Complete(R), 2401 } 2402 ``` 2403 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 2408 program. 2409 2410 ### Closure-like semantics 2411 2412 The closure-like syntax for generators alludes to the fact that they also have 2413 closure-like semantics. Namely: 2414 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 2418 constructed. 2419 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. 2425 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 2429 types and such. 2430 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. 2438 2439 * Whenever a generator is dropped it will drop all captured environment 2440 variables. 2441 2442 ### Generators as state machines 2443 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. 2449 2450 Let's take a look at an example to see what's going on here: 2451 2452 ```rust 2453 #![feature(generators, generator_trait)] 2454 2455 use std::ops::Generator; 2456 use std::pin::Pin; 2457 2458 fn main() { 2459 let ret = "foo"; 2460 let mut generator = move || { 2461 yield 1; 2462 return ret 2463 }; 2464 2465 Pin::new(&mut generator).resume(()); 2466 Pin::new(&mut generator).resume(()); 2467 } 2468 ``` 2469 2470 This generator literal will compile down to something similar to: 2471 2472 ```rust 2473 #![feature(arbitrary_self_types, generators, generator_trait)] 2474 2475 use std::ops::{Generator, GeneratorState}; 2476 use std::pin::Pin; 2477 2478 fn main() { 2479 let ret = "foo"; 2480 let mut generator = { 2481 enum __Generator { 2482 Start(&'static str), 2483 Yield1(&'static str), 2484 Done, 2485 } 2486 2487 impl Generator for __Generator { 2488 type Yield = i32; 2489 type Return = &'static str; 2490 2491 fn resume(mut self: Pin<&mut Self>, resume: ()) -> GeneratorState<i32, &'static str> { 2492 use std::mem; 2493 match mem::replace(&mut *self, __Generator::Done) { 2494 __Generator::Start(s) => { 2495 *self = __Generator::Yield1(s); 2496 GeneratorState::Yielded(1) 2497 } 2498 2499 __Generator::Yield1(s) => { 2500 *self = __Generator::Done; 2501 GeneratorState::Complete(s) 2502 } 2503 2504 __Generator::Done => { 2505 panic!("generator resumed after completion") 2506 } 2507 } 2508 } 2509 } 2510 2511 __Generator::Start(ret) 2512 }; 2513 2514 Pin::new(&mut generator).resume(()); 2515 Pin::new(&mut generator).resume(()); 2516 } 2517 ``` 2518 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. 2524 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` 2528 state. 2529 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 2533 does. 2534 "##, 2535 }, 2536 Lint { 2537 label: "half_open_range_patterns", 2538 description: r##"# `half_open_range_patterns` 2539 2540 The tracking issue for this feature is: [#67264] 2541 It is part of the `#![exclusive_range_pattern]` feature, 2542 tracked at [#37854]. 2543 2544 [#67264]: https://github.com/rust-lang/rust/issues/67264 2545 [#37854]: https://github.com/rust-lang/rust/issues/37854 2546 ----- 2547 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. 2551 2552 It also enabled RangeFrom patterns but that has since been 2553 stabilized. 2554 2555 ```rust 2556 #![feature(half_open_range_patterns)] 2557 #![feature(exclusive_range_pattern)] 2558 let x = 5; 2559 match x { 2560 ..0 => println!("negative!"), // "RangeTo" pattern. Unstable. 2561 0 => println!("zero!"), 2562 1.. => println!("positive!"), // "RangeFrom" pattern. Stable. 2563 } 2564 ``` 2565 "##, 2566 }, 2567 Lint { 2568 label: "infer_static_outlives_requirements", 2569 description: r##"# `infer_static_outlives_requirements` 2570 2571 The tracking issue for this feature is: [#54185] 2572 2573 [#54185]: https://github.com/rust-lang/rust/issues/54185 2574 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. 2579 2580 Note: It is an accompanying feature to `infer_outlives_requirements`, 2581 which must be enabled to infer outlives requirements. 2582 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. 2587 2588 ```rust,ignore (pseudo-Rust) 2589 struct Foo<U> where U: 'static { // <-- currently required 2590 bar: Bar<U> 2591 } 2592 struct Bar<T: 'static> { 2593 x: T, 2594 } 2595 ``` 2596 2597 2598 ## Examples: 2599 2600 ```rust,ignore (pseudo-Rust) 2601 #![feature(infer_outlives_requirements)] 2602 #![feature(infer_static_outlives_requirements)] 2603 2604 #[rustc_outlives] 2605 // Implicitly infer U: 'static 2606 struct Foo<U> { 2607 bar: Bar<U> 2608 } 2609 struct Bar<T: 'static> { 2610 x: T, 2611 } 2612 ``` 2613 "##, 2614 }, 2615 Lint { 2616 label: "inline_const", 2617 description: r##"# `inline_const` 2618 2619 The tracking issue for this feature is: [#76001] 2620 2621 See also [`inline_const_pat`](inline-const-pat.md) 2622 2623 ------ 2624 2625 This feature allows you to use inline constant expressions. For example, you can 2626 turn this code: 2627 2628 ```rust 2629 # fn add_one(x: i32) -> i32 { x + 1 } 2630 const MY_COMPUTATION: i32 = 1 + 2 * 3 / 4; 2631 2632 fn main() { 2633 let x = add_one(MY_COMPUTATION); 2634 } 2635 ``` 2636 2637 into this code: 2638 2639 ```rust 2640 #![feature(inline_const)] 2641 2642 # fn add_one(x: i32) -> i32 { x + 1 } 2643 fn main() { 2644 let x = add_one(const { 1 + 2 * 3 / 4 }); 2645 } 2646 ``` 2647 2648 [#76001]: https://github.com/rust-lang/rust/issues/76001 2649 "##, 2650 }, 2651 Lint { 2652 label: "inline_const_pat", 2653 description: r##"# `inline_const_pat` 2654 2655 The tracking issue for this feature is: [#76001] 2656 2657 See also [`inline_const`](inline-const.md) 2658 2659 ------ 2660 2661 This feature allows you to use inline constant expressions in pattern position: 2662 2663 ```rust 2664 #![feature(inline_const_pat)] 2665 2666 const fn one() -> i32 { 1 } 2667 2668 let some_int = 3; 2669 match some_int { 2670 const { 1 + 2 } => println!("Matched 1 + 2"), 2671 const { one() } => println!("Matched const fn returning 1"), 2672 _ => println!("Didn't match anything :("), 2673 } 2674 ``` 2675 2676 [#76001]: https://github.com/rust-lang/rust/issues/76001 2677 "##, 2678 }, 2679 Lint { 2680 label: "int_error_internals", 2681 description: r##"# `int_error_internals` 2682 2683 This feature is internal to the Rust compiler and is not intended for general use. 2684 2685 ------------------------ 2686 "##, 2687 }, 2688 Lint { 2689 label: "internal_output_capture", 2690 description: r##"# `internal_output_capture` 2691 2692 This feature is internal to the Rust compiler and is not intended for general use. 2693 2694 ------------------------ 2695 "##, 2696 }, 2697 Lint { 2698 label: "intra_doc_pointers", 2699 description: r##"# `intra-doc-pointers` 2700 2701 The tracking issue for this feature is: [#80896] 2702 2703 [#80896]: https://github.com/rust-lang/rust/issues/80896 2704 2705 ------------------------ 2706 2707 Rustdoc does not currently allow disambiguating between `*const` and `*mut`, and 2708 raw pointers in intra-doc links are unstable until it does. 2709 2710 ```rust 2711 #![feature(intra_doc_pointers)] 2712 //! [pointer::add] 2713 ``` 2714 "##, 2715 }, 2716 Lint { 2717 label: "intrinsics", 2718 description: r##"# `intrinsics` 2719 2720 The tracking issue for this feature is: None. 2721 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. 2725 2726 ------------------------ 2727 2728 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 2734 2735 ```rust 2736 #![feature(intrinsics)] 2737 # fn main() {} 2738 2739 extern "rust-intrinsic" { 2740 fn transmute<T, U>(x: T) -> U; 2741 2742 fn offset<T>(dst: *const T, offset: isize) -> *const T; 2743 } 2744 ``` 2745 2746 As with any other FFI functions, these are always `unsafe` to call. 2747 "##, 2748 }, 2749 Lint { 2750 label: "is_sorted", 2751 description: r##"# `is_sorted` 2752 2753 The tracking issue for this feature is: [#53485] 2754 2755 [#53485]: https://github.com/rust-lang/rust/issues/53485 2756 2757 ------------------------ 2758 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 2761 `Iterator`. 2762 "##, 2763 }, 2764 Lint { 2765 label: "lang_items", 2766 description: r##"# `lang_items` 2767 2768 The tracking issue for this feature is: None. 2769 2770 ------------------------ 2771 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 2777 items'. 2778 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`: 2782 2783 ```rust,ignore (libc-is-finicky) 2784 #![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)] 2785 #![no_std] 2786 use core::intrinsics; 2787 use core::panic::PanicInfo; 2788 2789 extern crate libc; 2790 2791 #[lang = "owned_box"] 2792 pub struct Box<T>(*mut T); 2793 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; 2797 2798 // Check if `malloc` failed: 2799 if p as usize == 0 { 2800 intrinsics::abort(); 2801 } 2802 2803 p 2804 } 2805 2806 #[lang = "box_free"] 2807 unsafe fn box_free<T: ?Sized>(ptr: *mut T) { 2808 libc::free(ptr as *mut libc::c_void) 2809 } 2810 2811 #[start] 2812 fn main(_argc: isize, _argv: *const *const u8) -> isize { 2813 let _x = box 1; 2814 2815 0 2816 } 2817 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 () {} 2822 ``` 2823 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. 2826 2827 Other features provided by lang items include: 2828 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. 2840 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. 2845 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. 2850 2851 ### Using libc 2852 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: 2855 2856 ```toml 2857 [dependencies] 2858 libc = { version = "0.2.14", default-features = false } 2859 ``` 2860 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 2863 disabled.** 2864 2865 ### Writing an executable without stdlib 2866 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. 2869 2870 The function marked `#[start]` is passed the command line parameters 2871 in the same format as C: 2872 2873 ```rust,ignore (libc-is-finicky) 2874 #![feature(lang_items, core_intrinsics, rustc_private)] 2875 #![feature(start)] 2876 #![no_std] 2877 use core::intrinsics; 2878 use core::panic::PanicInfo; 2879 2880 // Pull in the system libc library for what crt0.o likely requires. 2881 extern crate libc; 2882 2883 // Entry point for this program. 2884 #[start] 2885 fn start(_argc: isize, _argv: *const *const u8) -> isize { 2886 0 2887 } 2888 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"] 2893 #[no_mangle] 2894 pub extern fn rust_eh_personality() { 2895 } 2896 2897 #[lang = "panic_impl"] 2898 #[no_mangle] 2899 pub extern fn rust_begin_panic(info: &PanicInfo) -> ! { 2900 unsafe { intrinsics::abort() } 2901 } 2902 ``` 2903 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: 2908 2909 ```rust,ignore (libc-is-finicky) 2910 #![feature(lang_items, core_intrinsics, rustc_private)] 2911 #![feature(start)] 2912 #![no_std] 2913 #![no_main] 2914 use core::intrinsics; 2915 use core::panic::PanicInfo; 2916 2917 // Pull in the system libc library for what crt0.o likely requires. 2918 extern crate libc; 2919 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 { 2923 0 2924 } 2925 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"] 2930 #[no_mangle] 2931 pub extern fn rust_eh_personality() { 2932 } 2933 2934 #[lang = "panic_impl"] 2935 #[no_mangle] 2936 pub extern fn rust_begin_panic(info: &PanicInfo) -> ! { 2937 unsafe { intrinsics::abort() } 2938 } 2939 ``` 2940 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'```". 2944 2945 ## More about the language items 2946 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. 2952 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`. 2958 2959 [unwind]: https://github.com/rust-lang/rust/blob/master/library/panic_unwind/src/gcc.rs 2960 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 2964 `rust_begin_panic`. 2965 2966 Finally, a `eh_catch_typeinfo` static is needed for certain targets which 2967 implement Rust panics on top of C++ exceptions. 2968 2969 ## List of all language items 2970 2971 This is a list of all language items in Rust along with where they are located in 2972 the source code. 2973 2974 - Primitives 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` 2995 - Runtime 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` 3005 - Allocations 3006 - `owned_box`: `liballoc/boxed.rs` 3007 - `exchange_malloc`: `liballoc/heap.rs` 3008 - `box_free`: `liballoc/heap.rs` 3009 - Operands 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` 3038 - Functions 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` 3044 - Other 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` 3061 "##, 3062 }, 3063 Lint { 3064 label: "libstd_sys_internals", 3065 description: r##"# `libstd_sys_internals` 3066 3067 This feature is internal to the Rust compiler and is not intended for general use. 3068 3069 ------------------------ 3070 "##, 3071 }, 3072 Lint { 3073 label: "libstd_thread_internals", 3074 description: r##"# `libstd_thread_internals` 3075 3076 This feature is internal to the Rust compiler and is not intended for general use. 3077 3078 ------------------------ 3079 "##, 3080 }, 3081 Lint { 3082 label: "link_cfg", 3083 description: r##"# `link_cfg` 3084 3085 This feature is internal to the Rust compiler and is not intended for general use. 3086 3087 ------------------------ 3088 "##, 3089 }, 3090 Lint { 3091 label: "llvm_asm", 3092 description: r##"# `llvm_asm` 3093 3094 The tracking issue for this feature is: [#70173] 3095 3096 [#70173]: https://github.com/rust-lang/rust/issues/70173 3097 3098 ------------------------ 3099 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. 3103 3104 ```rust,ignore (pseudo-code) 3105 llvm_asm!(assembly template 3106 : output operands 3107 : input operands 3108 : clobbers 3109 : options 3110 ); 3111 ``` 3112 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. 3115 3116 > **Note**: the examples here are given in x86/x86-64 assembly, but 3117 > all platforms are supported. 3118 3119 ## Assembly template 3120 3121 The `assembly template` is the only required parameter and must be a 3122 literal string (i.e. `""`) 3123 3124 ```rust 3125 #![feature(llvm_asm)] 3126 3127 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 3128 fn foo() { 3129 unsafe { 3130 llvm_asm!("NOP"); 3131 } 3132 } 3133 3134 // Other platforms: 3135 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] 3136 fn foo() { /* ... */ } 3137 3138 fn main() { 3139 // ... 3140 foo(); 3141 // ... 3142 } 3143 ``` 3144 3145 (The `feature(llvm_asm)` and `#[cfg]`s are omitted from now on.) 3146 3147 Output operands, input operands, clobbers and options are all optional 3148 but you must add the right number of `:` if you skip them: 3149 3150 ```rust 3151 # #![feature(llvm_asm)] 3152 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 3153 # fn main() { unsafe { 3154 llvm_asm!("xor %eax, %eax" 3155 : 3156 : 3157 : "eax" 3158 ); 3159 # } } 3160 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] 3161 # fn main() {} 3162 ``` 3163 3164 Whitespace also doesn't matter: 3165 3166 ```rust 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"); 3171 # } } 3172 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] 3173 # fn main() {} 3174 ``` 3175 3176 ## Operands 3177 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: 3181 3182 ```rust 3183 # #![feature(llvm_asm)] 3184 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 3185 fn add(a: i32, b: i32) -> i32 { 3186 let c: i32; 3187 unsafe { 3188 llvm_asm!("add $2, $0" 3189 : "=r"(c) 3190 : "0"(a), "r"(b) 3191 ); 3192 } 3193 c 3194 } 3195 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] 3196 # fn add(a: i32, b: i32) -> i32 { a + b } 3197 3198 fn main() { 3199 assert_eq!(add(3, 14159), 14162) 3200 } 3201 ``` 3202 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: 3208 3209 ```rust 3210 # #![feature(llvm_asm)] 3211 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 3212 # unsafe fn read_byte_in(port: u16) -> u8 { 3213 let result: u8; 3214 llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}"(port)); 3215 result 3216 # } 3217 ``` 3218 3219 ## Clobbers 3220 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 3224 stay valid. 3225 3226 ```rust 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"); 3232 # } } 3233 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] 3234 # fn main() {} 3235 ``` 3236 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. 3240 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. 3244 3245 ## Options 3246 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: 3250 3251 Current valid options are: 3252 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. 3259 3260 ```rust 3261 # #![feature(llvm_asm)] 3262 # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 3263 # fn main() { 3264 let result: i32; 3265 unsafe { 3266 llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel") 3267 } 3268 println!("eax is currently {}", result); 3269 # } 3270 # #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] 3271 # fn main() {} 3272 ``` 3273 3274 ## More Information 3275 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, 3279 constraints, etc. 3280 3281 [llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions 3282 "##, 3283 }, 3284 Lint { 3285 label: "marker_trait_attr", 3286 description: r##"# `marker_trait_attr` 3287 3288 The tracking issue for this feature is: [#29864] 3289 3290 [#29864]: https://github.com/rust-lang/rust/issues/29864 3291 3292 ------------------------ 3293 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). 3301 3302 ```rust 3303 #![feature(marker_trait_attr)] 3304 3305 #[marker] trait CheapToClone: Clone {} 3306 3307 impl<T: Copy> CheapToClone for T {} 3308 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> {} 3313 3314 fn cheap_clone<T: CheapToClone>(t: T) -> T { 3315 t.clone() 3316 } 3317 ``` 3318 3319 This is expected to replace the unstable `overlapping_marker_traits` 3320 feature, which applied to all empty traits (without needing an opt-in). 3321 "##, 3322 }, 3323 Lint { 3324 label: "more_qualified_paths", 3325 description: r##"# `more_qualified_paths` 3326 3327 The `more_qualified_paths` feature can be used in order to enable the 3328 use of qualified paths in patterns. 3329 3330 ## Example 3331 3332 ```rust 3333 #![feature(more_qualified_paths)] 3334 3335 fn main() { 3336 // destructure through a qualified path 3337 let <Foo as A>::Assoc { br } = StructStruct { br: 2 }; 3338 } 3339 3340 struct StructStruct { 3341 br: i8, 3342 } 3343 3344 struct Foo; 3345 3346 trait A { 3347 type Assoc; 3348 } 3349 3350 impl A for Foo { 3351 type Assoc = StructStruct; 3352 } 3353 ``` 3354 "##, 3355 }, 3356 Lint { 3357 label: "native_link_modifiers", 3358 description: r##"# `native_link_modifiers` 3359 3360 The tracking issue for this feature is: [#81490] 3361 3362 [#81490]: https://github.com/rust-lang/rust/issues/81490 3363 3364 ------------------------ 3365 3366 The `native_link_modifiers` feature allows you to use the `modifiers` syntax with the `#[link(..)]` attribute. 3367 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. 3369 "##, 3370 }, 3371 Lint { 3372 label: "native_link_modifiers_as_needed", 3373 description: r##"# `native_link_modifiers_as_needed` 3374 3375 The tracking issue for this feature is: [#81490] 3376 3377 [#81490]: https://github.com/rust-lang/rust/issues/81490 3378 3379 ------------------------ 3380 3381 The `native_link_modifiers_as_needed` feature allows you to use the `as-needed` modifier. 3382 3383 `as-needed` is only compatible with the `dynamic` and `framework` linking kinds. Using any other kind will result in a compiler error. 3384 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. 3386 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`). 3389 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. 3391 "##, 3392 }, 3393 Lint { 3394 label: "native_link_modifiers_bundle", 3395 description: r##"# `native_link_modifiers_bundle` 3396 3397 The tracking issue for this feature is: [#81490] 3398 3399 [#81490]: https://github.com/rust-lang/rust/issues/81490 3400 3401 ------------------------ 3402 3403 The `native_link_modifiers_bundle` feature allows you to use the `bundle` modifier. 3404 3405 Only compatible with the `static` linking kind. Using any other kind will result in a compiler error. 3406 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. 3408 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. 3410 3411 This modifier is supposed to supersede the `static-nobundle` linking kind defined by [RFC 1717](https://github.com/rust-lang/rfcs/pull/1717). 3412 3413 The default for this modifier is currently `+bundle`, but it could be changed later on some future edition boundary. 3414 "##, 3415 }, 3416 Lint { 3417 label: "native_link_modifiers_verbatim", 3418 description: r##"# `native_link_modifiers_verbatim` 3419 3420 The tracking issue for this feature is: [#81490] 3421 3422 [#81490]: https://github.com/rust-lang/rust/issues/81490 3423 3424 ------------------------ 3425 3426 The `native_link_modifiers_verbatim` feature allows you to use the `verbatim` modifier. 3427 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. 3429 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. 3433 3434 The default for this modifier is `-verbatim`. 3435 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`. 3438 "##, 3439 }, 3440 Lint { 3441 label: "native_link_modifiers_whole_archive", 3442 description: r##"# `native_link_modifiers_whole_archive` 3443 3444 The tracking issue for this feature is: [#81490] 3445 3446 [#81490]: https://github.com/rust-lang/rust/issues/81490 3447 3448 ------------------------ 3449 3450 The `native_link_modifiers_whole_archive` feature allows you to use the `whole-archive` modifier. 3451 3452 Only compatible with the `static` linking kind. Using any other kind will result in a compiler error. 3453 3454 `+whole-archive` means that the static library is linked as a whole archive without throwing any object files away. 3455 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. 3458 3459 The default for this modifier is `-whole-archive`. 3460 "##, 3461 }, 3462 Lint { 3463 label: "negative_impls", 3464 description: r##"# `negative_impls` 3465 3466 The tracking issue for this feature is [#68318]. 3467 3468 [#68318]: https://github.com/rust-lang/rust/issues/68318 3469 3470 ---- 3471 3472 With the feature gate `negative_impls`, you can write negative impls as well as positive ones: 3473 3474 ```rust 3475 #![feature(negative_impls)] 3476 trait DerefMut { } 3477 impl<T: ?Sized> !DerefMut for &T { } 3478 ``` 3479 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. 3481 3482 Negative impls have the following characteristics: 3483 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. 3487 3488 ## Semver interaction 3489 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. 3491 3492 ## Orphan and overlap rules 3493 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. 3495 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.) 3497 3498 ## Interaction with auto traits 3499 3500 Declaring a negative impl `impl !SomeAutoTrait for SomeType` for an 3501 auto-trait serves two purposes: 3502 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. 3505 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`. 3512 3513 ## Immediate uses 3514 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). 3516 3517 This serves two purposes: 3518 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. 3521 "##, 3522 }, 3523 Lint { 3524 label: "no_coverage", 3525 description: r##"# `no_coverage` 3526 3527 The tracking issue for this feature is: [#84605] 3528 3529 [#84605]: https://github.com/rust-lang/rust/issues/84605 3530 3531 --- 3532 3533 The `no_coverage` attribute can be used to selectively disable coverage 3534 instrumentation in an annotated function. This might be useful to: 3535 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. 3539 3540 ## Example 3541 3542 ```rust 3543 #![feature(no_coverage)] 3544 3545 // `foo()` will get coverage instrumentation (by default) 3546 fn foo() { 3547 // ... 3548 } 3549 3550 #[no_coverage] 3551 fn bar() { 3552 // ... 3553 } 3554 ``` 3555 "##, 3556 }, 3557 Lint { 3558 label: "no_sanitize", 3559 description: r##"# `no_sanitize` 3560 3561 The tracking issue for this feature is: [#39699] 3562 3563 [#39699]: https://github.com/rust-lang/rust/issues/39699 3564 3565 ------------------------ 3566 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. 3571 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 3576 traces. 3577 3578 ## Examples 3579 3580 ``` rust 3581 #![feature(no_sanitize)] 3582 3583 #[no_sanitize(address)] 3584 fn foo() { 3585 // ... 3586 } 3587 ``` 3588 "##, 3589 }, 3590 Lint { 3591 label: "plugin", 3592 description: r##"# `plugin` 3593 3594 The tracking issue for this feature is: [#29597] 3595 3596 [#29597]: https://github.com/rust-lang/rust/issues/29597 3597 3598 3599 This feature is part of "compiler plugins." It will often be used with the 3600 `rustc_private` feature. 3601 3602 ------------------------ 3603 3604 `rustc` can load compiler plugins, which are user-provided libraries that 3605 extend the compiler's behavior with new lint checks, etc. 3606 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. 3612 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. 3617 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 3620 of a library. 3621 3622 # Lint plugins 3623 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`. 3629 3630 ```rust,ignore (requires-stage-2) 3631 #![feature(box_syntax, rustc_private)] 3632 3633 extern crate rustc_ast; 3634 3635 // Load rustc as a plugin to get macros 3636 extern crate rustc_driver; 3637 #[macro_use] 3638 extern crate rustc_lint; 3639 #[macro_use] 3640 extern crate rustc_session; 3641 3642 use rustc_driver::plugin::Registry; 3643 use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; 3644 use rustc_ast::ast; 3645 declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); 3646 3647 declare_lint_pass!(Pass => [TEST_LINT]); 3648 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() 3654 }); 3655 } 3656 } 3657 } 3658 3659 #[no_mangle] 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); 3663 } 3664 ``` 3665 3666 Then code like 3667 3668 ```rust,ignore (requires-plugin) 3669 #![feature(plugin)] 3670 #![plugin(lint_plugin_test)] 3671 3672 fn lintme() { } 3673 ``` 3674 3675 will produce a compiler warning: 3676 3677 ```txt 3678 foo.rs:4:1: 4:16 warning: item is named 'lintme', #[warn(test_lint)] on by default 3679 foo.rs:4 fn lintme() { } 3680 ^~~~~~~~~~~~~~~ 3681 ``` 3682 3683 The components of a lint plugin are: 3684 3685 * one or more `declare_lint!` invocations, which define static `Lint` structs; 3686 3687 * a struct holding any state needed by the lint pass (here, none); 3688 3689 * a `LintPass` 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. 3693 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. 3699 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 3704 conversion. 3705 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`. 3708 "##, 3709 }, 3710 Lint { 3711 label: "print_internals", 3712 description: r##"# `print_internals` 3713 3714 This feature is internal to the Rust compiler and is not intended for general use. 3715 3716 ------------------------ 3717 "##, 3718 }, 3719 Lint { 3720 label: "profiler_runtime", 3721 description: r##"# `profiler_runtime` 3722 3723 The tracking issue for this feature is: [#42524](https://github.com/rust-lang/rust/issues/42524). 3724 3725 ------------------------ 3726 "##, 3727 }, 3728 Lint { 3729 label: "profiler_runtime_lib", 3730 description: r##"# `profiler_runtime_lib` 3731 3732 This feature is internal to the Rust compiler and is not intended for general use. 3733 3734 ------------------------ 3735 "##, 3736 }, 3737 Lint { 3738 label: "raw_dylib", 3739 description: r##"# `raw_dylib` 3740 3741 The tracking issue for this feature is: [#58713] 3742 3743 [#58713]: https://github.com/rust-lang/rust/issues/58713 3744 3745 ------------------------ 3746 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. 3749 3750 ```rust,ignore (partial-example) 3751 #![feature(raw_dylib)] 3752 3753 #[link(name="library", kind="raw-dylib")] 3754 extern { 3755 fn extern_function(x: i32); 3756 } 3757 3758 fn main() { 3759 unsafe { 3760 extern_function(14); 3761 } 3762 } 3763 ``` 3764 3765 ## Limitations 3766 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. 3770 3771 On the `i686-pc-windows-msvc` target, this feature supports only the `cdecl`, `stdcall`, `system`, and `fastcall` 3772 calling conventions. 3773 "##, 3774 }, 3775 Lint { 3776 label: "repr128", 3777 description: r##"# `repr128` 3778 3779 The tracking issue for this feature is: [#56071] 3780 3781 [#56071]: https://github.com/rust-lang/rust/issues/56071 3782 3783 ------------------------ 3784 3785 The `repr128` feature adds support for `#[repr(u128)]` on `enum`s. 3786 3787 ```rust 3788 #![feature(repr128)] 3789 3790 #[repr(u128)] 3791 enum Foo { 3792 Bar(u64), 3793 } 3794 ``` 3795 "##, 3796 }, 3797 Lint { 3798 label: "rt", 3799 description: r##"# `rt` 3800 3801 This feature is internal to the Rust compiler and is not intended for general use. 3802 3803 ------------------------ 3804 "##, 3805 }, 3806 Lint { 3807 label: "rustc_attrs", 3808 description: r##"# `rustc_attrs` 3809 3810 This feature has no tracking issue, and is therefore internal to 3811 the compiler, not being intended for general use. 3812 3813 Note: `rustc_attrs` enables many rustc-internal attributes and this page 3814 only discuss a few of them. 3815 3816 ------------------------ 3817 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. 3822 3823 Options provided by `#[rustc_layout(...)]` are `debug`, `size`, `align`, 3824 `abi`. Note that it only works on sized types without generics. 3825 3826 ## Examples 3827 3828 ```rust,compile_fail 3829 #![feature(rustc_attrs)] 3830 3831 #[rustc_layout(abi, size)] 3832 pub enum X { 3833 Y(u8, u8, u8), 3834 Z(isize), 3835 } 3836 ``` 3837 3838 When that is compiled, the compiler will error with something like 3839 3840 ```text 3841 error: abi: Aggregate { sized: true } 3842 --> src/lib.rs:4:1 3843 | 3844 4 | / pub enum T { 3845 5 | | Y(u8, u8, u8), 3846 6 | | Z(isize), 3847 7 | | } 3848 | |_^ 3849 3850 error: size: Size { raw: 16 } 3851 --> src/lib.rs:4:1 3852 | 3853 4 | / pub enum T { 3854 5 | | Y(u8, u8, u8), 3855 6 | | Z(isize), 3856 7 | | } 3857 | |_^ 3858 3859 error: aborting due to 2 previous errors 3860 ``` 3861 "##, 3862 }, 3863 Lint { 3864 label: "sort_internals", 3865 description: r##"# `sort_internals` 3866 3867 This feature is internal to the Rust compiler and is not intended for general use. 3868 3869 ------------------------ 3870 "##, 3871 }, 3872 Lint { 3873 label: "str_internals", 3874 description: r##"# `str_internals` 3875 3876 This feature is internal to the Rust compiler and is not intended for general use. 3877 3878 ------------------------ 3879 "##, 3880 }, 3881 Lint { 3882 label: "test", 3883 description: r##"# `test` 3884 3885 The tracking issue for this feature is: None. 3886 3887 ------------------------ 3888 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 3892 (comments elided): 3893 3894 ```rust,no_run 3895 #![feature(test)] 3896 3897 extern crate test; 3898 3899 pub fn add_two(a: i32) -> i32 { 3900 a + 2 3901 } 3902 3903 #[cfg(test)] 3904 mod tests { 3905 use super::*; 3906 use test::Bencher; 3907 3908 #[test] 3909 fn it_works() { 3910 assert_eq!(4, add_two(2)); 3911 } 3912 3913 #[bench] 3914 fn bench_add_two(b: &mut Bencher) { 3915 b.iter(|| add_two(2)); 3916 } 3917 } 3918 ``` 3919 3920 Note the `test` feature gate, which enables this unstable feature. 3921 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. 3927 3928 We can run benchmark tests with `cargo bench`: 3929 3930 ```bash 3931 $ cargo bench 3932 Compiling adder v0.0.1 (file:///home/steve/tmp/adder) 3933 Running target/release/adder-91b3e234d4ed382a 3934 3935 running 2 tests 3936 test tests::it_works ... ignored 3937 test tests::bench_add_two ... bench: 1 ns/iter (+/- 0) 3938 3939 test result: ok. 0 passed; 0 failed; 1 ignored; 1 measured 3940 ``` 3941 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. 3947 3948 Advice on writing benchmarks: 3949 3950 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 3954 it many times 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) 3959 3960 ## Gotcha: optimizations 3961 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 3966 remove it entirely. 3967 3968 ```rust,no_run 3969 #![feature(test)] 3970 3971 extern crate test; 3972 use test::Bencher; 3973 3974 #[bench] 3975 fn bench_xor_1000_ints(b: &mut Bencher) { 3976 b.iter(|| { 3977 (0..1000).fold(0, |old, new| old ^ new); 3978 }); 3979 } 3980 ``` 3981 3982 gives the following results 3983 3984 ```text 3985 running 1 test 3986 test bench_xor_1000_ints ... bench: 0 ns/iter (+/- 0) 3987 3988 test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured 3989 ``` 3990 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 3995 `b.iter` call to 3996 3997 ```rust 3998 # struct X; 3999 # impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X; 4000 b.iter(|| { 4001 // Note lack of `;` (could also use an explicit `return`). 4002 (0..1000).fold(0, |old, new| old ^ new) 4003 }); 4004 ``` 4005 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 4008 argument as used. 4009 4010 ```rust 4011 #![feature(test)] 4012 4013 extern crate test; 4014 4015 # fn main() { 4016 # struct X; 4017 # impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X; 4018 b.iter(|| { 4019 let n = test::black_box(1000); 4020 4021 (0..n).fold(0, |a, b| a ^ b) 4022 }) 4023 # } 4024 ``` 4025 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)`). 4029 4030 Performing either of the above changes gives the following benchmarking results 4031 4032 ```text 4033 running 1 test 4034 test bench_xor_1000_ints ... bench: 131 ns/iter (+/- 3) 4035 4036 test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured 4037 ``` 4038 4039 However, the optimizer can still modify a testcase in an undesirable manner 4040 even when using either of the above. 4041 "##, 4042 }, 4043 Lint { 4044 label: "thread_local_internals", 4045 description: r##"# `thread_local_internals` 4046 4047 This feature is internal to the Rust compiler and is not intended for general use. 4048 4049 ------------------------ 4050 "##, 4051 }, 4052 Lint { 4053 label: "trace_macros", 4054 description: r##"# `trace_macros` 4055 4056 The tracking issue for this feature is [#29598]. 4057 4058 [#29598]: https://github.com/rust-lang/rust/issues/29598 4059 4060 ------------------------ 4061 4062 With `trace_macros` you can trace the expansion of macros in your code. 4063 4064 ## Examples 4065 4066 ```rust 4067 #![feature(trace_macros)] 4068 4069 fn main() { 4070 trace_macros!(true); 4071 println!("Hello, Rust!"); 4072 trace_macros!(false); 4073 } 4074 ``` 4075 4076 The `cargo build` output: 4077 4078 ```txt 4079 note: trace_macro 4080 --> src/main.rs:5:5 4081 | 4082 5 | println!("Hello, Rust!"); 4083 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 4084 | 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" ) ) 4089 )` 4090 4091 Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs 4092 ``` 4093 "##, 4094 }, 4095 Lint { 4096 label: "trait_alias", 4097 description: r##"# `trait_alias` 4098 4099 The tracking issue for this feature is: [#41517] 4100 4101 [#41517]: https://github.com/rust-lang/rust/issues/41517 4102 4103 ------------------------ 4104 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. 4109 4110 ```rust 4111 #![feature(trait_alias)] 4112 4113 trait Foo = std::fmt::Debug + Send; 4114 trait Bar = Foo + Sync; 4115 4116 // Use trait alias as bound on type parameter. 4117 fn foo<T: Foo>(v: &T) { 4118 println!("{:?}", v); 4119 } 4120 4121 pub fn main() { 4122 foo(&1); 4123 4124 // Use trait alias for trait objects. 4125 let a: &Bar = &123; 4126 println!("{:?}", a); 4127 let b = Box::new(456) as Box<dyn Foo>; 4128 println!("{:?}", b); 4129 } 4130 ``` 4131 "##, 4132 }, 4133 Lint { 4134 label: "trait_upcasting", 4135 description: r##"# `trait_upcasting` 4136 4137 The tracking issue for this feature is: [#65991] 4138 4139 [#65991]: https://github.com/rust-lang/rust/issues/65991 4140 4141 ------------------------ 4142 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`. 4146 4147 ```rust,edition2018 4148 #![feature(trait_upcasting)] 4149 #![allow(incomplete_features)] 4150 4151 trait Foo {} 4152 4153 trait Bar: Foo {} 4154 4155 impl Foo for i32 {} 4156 4157 impl<T: Foo + ?Sized> Bar for T {} 4158 4159 let bar: &dyn Bar = &123; 4160 let foo: &dyn Foo = bar; 4161 ``` 4162 "##, 4163 }, 4164 Lint { 4165 label: "transparent_unions", 4166 description: r##"# `transparent_unions` 4167 4168 The tracking issue for this feature is [#60405] 4169 4170 [#60405]: https://github.com/rust-lang/rust/issues/60405 4171 4172 ---- 4173 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. 4179 4180 ```rust 4181 #![feature(transparent_unions)] 4182 4183 // This union has the same representation as `f32`. 4184 #[repr(transparent)] 4185 union SingleFieldUnion { 4186 field: f32, 4187 } 4188 4189 // This union has the same representation as `usize`. 4190 #[repr(transparent)] 4191 union MultiFieldUnion { 4192 field: usize, 4193 nothing: (), 4194 } 4195 ``` 4196 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)]`: 4200 4201 ```rust 4202 #![feature(transparent_unions)] 4203 4204 // This (non-transparent) union is already valid in stable Rust: 4205 pub union GoodUnion { 4206 pub nothing: (), 4207 } 4208 4209 // Error: transparent union needs exactly one non-zero-sized field, but has 0 4210 // #[repr(transparent)] 4211 // pub union BadUnion { 4212 // pub nothing: (), 4213 // } 4214 ``` 4215 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: 4218 4219 ```rust 4220 #![feature(transparent_unions)] 4221 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. 4225 pub field: T, 4226 pub nothing: (), 4227 } 4228 4229 // This is okay even though `()` is a zero-sized type. 4230 pub const THIS_IS_OKAY: GenericUnion<()> = GenericUnion { field: () }; 4231 ``` 4232 4233 Like transparent `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). 4237 4238 Like transparent `struct`s, transparent `union`s are FFI-safe if and only if 4239 their underlying representation type is also FFI-safe. 4240 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. 4249 "##, 4250 }, 4251 Lint { 4252 label: "try_blocks", 4253 description: r##"# `try_blocks` 4254 4255 The tracking issue for this feature is: [#31436] 4256 4257 [#31436]: https://github.com/rust-lang/rust/issues/31436 4258 4259 ------------------------ 4260 4261 The `try_blocks` feature adds support for `try` blocks. A `try` 4262 block creates a new scope one can use the `?` operator in. 4263 4264 ```rust,edition2018 4265 #![feature(try_blocks)] 4266 4267 use std::num::ParseIntError; 4268 4269 let result: Result<i32, ParseIntError> = try { 4270 "1".parse::<i32>()? 4271 + "2".parse::<i32>()? 4272 + "3".parse::<i32>()? 4273 }; 4274 assert_eq!(result, Ok(6)); 4275 4276 let result: Result<i32, ParseIntError> = try { 4277 "1".parse::<i32>()? 4278 + "foo".parse::<i32>()? 4279 + "3".parse::<i32>()? 4280 }; 4281 assert!(result.is_err()); 4282 ``` 4283 "##, 4284 }, 4285 Lint { 4286 label: "type_changing_struct_update", 4287 description: r##"# `type_changing_struct_update` 4288 4289 The tracking issue for this feature is: [#86555] 4290 4291 [#86555]: https://github.com/rust-lang/rust/issues/86555 4292 4293 ------------------------ 4294 4295 This implements [RFC2528]. When turned on, you can create instances of the same struct 4296 that have different generic type or lifetime parameters. 4297 4298 [RFC2528]: https://github.com/rust-lang/rfcs/blob/master/text/2528-type-changing-struct-update-syntax.md 4299 4300 ```rust 4301 #![allow(unused_variables, dead_code)] 4302 #![feature(type_changing_struct_update)] 4303 4304 fn main () { 4305 struct Foo<T, U> { 4306 field1: T, 4307 field2: U, 4308 } 4309 4310 let base: Foo<String, i32> = Foo { 4311 field1: String::from("hello"), 4312 field2: 1234, 4313 }; 4314 let updated: Foo<f64, i32> = Foo { 4315 field1: 3.14, 4316 ..base 4317 }; 4318 } 4319 ``` 4320 "##, 4321 }, 4322 Lint { 4323 label: "unboxed_closures", 4324 description: r##"# `unboxed_closures` 4325 4326 The tracking issue for this feature is [#29625] 4327 4328 See Also: [`fn_traits`](../library-features/fn-traits.md) 4329 4330 [#29625]: https://github.com/rust-lang/rust/issues/29625 4331 4332 ---- 4333 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. 4337 4338 [`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html 4339 4340 ```rust 4341 #![feature(unboxed_closures)] 4342 4343 extern "rust-call" fn add_args(args: (u32, u32)) -> u32 { 4344 args.0 + args.1 4345 } 4346 4347 fn main() {} 4348 ``` 4349 "##, 4350 }, 4351 Lint { 4352 label: "unsized_locals", 4353 description: r##"# `unsized_locals` 4354 4355 The tracking issue for this feature is: [#48055] 4356 4357 [#48055]: https://github.com/rust-lang/rust/issues/48055 4358 4359 ------------------------ 4360 4361 This implements [RFC1909]. When turned on, you can have unsized arguments and locals: 4362 4363 [RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md 4364 4365 ```rust 4366 #![allow(incomplete_features)] 4367 #![feature(unsized_locals, unsized_fn_params)] 4368 4369 use std::any::Any; 4370 4371 fn main() { 4372 let x: Box<dyn Any> = Box::new(42); 4373 let x: dyn Any = *x; 4374 // ^ unsized local variable 4375 // ^^ unsized temporary 4376 foo(x); 4377 } 4378 4379 fn foo(_: dyn Any) {} 4380 // ^^^^^^ unsized argument 4381 ``` 4382 4383 The RFC still forbids the following unsized expressions: 4384 4385 ```rust,compile_fail 4386 #![feature(unsized_locals)] 4387 4388 use std::any::Any; 4389 4390 struct MyStruct<T: ?Sized> { 4391 content: T, 4392 } 4393 4394 struct MyTupleStruct<T: ?Sized>(T); 4395 4396 fn answer() -> Box<dyn Any> { 4397 Box::new(42) 4398 } 4399 4400 fn main() { 4401 // You CANNOT have unsized statics. 4402 static X: dyn Any = *answer(); // ERROR 4403 const Y: dyn Any = *answer(); // ERROR 4404 4405 // You CANNOT have struct initialized unsized. 4406 MyStruct { content: *answer() }; // ERROR 4407 MyTupleStruct(*answer()); // ERROR 4408 (42, *answer()); // ERROR 4409 4410 // You CANNOT have unsized return types. 4411 fn my_function() -> dyn Any { *answer() } // ERROR 4412 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 4417 4418 // You CANNOT even initialize them separately. 4419 let y: dyn Any; // OK 4420 y = *answer(); // ERROR 4421 4422 // Not mentioned in the RFC, but by-move captured variables are also Sized. 4423 let x: dyn Any = *answer(); 4424 (move || { // ERROR 4425 let y = x; 4426 })(); 4427 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 4433 } 4434 ``` 4435 4436 ## By-value trait objects 4437 4438 With this feature, you can have by-value `self` arguments without `Self: Sized` bounds. 4439 4440 ```rust 4441 #![feature(unsized_fn_params)] 4442 4443 trait Foo { 4444 fn foo(self) {} 4445 } 4446 4447 impl<T: ?Sized> Foo for T {} 4448 4449 fn main() { 4450 let slice: Box<[i32]> = Box::new([1, 2, 3]); 4451 <[i32] as Foo>::foo(*slice); 4452 } 4453 ``` 4454 4455 And `Foo` will also be object-safe. 4456 4457 ```rust 4458 #![feature(unsized_fn_params)] 4459 4460 trait Foo { 4461 fn foo(self) {} 4462 } 4463 4464 impl<T: ?Sized> Foo for T {} 4465 4466 fn main () { 4467 let slice: Box<dyn Foo> = Box::new([1, 2, 3]); 4468 // doesn't compile yet 4469 <dyn Foo as Foo>::foo(*slice); 4470 } 4471 ``` 4472 4473 One of the objectives of this feature is to allow `Box<dyn FnOnce>`. 4474 4475 ## Variable length arrays 4476 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]`. 4478 4479 ```rust,ignore (not-yet-implemented) 4480 #![feature(unsized_locals)] 4481 4482 fn mergesort<T: Ord>(a: &mut [T]) { 4483 let mut tmp = [T; dyn a.len()]; 4484 // ... 4485 } 4486 4487 fn main() { 4488 let mut a = [3, 1, 5, 6]; 4489 mergesort(&mut a); 4490 assert_eq!(a, [1, 3, 5, 6]); 4491 } 4492 ``` 4493 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]`. 4495 4496 ## Advisory on stack usage 4497 4498 It's advised not to casually use the `#![feature(unsized_locals)]` feature. Typical use-cases are: 4499 4500 - When you need a by-value trait objects. 4501 - When you really need a fast allocation of small temporary arrays. 4502 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 4504 4505 ```rust 4506 #![feature(unsized_locals)] 4507 4508 fn main() { 4509 let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]); 4510 let _x = {{{{{{{{{{*x}}}}}}}}}}; 4511 } 4512 ``` 4513 4514 and the code 4515 4516 ```rust 4517 #![feature(unsized_locals)] 4518 4519 fn main() { 4520 for _ in 0..10 { 4521 let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]); 4522 let _x = *x; 4523 } 4524 } 4525 ``` 4526 4527 will unnecessarily extend the stack frame. 4528 "##, 4529 }, 4530 Lint { 4531 label: "unsized_tuple_coercion", 4532 description: r##"# `unsized_tuple_coercion` 4533 4534 The tracking issue for this feature is: [#42877] 4535 4536 [#42877]: https://github.com/rust-lang/rust/issues/42877 4537 4538 ------------------------ 4539 4540 This is a part of [RFC0401]. According to the RFC, there should be an implementation like this: 4541 4542 ```rust,ignore (partial-example) 4543 impl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized<U> {} 4544 ``` 4545 4546 This implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this: 4547 4548 ```rust 4549 #![feature(unsized_tuple_coercion)] 4550 4551 fn main() { 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); 4555 } 4556 ``` 4557 4558 [RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md 4559 "##, 4560 }, 4561 Lint { 4562 label: "update_panic_count", 4563 description: r##"# `update_panic_count` 4564 4565 This feature is internal to the Rust compiler and is not intended for general use. 4566 4567 ------------------------ 4568 "##, 4569 }, 4570 Lint { 4571 label: "windows_c", 4572 description: r##"# `windows_c` 4573 4574 This feature is internal to the Rust compiler and is not intended for general use. 4575 4576 ------------------------ 4577 "##, 4578 }, 4579 Lint { 4580 label: "windows_handle", 4581 description: r##"# `windows_handle` 4582 4583 This feature is internal to the Rust compiler and is not intended for general use. 4584 4585 ------------------------ 4586 "##, 4587 }, 4588 Lint { 4589 label: "windows_net", 4590 description: r##"# `windows_net` 4591 4592 This feature is internal to the Rust compiler and is not intended for general use. 4593 4594 ------------------------ 4595 "##, 4596 }, 4597 Lint { 4598 label: "windows_stdio", 4599 description: r##"# `windows_stdio` 4600 4601 This feature is internal to the Rust compiler and is not intended for general use. 4602 4603 ------------------------ 4604 "##, 4605 }, 4606 ]; 4607 4608 pub const CLIPPY_LINTS: &[Lint] = &[ 4609 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 4614 checked."##, 4615 }, 4616 Lint { 4617 label: "clippy::almost_swapped", 4618 description: r##"Checks for `foo = bar; bar = foo` sequences."##, 4619 }, 4620 Lint { 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) 4625 or 4626 [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants), 4627 respectively, suggesting to use the predefined constant."##, 4628 }, 4629 Lint { 4630 label: "clippy::as_conversions", 4631 description: r##"Checks for usage of `as` conversions. 4632 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)."##, 4640 }, 4641 Lint { 4642 label: "clippy::assertions_on_constants", 4643 description: r##"Checks for `assert!(true)` and `assert!(false)` calls."##, 4644 }, 4645 Lint { 4646 label: "clippy::assign_op_pattern", 4647 description: r##"Checks for `a = a op b` or `a = b commutative_op a` 4648 patterns."##, 4649 }, 4650 Lint { 4651 label: "clippy::assign_ops", 4652 description: r##"Nothing. This lint has been deprecated."##, 4653 }, 4654 Lint { 4655 label: "clippy::async_yields_async", 4656 description: r##"Checks for async blocks that yield values of types 4657 that can themselves be awaited."##, 4658 }, 4659 Lint { 4660 label: "clippy::await_holding_lock", 4661 description: r##"Checks for calls to await while holding a 4662 non-async-aware MutexGuard."##, 4663 }, 4664 Lint { 4665 label: "clippy::await_holding_refcell_ref", 4666 description: r##"Checks for calls to await while holding a 4667 `RefCell` `Ref` or `RefMut`."##, 4668 }, 4669 Lint { 4670 label: "clippy::bad_bit_mask", 4671 description: r##"Checks for incompatible bit masks in comparisons. 4672 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 4676 table: 4677 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` |"##, 4686 }, 4687 Lint { 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))`."##, 4691 }, 4692 Lint { 4693 label: "clippy::blacklisted_name", 4694 description: r##"Checks for usage of blacklisted names for variables, such 4695 as `foo`."##, 4696 }, 4697 Lint { 4698 label: "clippy::blanket_clippy_restriction_lints", 4699 description: r##"Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category."##, 4700 }, 4701 Lint { 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."##, 4705 }, 4706 Lint { 4707 label: "clippy::bool_assert_comparison", 4708 description: r##"This lint warns about boolean comparisons in assert-like macros."##, 4709 }, 4710 Lint { 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."##, 4715 }, 4716 Lint { 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."##, 4720 }, 4721 Lint { 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."##, 4725 }, 4726 Lint { 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."##, 4730 }, 4731 Lint { 4732 label: "clippy::boxed_local", 4733 description: r##"Checks for usage of `Box<T>` where an unboxed `T` would 4734 work fine."##, 4735 }, 4736 Lint { 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."##, 4740 }, 4741 Lint { 4742 label: "clippy::builtin_type_shadow", 4743 description: r##"Warns if a generic shadows a built-in type."##, 4744 }, 4745 Lint { 4746 label: "clippy::bytes_nth", 4747 description: r##"Checks for the use of `.bytes().nth()`."##, 4748 }, 4749 Lint { 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"##, 4753 }, 4754 Lint { 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."##, 4758 }, 4759 Lint { 4760 label: "clippy::cast_lossless", 4761 description: r##"Checks for casts between numerical types that may 4762 be replaced by safe conversion functions."##, 4763 }, 4764 Lint { 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 4768 default."##, 4769 }, 4770 Lint { 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."##, 4778 }, 4779 Lint { 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 4784 `Allow` by default. 4785 4786 Basically, this warns on casting any integer with 32 or more bits to `f32` 4787 or any 64-bit integer to `f64`."##, 4788 }, 4789 Lint { 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"##, 4793 }, 4794 Lint { 4795 label: "clippy::cast_ref_to_mut", 4796 description: r##"Checks for casts of `&T` to `&mut T` anywhere in the code."##, 4797 }, 4798 Lint { 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."##, 4804 }, 4805 Lint { 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."##, 4809 }, 4810 Lint { 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."##, 4814 }, 4815 Lint { 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."##, 4819 }, 4820 Lint { 4821 label: "clippy::checked_conversions", 4822 description: r##"Checks for explicit bounds checking when casting."##, 4823 }, 4824 Lint { 4825 label: "clippy::clone_double_ref", 4826 description: r##"Checks for usage of `.clone()` on an `&&T`."##, 4827 }, 4828 Lint { 4829 label: "clippy::clone_on_copy", 4830 description: r##"Checks for usage of `.clone()` on a `Copy` type."##, 4831 }, 4832 Lint { 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)`)."##, 4837 }, 4838 Lint { 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."##, 4842 }, 4843 Lint { label: "clippy::cmp_nan", description: r##"Checks for comparisons to NaN."## }, 4844 Lint { 4845 label: "clippy::cmp_null", 4846 description: r##"This lint checks for equality comparisons with `ptr::null`"##, 4847 }, 4848 Lint { 4849 label: "clippy::cmp_owned", 4850 description: r##"Checks for conversions to owned values just for the sake 4851 of a comparison."##, 4852 }, 4853 Lint { 4854 label: "clippy::cognitive_complexity", 4855 description: r##"Checks for methods with high cognitive complexity."##, 4856 }, 4857 Lint { 4858 label: "clippy::collapsible_else_if", 4859 description: r##"Checks for collapsible `else { if ... }` expressions 4860 that can be collapsed to `else if ...`."##, 4861 }, 4862 Lint { 4863 label: "clippy::collapsible_if", 4864 description: r##"Checks for nested `if` statements which can be collapsed 4865 by `&&`-combining their conditions."##, 4866 }, 4867 Lint { 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. 4871 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."##, 4874 }, 4875 Lint { 4876 label: "clippy::comparison_chain", 4877 description: r##"Checks comparison chains written with `if` that can be 4878 rewritten with `match` and `cmp`."##, 4879 }, 4880 Lint { 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."##, 4884 }, 4885 Lint { 4886 label: "clippy::copy_iterator", 4887 description: r##"Checks for types that implement `Copy` as well as 4888 `Iterator`."##, 4889 }, 4890 Lint { 4891 label: "clippy::create_dir", 4892 description: r##"Checks usage of `std::fs::create_dir` and suggest using `std::fs::create_dir_all` instead."##, 4893 }, 4894 Lint { 4895 label: "clippy::crosspointer_transmute", 4896 description: r##"Checks for transmutes between a type `T` and `*T`."##, 4897 }, 4898 Lint { label: "clippy::dbg_macro", description: r##"Checks for usage of dbg!() macro."## }, 4899 Lint { 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."##, 4903 }, 4904 Lint { 4905 label: "clippy::decimal_literal_representation", 4906 description: r##"Warns if there is a better representation for a numeric literal."##, 4907 }, 4908 Lint { 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.)."##, 4912 }, 4913 Lint { 4914 label: "clippy::default_numeric_fallback", 4915 description: r##"Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type 4916 inference. 4917 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`. 4921 4922 See [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback."##, 4923 }, 4924 Lint { 4925 label: "clippy::default_trait_access", 4926 description: r##"Checks for literal calls to `Default::default()`."##, 4927 }, 4928 Lint { 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]`."##, 4932 }, 4933 Lint { 4934 label: "clippy::deprecated_semver", 4935 description: r##"Checks for `#[deprecated]` annotations with a `since` 4936 field that is not a valid semantic version."##, 4937 }, 4938 Lint { 4939 label: "clippy::deref_addrof", 4940 description: r##"Checks for usage of `*&` and `*&mut` in expressions."##, 4941 }, 4942 Lint { 4943 label: "clippy::derivable_impls", 4944 description: r##"Detects manual `std::default::Default` implementations that are identical to a derived implementation."##, 4945 }, 4946 Lint { 4947 label: "clippy::derive_hash_xor_eq", 4948 description: r##"Checks for deriving `Hash` but implementing `PartialEq` 4949 explicitly or vice versa."##, 4950 }, 4951 Lint { 4952 label: "clippy::derive_ord_xor_partial_ord", 4953 description: r##"Checks for deriving `Ord` but implementing `PartialOrd` 4954 explicitly or vice versa."##, 4955 }, 4956 Lint { 4957 label: "clippy::disallowed_methods", 4958 description: r##"Denies the configured methods and functions in clippy.toml"##, 4959 }, 4960 Lint { 4961 label: "clippy::disallowed_script_idents", 4962 description: r##"Checks for usage of unicode scripts other than those explicitly allowed 4963 by the lint config. 4964 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]. 4969 4970 See also: [`non_ascii_idents`]. 4971 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"##, 4974 }, 4975 Lint { 4976 label: "clippy::disallowed_types", 4977 description: r##"Denies the configured types in clippy.toml."##, 4978 }, 4979 Lint { 4980 label: "clippy::diverging_sub_expression", 4981 description: r##"Checks for diverging calls that are not match arms or 4982 statements."##, 4983 }, 4984 Lint { 4985 label: "clippy::doc_markdown", 4986 description: r##"Checks for the presence of `_`, `::` or camel-case words 4987 outside ticks in documentation."##, 4988 }, 4989 Lint { 4990 label: "clippy::double_comparisons", 4991 description: r##"Checks for double comparisons that could be simplified to a single expression."##, 4992 }, 4993 Lint { 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]`."##, 4998 }, 4999 Lint { 5000 label: "clippy::double_neg", 5001 description: r##"Detects expressions of the form `--x`."##, 5002 }, 5003 Lint { 5004 label: "clippy::double_parens", 5005 description: r##"Checks for unnecessary double parentheses."##, 5006 }, 5007 Lint { 5008 label: "clippy::drop_copy", 5009 description: r##"Checks for calls to `std::mem::drop` with a value 5010 that derives the Copy trait"##, 5011 }, 5012 Lint { 5013 label: "clippy::drop_ref", 5014 description: r##"Checks for calls to `std::mem::drop` with a reference 5015 instead of an owned value."##, 5016 }, 5017 Lint { 5018 label: "clippy::duplicate_underscore_argument", 5019 description: r##"Checks for function arguments having the similar names 5020 differing by an underscore."##, 5021 }, 5022 Lint { 5023 label: "clippy::duration_subsec", 5024 description: r##"Checks for calculation of subsecond microseconds or milliseconds 5025 from other `Duration` methods."##, 5026 }, 5027 Lint { 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."##, 5031 }, 5032 Lint { 5033 label: "clippy::empty_enum", 5034 description: r##"Checks for `enum`s with no variants. 5035 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."##, 5039 }, 5040 Lint { 5041 label: "clippy::empty_line_after_outer_attr", 5042 description: r##"Checks for empty lines after outer attributes"##, 5043 }, 5044 Lint { label: "clippy::empty_loop", description: r##"Checks for empty `loop` expressions."## }, 5045 Lint { 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`."##, 5049 }, 5050 Lint { label: "clippy::enum_glob_use", description: r##"Checks for `use Enum::*`."## }, 5051 Lint { 5052 label: "clippy::enum_variant_names", 5053 description: r##"Detects enumeration variants that are prefixed or suffixed 5054 by the same characters."##, 5055 }, 5056 Lint { 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 `/`)."##, 5061 }, 5062 Lint { 5063 label: "clippy::equatable_if_let", 5064 description: r##"Checks for pattern matchings that can be expressed using equality."##, 5065 }, 5066 Lint { 5067 label: "clippy::erasing_op", 5068 description: r##"Checks for erasing operations, e.g., `x * 0`."##, 5069 }, 5070 Lint { 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."##, 5075 }, 5076 Lint { 5077 label: "clippy::excessive_precision", 5078 description: r##"Checks for float literals with a precision greater 5079 than that supported by the underlying type."##, 5080 }, 5081 Lint { 5082 label: "clippy::exhaustive_enums", 5083 description: r##"Warns on any exported `enum`s that are not tagged `#[non_exhaustive]`"##, 5084 }, 5085 Lint { 5086 label: "clippy::exhaustive_structs", 5087 description: r##"Warns on any exported `structs`s that are not tagged `#[non_exhaustive]`"##, 5088 }, 5089 Lint { 5090 label: "clippy::exit", 5091 description: r##"`exit()` terminates the program and doesn't provide a 5092 stack trace."##, 5093 }, 5094 Lint { 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"##, 5098 }, 5099 Lint { 5100 label: "clippy::expect_used", 5101 description: r##"Checks for `.expect()` calls on `Option`s and `Result`s."##, 5102 }, 5103 Lint { 5104 label: "clippy::expl_impl_clone_on_copy", 5105 description: r##"Checks for explicit `Clone` implementations for `Copy` 5106 types."##, 5107 }, 5108 Lint { 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()`."##, 5112 }, 5113 Lint { 5114 label: "clippy::explicit_deref_methods", 5115 description: r##"Checks for explicit `deref()` or `deref_mut()` method calls."##, 5116 }, 5117 Lint { 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."##, 5121 }, 5122 Lint { 5123 label: "clippy::explicit_iter_loop", 5124 description: r##"Checks for loops on `x.iter()` where `&x` will do, and 5125 suggests the latter."##, 5126 }, 5127 Lint { 5128 label: "clippy::explicit_write", 5129 description: r##"Checks for usage of `write!()` / `writeln()!` which can be 5130 replaced with `(e)print!()` / `(e)println!()`"##, 5131 }, 5132 Lint { 5133 label: "clippy::extend_from_slice", 5134 description: r##"Nothing. This lint has been deprecated."##, 5135 }, 5136 Lint { 5137 label: "clippy::extend_with_drain", 5138 description: r##"Checks for occurrences where one vector gets extended instead of append"##, 5139 }, 5140 Lint { 5141 label: "clippy::extra_unused_lifetimes", 5142 description: r##"Checks for lifetimes in generics that are never used 5143 anywhere else."##, 5144 }, 5145 Lint { 5146 label: "clippy::fallible_impl_from", 5147 description: r##"Checks for impls of `From<..>` that contain `panic!()` or `unwrap()`"##, 5148 }, 5149 Lint { 5150 label: "clippy::field_reassign_with_default", 5151 description: r##"Checks for immediate reassignment of fields initialized 5152 with Default::default()."##, 5153 }, 5154 Lint { 5155 label: "clippy::filetype_is_file", 5156 description: r##"Checks for `FileType::is_file()`."##, 5157 }, 5158 Lint { 5159 label: "clippy::filter_map", 5160 description: r##"Nothing. This lint has been deprecated."##, 5161 }, 5162 Lint { 5163 label: "clippy::filter_map_identity", 5164 description: r##"Checks for usage of `filter_map(|x| x)`."##, 5165 }, 5166 Lint { 5167 label: "clippy::filter_map_next", 5168 description: r##"Checks for usage of `_.filter_map(_).next()`."##, 5169 }, 5170 Lint { 5171 label: "clippy::filter_next", 5172 description: r##"Checks for usage of `_.filter(_).next()`."##, 5173 }, 5174 Lint { label: "clippy::find_map", description: r##"Nothing. This lint has been deprecated."## }, 5175 Lint { 5176 label: "clippy::flat_map_identity", 5177 description: r##"Checks for usage of `flat_map(|x| x)`."##, 5178 }, 5179 Lint { 5180 label: "clippy::flat_map_option", 5181 description: r##"Checks for usages of `Iterator::flat_map()` where `filter_map()` could be 5182 used instead."##, 5183 }, 5184 Lint { label: "clippy::float_arithmetic", description: r##"Checks for float arithmetic."## }, 5185 Lint { 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)."##, 5190 }, 5191 Lint { 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)."##, 5196 }, 5197 Lint { 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()`."##, 5201 }, 5202 Lint { 5203 label: "clippy::fn_address_comparisons", 5204 description: r##"Checks for comparisons with an address of a function item."##, 5205 }, 5206 Lint { 5207 label: "clippy::fn_params_excessive_bools", 5208 description: r##"Checks for excessive use of 5209 bools in function definitions."##, 5210 }, 5211 Lint { 5212 label: "clippy::fn_to_numeric_cast", 5213 description: r##"Checks for casts of function pointers to something other than usize"##, 5214 }, 5215 Lint { 5216 label: "clippy::fn_to_numeric_cast_any", 5217 description: r##"Checks for casts of a function pointer to any integer type."##, 5218 }, 5219 Lint { 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 5222 store address."##, 5223 }, 5224 Lint { 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."##, 5228 }, 5229 Lint { 5230 label: "clippy::for_loops_over_fallibles", 5231 description: r##"Checks for `for` loops over `Option` or `Result` values."##, 5232 }, 5233 Lint { 5234 label: "clippy::forget_copy", 5235 description: r##"Checks for calls to `std::mem::forget` with a value that 5236 derives the Copy trait"##, 5237 }, 5238 Lint { 5239 label: "clippy::forget_ref", 5240 description: r##"Checks for calls to `std::mem::forget` with a reference 5241 instead of an owned value."##, 5242 }, 5243 Lint { 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."##, 5248 }, 5249 Lint { 5250 label: "clippy::from_iter_instead_of_collect", 5251 description: r##"Checks for `from_iter()` function calls on types that implement the `FromIterator` 5252 trait."##, 5253 }, 5254 Lint { 5255 label: "clippy::from_over_into", 5256 description: r##"Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead."##, 5257 }, 5258 Lint { 5259 label: "clippy::from_str_radix_10", 5260 description: r##"Checks for function invocations of the form `primitive::from_str_radix(s, 10)`"##, 5261 }, 5262 Lint { 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."##, 5268 }, 5269 Lint { 5270 label: "clippy::get_last_with_len", 5271 description: r##"Checks for using `x.get(x.len() - 1)` instead of 5272 `x.last()`."##, 5273 }, 5274 Lint { 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`"##, 5278 }, 5279 Lint { 5280 label: "clippy::identity_op", 5281 description: r##"Checks for identity operations, e.g., `x + 0`."##, 5282 }, 5283 Lint { 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."##, 5287 }, 5288 Lint { 5289 label: "clippy::if_let_redundant_pattern_matching", 5290 description: r##"Nothing. This lint has been deprecated."##, 5291 }, 5292 Lint { 5293 label: "clippy::if_not_else", 5294 description: r##"Checks for usage of `!` or `!=` in an if condition with an 5295 else branch."##, 5296 }, 5297 Lint { 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."##, 5301 }, 5302 Lint { 5303 label: "clippy::if_then_some_else_none", 5304 description: r##"Checks for if-else that could be written to `bool::then`."##, 5305 }, 5306 Lint { 5307 label: "clippy::ifs_same_cond", 5308 description: r##"Checks for consecutive `if`s with the same condition."##, 5309 }, 5310 Lint { 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."##, 5313 }, 5314 Lint { 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`)."##, 5319 }, 5320 Lint { 5321 label: "clippy::implicit_return", 5322 description: r##"Checks for missing return statements at the end of a block."##, 5323 }, 5324 Lint { 5325 label: "clippy::implicit_saturating_sub", 5326 description: r##"Checks for implicit saturating subtraction."##, 5327 }, 5328 Lint { 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."##, 5333 }, 5334 Lint { 5335 label: "clippy::inconsistent_digit_grouping", 5336 description: r##"Warns if an integral or floating-point constant is 5337 grouped inconsistently with underscores."##, 5338 }, 5339 Lint { 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."##, 5344 }, 5345 Lint { 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."##, 5349 }, 5350 Lint { 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."##, 5355 }, 5356 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 5360 following table: 5361 5362 |Comparison| Bit Op |Example |equals | 5363 |----------|---------|-----------|-------| 5364 |`>` / `<=`|`|` / `^`|`x | 2 > 3`|`x > 3`| 5365 |`<` / `>=`|`|` / `^`|`x ^ 1 < 4`|`x < 4`|"##, 5366 }, 5367 Lint { 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`)."##, 5371 }, 5372 Lint { 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."##, 5376 }, 5377 Lint { 5378 label: "clippy::infinite_iter", 5379 description: r##"Checks for iteration that is guaranteed to be infinite."##, 5380 }, 5381 Lint { 5382 label: "clippy::inherent_to_string", 5383 description: r##"Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`."##, 5384 }, 5385 Lint { 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."##, 5388 }, 5389 Lint { 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."##, 5393 }, 5394 Lint { 5395 label: "clippy::inline_asm_x86_att_syntax", 5396 description: r##"Checks for usage of AT&T x86 assembly syntax."##, 5397 }, 5398 Lint { 5399 label: "clippy::inline_asm_x86_intel_syntax", 5400 description: r##"Checks for usage of Intel x86 assembly syntax."##, 5401 }, 5402 Lint { 5403 label: "clippy::inline_fn_without_body", 5404 description: r##"Checks for `#[inline]` on trait methods without bodies"##, 5405 }, 5406 Lint { 5407 label: "clippy::inspect_for_each", 5408 description: r##"Checks for usage of `inspect().for_each()`."##, 5409 }, 5410 Lint { 5411 label: "clippy::int_plus_one", 5412 description: r##"Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block"##, 5413 }, 5414 Lint { 5415 label: "clippy::integer_arithmetic", 5416 description: r##"Checks for integer arithmetic operations which could overflow or panic. 5417 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 5422 attempted."##, 5423 }, 5424 Lint { label: "clippy::integer_division", description: r##"Checks for division of integers"## }, 5425 Lint { 5426 label: "clippy::into_iter_on_ref", 5427 description: r##"Checks for `into_iter` calls on references which should be replaced by `iter` 5428 or `iter_mut`."##, 5429 }, 5430 Lint { 5431 label: "clippy::invalid_null_ptr_usage", 5432 description: r##"This lint checks for invalid usages of `ptr::null`."##, 5433 }, 5434 Lint { 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 5438 regex syntax."##, 5439 }, 5440 Lint { 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."##, 5445 }, 5446 Lint { 5447 label: "clippy::invisible_characters", 5448 description: r##"Checks for invisible Unicode characters in the code."##, 5449 }, 5450 Lint { 5451 label: "clippy::items_after_statements", 5452 description: r##"Checks for items declared after some statement in a block."##, 5453 }, 5454 Lint { 5455 label: "clippy::iter_cloned_collect", 5456 description: r##"Checks for the use of `.cloned().collect()` on slice to 5457 create a `Vec`."##, 5458 }, 5459 Lint { 5460 label: "clippy::iter_count", 5461 description: r##"Checks for the use of `.iter().count()`."##, 5462 }, 5463 Lint { label: "clippy::iter_next_loop", description: r##"Checks for loops on `x.next()`."## }, 5464 Lint { 5465 label: "clippy::iter_next_slice", 5466 description: r##"Checks for usage of `iter().next()` on a Slice or an Array"##, 5467 }, 5468 Lint { 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`."##, 5471 }, 5472 Lint { 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."##, 5476 }, 5477 Lint { 5478 label: "clippy::iter_nth_zero", 5479 description: r##"Checks for the use of `iter.nth(0)`."##, 5480 }, 5481 Lint { 5482 label: "clippy::iter_skip_next", 5483 description: r##"Checks for use of `.skip(x).next()` on iterators."##, 5484 }, 5485 Lint { 5486 label: "clippy::iterator_step_by_zero", 5487 description: r##"Checks for calling `.step_by(0)` on iterators which panics."##, 5488 }, 5489 Lint { 5490 label: "clippy::just_underscores_and_digits", 5491 description: r##"Checks if you have variables whose name consists of just 5492 underscores and digits."##, 5493 }, 5494 Lint { 5495 label: "clippy::large_const_arrays", 5496 description: r##"Checks for large `const` arrays that should 5497 be defined as `static` instead."##, 5498 }, 5499 Lint { 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 5503 are too large."##, 5504 }, 5505 Lint { 5506 label: "clippy::large_enum_variant", 5507 description: r##"Checks for large size differences between variants on 5508 `enum`s."##, 5509 }, 5510 Lint { 5511 label: "clippy::large_stack_arrays", 5512 description: r##"Checks for local arrays that may be too large."##, 5513 }, 5514 Lint { 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`."##, 5521 }, 5522 Lint { 5523 label: "clippy::len_without_is_empty", 5524 description: r##"Checks for items that implement `.len()` but not 5525 `.is_empty()`."##, 5526 }, 5527 Lint { 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."##, 5531 }, 5532 Lint { 5533 label: "clippy::let_and_return", 5534 description: r##"Checks for `let`-bindings, which are subsequently 5535 returned."##, 5536 }, 5537 Lint { 5538 label: "clippy::let_underscore_drop", 5539 description: r##"Checks for `let _ = <expr>` 5540 where expr has a type that implements `Drop`"##, 5541 }, 5542 Lint { 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`."##, 5546 }, 5547 Lint { 5548 label: "clippy::let_underscore_must_use", 5549 description: r##"Checks for `let _ = <expr>` where expr is `#[must_use]`"##, 5550 }, 5551 Lint { label: "clippy::let_unit_value", description: r##"Checks for binding a unit value."## }, 5552 Lint { 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`)."##, 5556 }, 5557 Lint { 5558 label: "clippy::logic_bug", 5559 description: r##"Checks for boolean expressions that contain terminals that 5560 can be eliminated."##, 5561 }, 5562 Lint { 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."##, 5566 }, 5567 Lint { 5568 label: "clippy::macro_use_imports", 5569 description: r##"Checks for `#[macro_use] use...`."##, 5570 }, 5571 Lint { 5572 label: "clippy::main_recursion", 5573 description: r##"Checks for recursion using the entrypoint."##, 5574 }, 5575 Lint { 5576 label: "clippy::manual_assert", 5577 description: r##"Detects `if`-then-`panic!` that can be replaced with `assert!`."##, 5578 }, 5579 Lint { 5580 label: "clippy::manual_async_fn", 5581 description: r##"It checks for manual implementations of `async` functions."##, 5582 }, 5583 Lint { 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(_)`."##, 5587 }, 5588 Lint { 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(_)`."##, 5592 }, 5593 Lint { 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."##, 5597 }, 5598 Lint { 5599 label: "clippy::manual_map", 5600 description: r##"Checks for usages of `match` which could be implemented using `map`"##, 5601 }, 5602 Lint { 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."##, 5606 }, 5607 Lint { 5608 label: "clippy::manual_non_exhaustive", 5609 description: r##"Checks for manual implementations of the non-exhaustive pattern."##, 5610 }, 5611 Lint { 5612 label: "clippy::manual_ok_or", 5613 description: r##"Finds patterns that reimplement `Option::ok_or`."##, 5614 }, 5615 Lint { 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)`."##, 5619 }, 5620 Lint { 5621 label: "clippy::manual_saturating_arithmetic", 5622 description: r##"Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`."##, 5623 }, 5624 Lint { 5625 label: "clippy::manual_split_once", 5626 description: r##"Checks for usages of `str::splitn(2, _)`"##, 5627 }, 5628 Lint { 5629 label: "clippy::manual_str_repeat", 5630 description: r##"Checks for manual implementations of `str::repeat`"##, 5631 }, 5632 Lint { 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."##, 5636 }, 5637 Lint { label: "clippy::manual_swap", description: r##"Checks for manual swapping."## }, 5638 Lint { 5639 label: "clippy::manual_unwrap_or", 5640 description: r##"Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`."##, 5641 }, 5642 Lint { 5643 label: "clippy::many_single_char_names", 5644 description: r##"Checks for too many variables whose name consists of a 5645 single character."##, 5646 }, 5647 Lint { 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"##, 5652 }, 5653 Lint { 5654 label: "clippy::map_collect_result_unit", 5655 description: r##"Checks for usage of `_.map(_).collect::<Result<(), _>()`."##, 5656 }, 5657 Lint { 5658 label: "clippy::map_entry", 5659 description: r##"Checks for uses of `contains_key` + `insert` on `HashMap` 5660 or `BTreeMap`."##, 5661 }, 5662 Lint { 5663 label: "clippy::map_err_ignore", 5664 description: r##"Checks for instances of `map_err(|_| Some::Enum)`"##, 5665 }, 5666 Lint { 5667 label: "clippy::map_flatten", 5668 description: r##"Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option`"##, 5669 }, 5670 Lint { 5671 label: "clippy::map_identity", 5672 description: r##"Checks for instances of `map(f)` where `f` is the identity function."##, 5673 }, 5674 Lint { 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(_)`."##, 5678 }, 5679 Lint { 5680 label: "clippy::match_as_ref", 5681 description: r##"Checks for match which is used to add a reference to an 5682 `Option` value."##, 5683 }, 5684 Lint { 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."##, 5688 }, 5689 Lint { 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!`"##, 5693 }, 5694 Lint { 5695 label: "clippy::match_on_vec_items", 5696 description: r##"Checks for `match vec[idx]` or `match vec[n..m]`."##, 5697 }, 5698 Lint { 5699 label: "clippy::match_overlapping_arm", 5700 description: r##"Checks for overlapping match arms."##, 5701 }, 5702 Lint { 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."##, 5707 }, 5708 Lint { 5709 label: "clippy::match_result_ok", 5710 description: r##"Checks for unnecessary `ok()` in `while let`."##, 5711 }, 5712 Lint { 5713 label: "clippy::match_same_arms", 5714 description: r##"Checks for `match` with identical arm bodies."##, 5715 }, 5716 Lint { 5717 label: "clippy::match_single_binding", 5718 description: r##"Checks for useless match that binds to only one value."##, 5719 }, 5720 Lint { 5721 label: "clippy::match_str_case_mismatch", 5722 description: r##"Checks for `match` expressions modifying the case of a string with non-compliant arms"##, 5723 }, 5724 Lint { 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!`."##, 5728 }, 5729 Lint { 5730 label: "clippy::match_wildcard_for_single_variants", 5731 description: r##"Checks for wildcard enum matches for a single variant."##, 5732 }, 5733 Lint { 5734 label: "clippy::maybe_infinite_iter", 5735 description: r##"Checks for iteration that may be infinite."##, 5736 }, 5737 Lint { 5738 label: "clippy::mem_forget", 5739 description: r##"Checks for usage of `std::mem::forget(t)` where `t` is 5740 `Drop`."##, 5741 }, 5742 Lint { 5743 label: "clippy::mem_replace_option_with_none", 5744 description: r##"Checks for `mem::replace()` on an `Option` with 5745 `None`."##, 5746 }, 5747 Lint { 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()`."##, 5751 }, 5752 Lint { 5753 label: "clippy::mem_replace_with_uninit", 5754 description: r##"Checks for `mem::replace(&mut _, mem::uninitialized())` 5755 and `mem::replace(&mut _, mem::zeroed())`."##, 5756 }, 5757 Lint { 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."##, 5761 }, 5762 Lint { 5763 label: "clippy::misaligned_transmute", 5764 description: r##"Nothing. This lint has been deprecated."##, 5765 }, 5766 Lint { 5767 label: "clippy::mismatched_target_os", 5768 description: r##"Checks for cfg attributes having operating systems used in target family position."##, 5769 }, 5770 Lint { 5771 label: "clippy::misrefactored_assign_op", 5772 description: r##"Checks for `a op= a op b` or `a op= b op a` patterns."##, 5773 }, 5774 Lint { 5775 label: "clippy::missing_const_for_fn", 5776 description: r##"Suggests the use of `const` in functions and methods where possible."##, 5777 }, 5778 Lint { 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)."##, 5782 }, 5783 Lint { 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."##, 5787 }, 5788 Lint { 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."##, 5792 }, 5793 Lint { 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]`."##, 5797 }, 5798 Lint { 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."##, 5802 }, 5803 Lint { 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."##, 5807 }, 5808 Lint { 5809 label: "clippy::mistyped_literal_suffixes", 5810 description: r##"Warns for mistyped suffix in literals"##, 5811 }, 5812 Lint { 5813 label: "clippy::mixed_case_hex_literals", 5814 description: r##"Warns on hexadecimal literals with mixed-case letter 5815 digits."##, 5816 }, 5817 Lint { 5818 label: "clippy::mod_module_files", 5819 description: r##"Checks that module layout uses only self named module files, bans mod.rs files."##, 5820 }, 5821 Lint { 5822 label: "clippy::module_inception", 5823 description: r##"Checks for modules that have the same name as their 5824 parent module"##, 5825 }, 5826 Lint { 5827 label: "clippy::module_name_repetitions", 5828 description: r##"Detects type names that are prefixed or suffixed by the 5829 containing module's name."##, 5830 }, 5831 Lint { label: "clippy::modulo_arithmetic", description: r##"Checks for modulo arithmetic."## }, 5832 Lint { 5833 label: "clippy::modulo_one", 5834 description: r##"Checks for getting the remainder of a division by one or minus 5835 one."##, 5836 }, 5837 Lint { 5838 label: "clippy::multiple_crate_versions", 5839 description: r##"Checks to see if multiple versions of a crate are being 5840 used."##, 5841 }, 5842 Lint { 5843 label: "clippy::multiple_inherent_impl", 5844 description: r##"Checks for multiple inherent implementations of a struct"##, 5845 }, 5846 Lint { 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."##, 5851 }, 5852 Lint { 5853 label: "clippy::must_use_unit", 5854 description: r##"Checks for a `#[must_use]` attribute on 5855 unit-returning functions and methods."##, 5856 }, 5857 Lint { 5858 label: "clippy::mut_from_ref", 5859 description: r##"This lint checks for functions that take immutable 5860 references and return mutable ones."##, 5861 }, 5862 Lint { 5863 label: "clippy::mut_mut", 5864 description: r##"Checks for instances of `mut mut` references."##, 5865 }, 5866 Lint { 5867 label: "clippy::mut_mutex_lock", 5868 description: r##"Checks for `&mut Mutex::lock` calls"##, 5869 }, 5870 Lint { 5871 label: "clippy::mut_range_bound", 5872 description: r##"Checks for loops which have a range bound that is a mutable variable"##, 5873 }, 5874 Lint { 5875 label: "clippy::mutable_key_type", 5876 description: r##"Checks for sets/maps with mutable key types."##, 5877 }, 5878 Lint { 5879 label: "clippy::mutex_atomic", 5880 description: r##"Checks for usages of `Mutex<X>` where an atomic will do."##, 5881 }, 5882 Lint { 5883 label: "clippy::mutex_integer", 5884 description: r##"Checks for usages of `Mutex<X>` where `X` is an integral 5885 type."##, 5886 }, 5887 Lint { label: "clippy::naive_bytecount", description: r##"Checks for naive byte counts"## }, 5888 Lint { 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"##, 5892 }, 5893 Lint { 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 5896 a lazy and."##, 5897 }, 5898 Lint { 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."##, 5902 }, 5903 Lint { 5904 label: "clippy::needless_borrow", 5905 description: r##"Checks for address of operations (`&`) that are going to 5906 be dereferenced immediately by the compiler."##, 5907 }, 5908 Lint { 5909 label: "clippy::needless_borrowed_reference", 5910 description: r##"Checks for bindings that destructure a reference and borrow the inner 5911 value with `&ref`."##, 5912 }, 5913 Lint { 5914 label: "clippy::needless_collect", 5915 description: r##"Checks for functions collecting an iterator when collect 5916 is not needed."##, 5917 }, 5918 Lint { 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."##, 5924 }, 5925 Lint { 5926 label: "clippy::needless_doctest_main", 5927 description: r##"Checks for `fn main() { .. }` in doctests"##, 5928 }, 5929 Lint { 5930 label: "clippy::needless_for_each", 5931 description: r##"Checks for usage of `for_each` that would be more simply written as a 5932 `for` loop."##, 5933 }, 5934 Lint { 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."##, 5938 }, 5939 Lint { 5940 label: "clippy::needless_lifetimes", 5941 description: r##"Checks for lifetime annotations which can be removed by 5942 relying on lifetime elision."##, 5943 }, 5944 Lint { 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."##, 5948 }, 5949 Lint { 5950 label: "clippy::needless_pass_by_value", 5951 description: r##"Checks for functions taking arguments by value, but not 5952 consuming them in its 5953 body."##, 5954 }, 5955 Lint { 5956 label: "clippy::needless_question_mark", 5957 description: r##"Suggests alternatives for useless applications of `?` in terminating expressions"##, 5958 }, 5959 Lint { 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."##, 5963 }, 5964 Lint { 5965 label: "clippy::needless_return", 5966 description: r##"Checks for return statements at the end of a block."##, 5967 }, 5968 Lint { 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."##, 5971 }, 5972 Lint { 5973 label: "clippy::needless_update", 5974 description: r##"Checks for needlessly including a base struct on update 5975 when all fields are changed anyway. 5976 5977 This lint is not applied to structs marked with 5978 [non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html)."##, 5979 }, 5980 Lint { 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`)."##, 5984 }, 5985 Lint { 5986 label: "clippy::neg_multiply", 5987 description: r##"Checks for multiplication by -1 as a form of negation."##, 5988 }, 5989 Lint { 5990 label: "clippy::negative_feature_names", 5991 description: r##"Checks for negative feature names with prefix `no-` or `not-`"##, 5992 }, 5993 Lint { 5994 label: "clippy::never_loop", 5995 description: r##"Checks for loops that will always `break`, `return` or 5996 `continue` an outer loop."##, 5997 }, 5998 Lint { 5999 label: "clippy::new_ret_no_self", 6000 description: r##"Checks for `new` not returning a type that contains `Self`."##, 6001 }, 6002 Lint { 6003 label: "clippy::new_without_default", 6004 description: r##"Checks for types with a `fn new() -> Self` method and no 6005 implementation of 6006 [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)."##, 6007 }, 6008 Lint { 6009 label: "clippy::no_effect", 6010 description: r##"Checks for statements which have no effect."##, 6011 }, 6012 Lint { 6013 label: "clippy::no_effect_underscore_binding", 6014 description: r##"Checks for binding to underscore prefixed variable without side-effects."##, 6015 }, 6016 Lint { 6017 label: "clippy::non_ascii_literal", 6018 description: r##"Checks for non-ASCII characters in string and char literals."##, 6019 }, 6020 Lint { 6021 label: "clippy::non_octal_unix_permissions", 6022 description: r##"Checks for non-octal values used to set Unix file permissions."##, 6023 }, 6024 Lint { 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."##, 6031 }, 6032 Lint { 6033 label: "clippy::nonminimal_bool", 6034 description: r##"Checks for boolean expressions that can be written more 6035 concisely."##, 6036 }, 6037 Lint { 6038 label: "clippy::nonsensical_open_options", 6039 description: r##"Checks for duplicate open options as well as combinations 6040 that make no sense."##, 6041 }, 6042 Lint { 6043 label: "clippy::nonstandard_macro_braces", 6044 description: r##"Checks that common macros are used with consistent bracing."##, 6045 }, 6046 Lint { 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`."##, 6050 }, 6051 Lint { 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."##, 6055 }, 6056 Lint { label: "clippy::ok_expect", description: r##"Checks for usage of `ok().expect(..)`."## }, 6057 Lint { 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"##, 6062 }, 6063 Lint { 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)."##, 6066 }, 6067 Lint { 6068 label: "clippy::option_env_unwrap", 6069 description: r##"Checks for usage of `option_env!(...).unwrap()` and 6070 suggests usage of the `env!` macro."##, 6071 }, 6072 Lint { 6073 label: "clippy::option_filter_map", 6074 description: r##"Checks for indirect collection of populated `Option`"##, 6075 }, 6076 Lint { 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 6081 expression)."##, 6082 }, 6083 Lint { 6084 label: "clippy::option_map_or_none", 6085 description: r##"Checks for usage of `_.map_or(None, _)`."##, 6086 }, 6087 Lint { 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 `()`."##, 6091 }, 6092 Lint { 6093 label: "clippy::option_option", 6094 description: r##"Checks for use of `Option<Option<_>>` in function signatures and type 6095 definitions"##, 6096 }, 6097 Lint { 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."##, 6102 }, 6103 Lint { 6104 label: "clippy::out_of_bounds_indexing", 6105 description: r##"Checks for out of bounds array indexing with a constant 6106 index."##, 6107 }, 6108 Lint { 6109 label: "clippy::overflow_check_conditional", 6110 description: r##"Detects classic underflow/overflow checks."##, 6111 }, 6112 Lint { label: "clippy::panic", description: r##"Checks for usage of `panic!`."## }, 6113 Lint { 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."##, 6116 }, 6117 Lint { 6118 label: "clippy::panicking_unwrap", 6119 description: r##"Checks for calls of `unwrap[_err]()` that will always fail."##, 6120 }, 6121 Lint { 6122 label: "clippy::partialeq_ne_impl", 6123 description: r##"Checks for manual re-implementations of `PartialEq::ne`."##, 6124 }, 6125 Lint { 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."##, 6129 }, 6130 Lint { 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. 6134 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. 6143 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."##, 6150 }, 6151 Lint { 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."##, 6155 }, 6156 Lint { 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 6161 parentheses 6162 * a negative numeric literal (which is really a unary `-` followed by a 6163 numeric literal) 6164 followed by a method call"##, 6165 }, 6166 Lint { 6167 label: "clippy::print_literal", 6168 description: r##"This lint warns about the use of literals as `print!`/`println!` args."##, 6169 }, 6170 Lint { 6171 label: "clippy::print_stderr", 6172 description: r##"Checks for printing on *stderr*. The purpose of this lint 6173 is to catch debugging remnants."##, 6174 }, 6175 Lint { 6176 label: "clippy::print_stdout", 6177 description: r##"Checks for printing on *stdout*. The purpose of this lint 6178 is to catch debugging remnants."##, 6179 }, 6180 Lint { 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."##, 6184 }, 6185 Lint { 6186 label: "clippy::println_empty_string", 6187 description: r##"This lint warns when you use `println!()` to 6188 print a newline."##, 6189 }, 6190 Lint { 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()` 6195 calls."##, 6196 }, 6197 Lint { 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`."##, 6201 }, 6202 Lint { label: "clippy::ptr_eq", description: r##"Use `std::ptr::eq` when applicable"## }, 6203 Lint { 6204 label: "clippy::ptr_offset_with_cast", 6205 description: r##"Checks for usage of the `offset` pointer method with a `usize` casted to an 6206 `isize`."##, 6207 }, 6208 Lint { 6209 label: "clippy::pub_enum_variant_names", 6210 description: r##"Nothing. This lint has been deprecated."##, 6211 }, 6212 Lint { 6213 label: "clippy::question_mark", 6214 description: r##"Checks for expressions that could be replaced by the question mark operator."##, 6215 }, 6216 Lint { 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)`."##, 6220 }, 6221 Lint { 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)`."##, 6225 }, 6226 Lint { 6227 label: "clippy::range_step_by_zero", 6228 description: r##"Nothing. This lint has been deprecated."##, 6229 }, 6230 Lint { 6231 label: "clippy::range_zip_with_len", 6232 description: r##"Checks for zipping a collection with the range of 6233 `0.._.len()`."##, 6234 }, 6235 Lint { 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`."##, 6238 }, 6239 Lint { label: "clippy::rc_mutex", description: r##"Checks for `Rc<Mutex<T>>`."## }, 6240 Lint { 6241 label: "clippy::redundant_allocation", 6242 description: r##"Checks for use of redundant allocations anywhere in the code."##, 6243 }, 6244 Lint { 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."##, 6248 }, 6249 Lint { 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."##, 6254 }, 6255 Lint { 6256 label: "clippy::redundant_closure_call", 6257 description: r##"Detects closures called in the same expression where they 6258 are defined."##, 6259 }, 6260 Lint { 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."##, 6264 }, 6265 Lint { 6266 label: "clippy::redundant_else", 6267 description: r##"Checks for `else` blocks that can be removed without changing semantics."##, 6268 }, 6269 Lint { 6270 label: "clippy::redundant_feature_names", 6271 description: r##"Checks for feature names with prefix `use-`, `with-` or suffix `-support`"##, 6272 }, 6273 Lint { 6274 label: "clippy::redundant_field_names", 6275 description: r##"Checks for fields in struct literals where shorthands 6276 could be used."##, 6277 }, 6278 Lint { 6279 label: "clippy::redundant_pattern", 6280 description: r##"Checks for patterns in the form `name @ _`."##, 6281 }, 6282 Lint { 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`"##, 6286 }, 6287 Lint { 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."##, 6291 }, 6292 Lint { 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."##, 6296 }, 6297 Lint { 6298 label: "clippy::redundant_static_lifetimes", 6299 description: r##"Checks for constants and statics with an explicit `'static` lifetime."##, 6300 }, 6301 Lint { 6302 label: "clippy::ref_binding_to_reference", 6303 description: r##"Checks for `ref` bindings which create a reference to a reference."##, 6304 }, 6305 Lint { 6306 label: "clippy::ref_in_deref", 6307 description: r##"Checks for references in expressions that use 6308 auto dereference."##, 6309 }, 6310 Lint { 6311 label: "clippy::ref_option_ref", 6312 description: r##"Checks for usage of `&Option<&T>`."##, 6313 }, 6314 Lint { 6315 label: "clippy::regex_macro", 6316 description: r##"Nothing. This lint has been deprecated."##, 6317 }, 6318 Lint { 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` 6324 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))"##, 6327 }, 6328 Lint { 6329 label: "clippy::replace_consts", 6330 description: r##"Nothing. This lint has been deprecated."##, 6331 }, 6332 Lint { 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."##, 6335 }, 6336 Lint { 6337 label: "clippy::result_map_or_into_option", 6338 description: r##"Checks for usage of `_.map_or(None, Some)`."##, 6339 }, 6340 Lint { 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 `()`."##, 6344 }, 6345 Lint { 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`."##, 6350 }, 6351 Lint { 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."##, 6354 }, 6355 Lint { 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`."##, 6359 }, 6360 Lint { 6361 label: "clippy::same_functions_in_if_condition", 6362 description: r##"Checks for consecutive `if`s with the same function call."##, 6363 }, 6364 Lint { 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."##, 6368 }, 6369 Lint { 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."##, 6373 }, 6374 Lint { 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()`."##, 6378 }, 6379 Lint { 6380 label: "clippy::self_assignment", 6381 description: r##"Checks for explicit self-assignments."##, 6382 }, 6383 Lint { 6384 label: "clippy::self_named_constructors", 6385 description: r##"Warns when constructors have the same name as their types."##, 6386 }, 6387 Lint { 6388 label: "clippy::self_named_module_files", 6389 description: r##"Checks that module layout uses only mod.rs files."##, 6390 }, 6391 Lint { 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."##, 6395 }, 6396 Lint { 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."##, 6401 }, 6402 Lint { 6403 label: "clippy::serde_api_misuse", 6404 description: r##"Checks for mis-uses of the serde API."##, 6405 }, 6406 Lint { 6407 label: "clippy::shadow_reuse", 6408 description: r##"Checks for bindings that shadow other bindings already in 6409 scope, while reusing the original value."##, 6410 }, 6411 Lint { 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."##, 6415 }, 6416 Lint { 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."##, 6421 }, 6422 Lint { 6423 label: "clippy::short_circuit_statement", 6424 description: r##"Checks for the use of short circuit boolean conditions as 6425 a 6426 statement."##, 6427 }, 6428 Lint { 6429 label: "clippy::should_assert_eq", 6430 description: r##"Nothing. This lint has been deprecated."##, 6431 }, 6432 Lint { 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."##, 6438 }, 6439 Lint { 6440 label: "clippy::similar_names", 6441 description: r##"Checks for names that are very similar and thus confusing."##, 6442 }, 6443 Lint { 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."##, 6447 }, 6448 Lint { 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)`."##, 6452 }, 6453 Lint { 6454 label: "clippy::single_component_path_imports", 6455 description: r##"Checking for imports with single component use path."##, 6456 }, 6457 Lint { 6458 label: "clippy::single_element_loop", 6459 description: r##"Checks whether a for loop has a single element."##, 6460 }, 6461 Lint { 6462 label: "clippy::single_match", 6463 description: r##"Checks for matches with a single arm where an `if let` 6464 will usually suffice."##, 6465 }, 6466 Lint { 6467 label: "clippy::single_match_else", 6468 description: r##"Checks for matches with two arms where an `if let else` will 6469 usually suffice."##, 6470 }, 6471 Lint { 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`"##, 6476 }, 6477 Lint { 6478 label: "clippy::skip_while_next", 6479 description: r##"Checks for usage of `_.skip_while(condition).next()`."##, 6480 }, 6481 Lint { 6482 label: "clippy::slow_vector_initialization", 6483 description: r##"Checks slow zero-filled vector initialization"##, 6484 }, 6485 Lint { 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."##, 6490 }, 6491 Lint { 6492 label: "clippy::str_to_string", 6493 description: r##"This lint checks for `.to_string()` method calls on values of type `&str`."##, 6494 }, 6495 Lint { 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* 6499 match."##, 6500 }, 6501 Lint { 6502 label: "clippy::string_add_assign", 6503 description: r##"Checks for string appends of the form `x = x + y` (without 6504 `let`!)."##, 6505 }, 6506 Lint { 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`."##, 6510 }, 6511 Lint { 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."##, 6514 }, 6515 Lint { 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."##, 6519 }, 6520 Lint { 6521 label: "clippy::string_slice", 6522 description: r##"Checks for slice operations on strings"##, 6523 }, 6524 Lint { 6525 label: "clippy::string_to_string", 6526 description: r##"This lint checks for `.to_string()` method calls on values of type `String`."##, 6527 }, 6528 Lint { 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."##, 6532 }, 6533 Lint { 6534 label: "clippy::struct_excessive_bools", 6535 description: r##"Checks for excessive 6536 use of bools in structs."##, 6537 }, 6538 Lint { 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."##, 6543 }, 6544 Lint { 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."##, 6548 }, 6549 Lint { 6550 label: "clippy::suspicious_assignment_formatting", 6551 description: r##"Checks for use of the nonexistent `=*`, `=!` and `=-` 6552 operators."##, 6553 }, 6554 Lint { 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."##, 6558 }, 6559 Lint { 6560 label: "clippy::suspicious_map", 6561 description: r##"Checks for calls to `map` followed by a `count`."##, 6562 }, 6563 Lint { 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."##, 6567 }, 6568 Lint { 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."##, 6573 }, 6574 Lint { 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."##, 6579 }, 6580 Lint { 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."##, 6585 }, 6586 Lint { 6587 label: "clippy::tabs_in_doc_comments", 6588 description: r##"Checks doc comments for usage of tab characters."##, 6589 }, 6590 Lint { 6591 label: "clippy::temporary_assignment", 6592 description: r##"Checks for construction of a structure or tuple just to 6593 assign a value in it."##, 6594 }, 6595 Lint { 6596 label: "clippy::to_digit_is_some", 6597 description: r##"Checks for `.to_digit(..).is_some()` on `char`s."##, 6598 }, 6599 Lint { 6600 label: "clippy::to_string_in_display", 6601 description: r##"Checks for uses of `to_string()` in `Display` traits."##, 6602 }, 6603 Lint { 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."##, 6608 }, 6609 Lint { label: "clippy::todo", description: r##"Checks for usage of `todo!`."## }, 6610 Lint { 6611 label: "clippy::too_many_arguments", 6612 description: r##"Checks for functions with too many parameters."##, 6613 }, 6614 Lint { 6615 label: "clippy::too_many_lines", 6616 description: r##"Checks for functions with a large amount of lines."##, 6617 }, 6618 Lint { 6619 label: "clippy::toplevel_ref_arg", 6620 description: r##"Checks for function arguments and let bindings denoted as 6621 `ref`."##, 6622 }, 6623 Lint { 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."##, 6626 }, 6627 Lint { 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."##, 6631 }, 6632 Lint { 6633 label: "clippy::transmute_bytes_to_str", 6634 description: r##"Checks for transmutes from a `&[u8]` to a `&str`."##, 6635 }, 6636 Lint { 6637 label: "clippy::transmute_float_to_int", 6638 description: r##"Checks for transmutes from a float to an integer."##, 6639 }, 6640 Lint { 6641 label: "clippy::transmute_int_to_bool", 6642 description: r##"Checks for transmutes from an integer to a `bool`."##, 6643 }, 6644 Lint { 6645 label: "clippy::transmute_int_to_char", 6646 description: r##"Checks for transmutes from an integer to a `char`."##, 6647 }, 6648 Lint { 6649 label: "clippy::transmute_int_to_float", 6650 description: r##"Checks for transmutes from an integer to a float."##, 6651 }, 6652 Lint { 6653 label: "clippy::transmute_num_to_bytes", 6654 description: r##"Checks for transmutes from a number to an array of `u8`"##, 6655 }, 6656 Lint { 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."##, 6660 }, 6661 Lint { 6662 label: "clippy::transmute_ptr_to_ref", 6663 description: r##"Checks for transmutes from a pointer to a reference."##, 6664 }, 6665 Lint { 6666 label: "clippy::transmutes_expressible_as_ptr_casts", 6667 description: r##"Checks for transmutes that could be a pointer cast."##, 6668 }, 6669 Lint { 6670 label: "clippy::transmuting_null", 6671 description: r##"Checks for transmute calls which would receive a null pointer."##, 6672 }, 6673 Lint { 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`)."##, 6677 }, 6678 Lint { 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 6682 pass by value."##, 6683 }, 6684 Lint { label: "clippy::try_err", description: r##"Checks for usages of `Err(x)?`."## }, 6685 Lint { 6686 label: "clippy::type_complexity", 6687 description: r##"Checks for types used in structs, parameters and `let` 6688 declarations above a certain complexity threshold."##, 6689 }, 6690 Lint { 6691 label: "clippy::type_repetition_in_bounds", 6692 description: r##"This lint warns about unnecessary type repetitions in trait bounds"##, 6693 }, 6694 Lint { 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."##, 6699 }, 6700 Lint { 6701 label: "clippy::undropped_manually_drops", 6702 description: r##"Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`."##, 6703 }, 6704 Lint { 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)."##, 6709 }, 6710 Lint { 6711 label: "clippy::unimplemented", 6712 description: r##"Checks for usage of `unimplemented!`."##, 6713 }, 6714 Lint { 6715 label: "clippy::uninit_assumed_init", 6716 description: r##"Checks for `MaybeUninit::uninit().assume_init()`."##, 6717 }, 6718 Lint { 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()`."##, 6723 }, 6724 Lint { 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 (`()`)."##, 6728 }, 6729 Lint { 6730 label: "clippy::unit_cmp", 6731 description: r##"Checks for comparisons to unit. This includes all binary 6732 comparisons (like `==` and `<`) and asserts."##, 6733 }, 6734 Lint { label: "clippy::unit_hash", description: r##"Detects `().hash(_)`."## }, 6735 Lint { 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."##, 6740 }, 6741 Lint { 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."##, 6745 }, 6746 Lint { 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."##, 6751 }, 6752 Lint { 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`."##, 6757 }, 6758 Lint { 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`. 6762 6763 This lint suggests changing the following functions, when eager evaluation results in 6764 simpler code: 6765 - `unwrap_or_else` to `unwrap_or` 6766 - `and_then` to `and` 6767 - `or_else` to `or` 6768 - `get_or_insert_with` to `get_or_insert` 6769 - `ok_or_else` to `ok_or`"##, 6770 }, 6771 Lint { 6772 label: "clippy::unnecessary_mut_passed", 6773 description: r##"Detects passing a mutable reference to a function that only 6774 requires an immutable reference."##, 6775 }, 6776 Lint { 6777 label: "clippy::unnecessary_operation", 6778 description: r##"Checks for expression statements that can be reduced to a 6779 sub-expression."##, 6780 }, 6781 Lint { 6782 label: "clippy::unnecessary_self_imports", 6783 description: r##"Checks for imports ending in `::{self}`."##, 6784 }, 6785 Lint { 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."##, 6789 }, 6790 Lint { 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."##, 6794 }, 6795 Lint { 6796 label: "clippy::unnecessary_unwrap", 6797 description: r##"Checks for calls of `unwrap[_err]()` that cannot fail."##, 6798 }, 6799 Lint { 6800 label: "clippy::unnecessary_wraps", 6801 description: r##"Checks for private functions that only return `Ok` or `Some`."##, 6802 }, 6803 Lint { 6804 label: "clippy::unneeded_field_pattern", 6805 description: r##"Checks for structure field patterns bound to wildcards."##, 6806 }, 6807 Lint { 6808 label: "clippy::unneeded_wildcard_pattern", 6809 description: r##"Checks for tuple patterns with a wildcard 6810 pattern (`_`) is next to a rest pattern (`..`). 6811 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."##, 6816 }, 6817 Lint { 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)`. 6821 6822 Another way to think of this is that it rewrites patterns in 6823 *disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*."##, 6824 }, 6825 Lint { label: "clippy::unreachable", description: r##"Checks for usage of `unreachable!`."## }, 6826 Lint { 6827 label: "clippy::unreadable_literal", 6828 description: r##"Warns if a long integral or floating-point constant does 6829 not contain underscores."##, 6830 }, 6831 Lint { 6832 label: "clippy::unsafe_derive_deserialize", 6833 description: r##"Checks for deriving `serde::Deserialize` on a type that 6834 has methods using `unsafe`."##, 6835 }, 6836 Lint { 6837 label: "clippy::unsafe_removed_from_name", 6838 description: r##"Checks for imports that remove unsafe from an item's 6839 name."##, 6840 }, 6841 Lint { 6842 label: "clippy::unsafe_vector_initialization", 6843 description: r##"Nothing. This lint has been deprecated."##, 6844 }, 6845 Lint { 6846 label: "clippy::unseparated_literal_suffix", 6847 description: r##"Warns if literal suffixes are not separated by an 6848 underscore. 6849 To enforce unseparated literal suffix style, 6850 see the `separated_literal_suffix` lint."##, 6851 }, 6852 Lint { 6853 label: "clippy::unsound_collection_transmute", 6854 description: r##"Checks for transmutes between collections whose 6855 types have different ABI, size or alignment."##, 6856 }, 6857 Lint { 6858 label: "clippy::unstable_as_mut_slice", 6859 description: r##"Nothing. This lint has been deprecated."##, 6860 }, 6861 Lint { 6862 label: "clippy::unstable_as_slice", 6863 description: r##"Nothing. This lint has been deprecated."##, 6864 }, 6865 Lint { 6866 label: "clippy::unused_async", 6867 description: r##"Checks for functions that are declared `async` but have no `.await`s inside of them."##, 6868 }, 6869 Lint { 6870 label: "clippy::unused_collect", 6871 description: r##"Nothing. This lint has been deprecated."##, 6872 }, 6873 Lint { 6874 label: "clippy::unused_io_amount", 6875 description: r##"Checks for unused written/read amount."##, 6876 }, 6877 Lint { 6878 label: "clippy::unused_self", 6879 description: r##"Checks methods that contain a `self` argument but don't use it"##, 6880 }, 6881 Lint { 6882 label: "clippy::unused_unit", 6883 description: r##"Checks for unit (`()`) expressions that can be removed."##, 6884 }, 6885 Lint { 6886 label: "clippy::unusual_byte_groupings", 6887 description: r##"Warns if hexadecimal or binary literals are not grouped 6888 by nibble or byte."##, 6889 }, 6890 Lint { 6891 label: "clippy::unwrap_in_result", 6892 description: r##"Checks for functions of type `Result` that contain `expect()` or `unwrap()`"##, 6893 }, 6894 Lint { 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."##, 6898 }, 6899 Lint { 6900 label: "clippy::unwrap_used", 6901 description: r##"Checks for `.unwrap()` calls on `Option`s and on `Result`s."##, 6902 }, 6903 Lint { 6904 label: "clippy::upper_case_acronyms", 6905 description: r##"Checks for fully capitalized names and optionally names containing a capitalized acronym."##, 6906 }, 6907 Lint { 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."##, 6911 }, 6912 Lint { 6913 label: "clippy::use_self", 6914 description: r##"Checks for unnecessary repetition of structure name when a 6915 replacement with `Self` is applicable."##, 6916 }, 6917 Lint { 6918 label: "clippy::used_underscore_binding", 6919 description: r##"Checks for the use of bindings with a single leading 6920 underscore."##, 6921 }, 6922 Lint { 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."##, 6926 }, 6927 Lint { 6928 label: "clippy::useless_attribute", 6929 description: r##"Checks for `extern crate` and `use` items annotated with 6930 lint attributes. 6931 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."##, 6936 }, 6937 Lint { 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."##, 6941 }, 6942 Lint { 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."##, 6946 }, 6947 Lint { 6948 label: "clippy::useless_let_if_seq", 6949 description: r##"Checks for variable declarations immediately followed by a 6950 conditional affectation."##, 6951 }, 6952 Lint { 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."##, 6956 }, 6957 Lint { 6958 label: "clippy::useless_vec", 6959 description: r##"Checks for usage of `&vec![..]` when using `&[..]` would 6960 be possible."##, 6961 }, 6962 Lint { 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."##, 6966 }, 6967 Lint { 6968 label: "clippy::vec_init_then_push", 6969 description: r##"Checks for calls to `push` immediately after creating a new `Vec`."##, 6970 }, 6971 Lint { 6972 label: "clippy::vec_resize_to_zero", 6973 description: r##"Finds occurrences of `Vec::resize(0, an_int)`"##, 6974 }, 6975 Lint { 6976 label: "clippy::verbose_bit_mask", 6977 description: r##"Checks for bit masks that can be replaced by a call 6978 to `trailing_zeros`"##, 6979 }, 6980 Lint { 6981 label: "clippy::verbose_file_reads", 6982 description: r##"Checks for use of File::read_to_end and File::read_to_string."##, 6983 }, 6984 Lint { 6985 label: "clippy::vtable_address_comparisons", 6986 description: r##"Checks for comparisons with an address of a trait vtable."##, 6987 }, 6988 Lint { 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."##, 6992 }, 6993 Lint { 6994 label: "clippy::while_let_loop", 6995 description: r##"Detects `loop + match` combinations that are easier 6996 written as a `while let` loop."##, 6997 }, 6998 Lint { 6999 label: "clippy::while_let_on_iterator", 7000 description: r##"Checks for `while let` expressions on iterators."##, 7001 }, 7002 Lint { 7003 label: "clippy::wildcard_dependencies", 7004 description: r##"Checks for wildcard dependencies in the `Cargo.toml`."##, 7005 }, 7006 Lint { 7007 label: "clippy::wildcard_enum_match_arm", 7008 description: r##"Checks for wildcard enum matches using `_`."##, 7009 }, 7010 Lint { 7011 label: "clippy::wildcard_imports", 7012 description: r##"Checks for wildcard imports `use _::*`."##, 7013 }, 7014 Lint { 7015 label: "clippy::wildcard_in_or_patterns", 7016 description: r##"Checks for wildcard pattern used with others patterns in same match arm."##, 7017 }, 7018 Lint { 7019 label: "clippy::write_literal", 7020 description: r##"This lint warns about the use of literals as `write!`/`writeln!` args."##, 7021 }, 7022 Lint { 7023 label: "clippy::write_with_newline", 7024 description: r##"This lint warns when you use `write!()` with a format 7025 string that 7026 ends in a newline."##, 7027 }, 7028 Lint { 7029 label: "clippy::writeln_empty_string", 7030 description: r##"This lint warns when you use `writeln!(buf, )` to 7031 print a newline."##, 7032 }, 7033 Lint { 7034 label: "clippy::wrong_pub_self_convention", 7035 description: r##"Nothing. This lint has been deprecated."##, 7036 }, 7037 Lint { 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: 7041 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` | 7051 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). 7058 7059 Clippy allows `Pin<&Self>` and `Pin<&mut Self>` if `&self` and `&mut self` is required. 7060 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"##, 7063 }, 7064 Lint { 7065 label: "clippy::wrong_transmute", 7066 description: r##"Checks for transmutes that can't ever be correct on any 7067 architecture."##, 7068 }, 7069 Lint { label: "clippy::zero_divided_by_zero", description: r##"Checks for `0.0 / 0.0`."## }, 7070 Lint { 7071 label: "clippy::zero_prefixed_literal", 7072 description: r##"Warns if an integral constant literal starts with `0`."##, 7073 }, 7074 Lint { 7075 label: "clippy::zero_ptr", 7076 description: r##"Catch casts from `0` to some pointer type"##, 7077 }, 7078 Lint { 7079 label: "clippy::zero_sized_map_values", 7080 description: r##"Checks for maps with zero-sized value types anywhere in the code."##, 7081 }, 7082 Lint { 7083 label: "clippy::zst_offset", 7084 description: r##"Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to 7085 zero-sized types"##, 7086 }, 7087 ]; 7088 pub const CLIPPY_LINT_GROUPS: &[LintGroup] = &[ 7089 LintGroup { 7090 lint: Lint { 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"##, 7093 }, 7094 children: &[ 7095 "clippy::cargo_common_metadata", 7096 "clippy::multiple_crate_versions", 7097 "clippy::negative_feature_names", 7098 "clippy::redundant_feature_names", 7099 "clippy::wildcard_dependencies", 7100 ], 7101 }, 7102 LintGroup { 7103 lint: Lint { 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"##, 7106 }, 7107 children: &[ 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", 7184 "clippy::unit_arg", 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", 7194 "clippy::vec_box", 7195 "clippy::while_let_loop", 7196 "clippy::wildcard_in_or_patterns", 7197 "clippy::zero_divided_by_zero", 7198 "clippy::zero_prefixed_literal", 7199 ], 7200 }, 7201 LintGroup { 7202 lint: Lint { 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"##, 7205 }, 7206 children: &[ 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", 7214 "clippy::cmp_nan", 7215 "clippy::deprecated_semver", 7216 "clippy::derive_hash_xor_eq", 7217 "clippy::derive_ord_xor_partial_ord", 7218 "clippy::drop_copy", 7219 "clippy::drop_ref", 7220 "clippy::enum_clike_unportable_variant", 7221 "clippy::eq_op", 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", 7242 "clippy::min_max", 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", 7265 "clippy::unit_cmp", 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", 7276 ], 7277 }, 7278 LintGroup { 7279 lint: Lint { 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"##, 7282 }, 7283 children: &[ 7284 "clippy::assign_ops", 7285 "clippy::extend_from_slice", 7286 "clippy::filter_map", 7287 "clippy::find_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", 7300 ], 7301 }, 7302 LintGroup { 7303 lint: Lint { 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"##, 7306 }, 7307 children: &[ 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", 7331 "clippy::use_self", 7332 "clippy::useless_let_if_seq", 7333 "clippy::useless_transmute", 7334 ], 7335 }, 7336 LintGroup { 7337 lint: Lint { 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"##, 7340 }, 7341 children: &[ 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", 7398 "clippy::mut_mut", 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", 7435 ], 7436 }, 7437 LintGroup { 7438 lint: Lint { 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"##, 7441 }, 7442 children: &[ 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", 7449 "clippy::iter_nth", 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", 7467 ], 7468 }, 7469 LintGroup { 7470 lint: Lint { 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"##, 7473 }, 7474 children: &[ 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", 7485 "clippy::exit", 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", 7510 "clippy::panic", 7511 "clippy::panic_in_result_fn", 7512 "clippy::pattern_type_mismatch", 7513 "clippy::print_stderr", 7514 "clippy::print_stdout", 7515 "clippy::rc_buffer", 7516 "clippy::rc_mutex", 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", 7528 "clippy::todo", 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", 7540 ], 7541 }, 7542 LintGroup { 7543 lint: Lint { 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"##, 7546 }, 7547 children: &[ 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", 7558 "clippy::cmp_null", 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", 7586 "clippy::len_zero", 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", 7616 "clippy::op_ref", 7617 "clippy::option_map_or_none", 7618 "clippy::print_literal", 7619 "clippy::print_with_newline", 7620 "clippy::println_empty_string", 7621 "clippy::ptr_arg", 7622 "clippy::ptr_eq", 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", 7641 "clippy::try_err", 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", 7655 "clippy::zero_ptr", 7656 ], 7657 }, 7658 LintGroup { 7659 lint: Lint { 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"##, 7662 }, 7663 children: &[ 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", 7680 ], 7681 }, 7682 ]; 7683