aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-04 18:45:37 +0100
committerGitHub <[email protected]>2021-06-04 18:45:37 +0100
commit98395f29a417b37a5969594f0cac5ae23585da85 (patch)
tree3a13913003723f3da843dae8580287b9d33c68eb /crates
parent92d91050c4aa48732e7af3bf979aa7ed5aed924d (diff)
parentae1c63fcdd0caf34f41fba62b04e3d868a589f1d (diff)
Merge #9138
9138: feat: Implement hover for lints r=Veykril a=Veykril fixes https://github.com/rust-analyzer/rust-analyzer/issues/8857, fixes https://github.com/rust-analyzer/rust-analyzer/issues/3941 ![URXBanNxYe](https://user-images.githubusercontent.com/3757771/120830905-4bd8da80-c55f-11eb-9f55-ff5a321726fa.gif) We also generate the default lints(and lint groups 🎉) instead now by invoking `rustc -W help` and parsing the output from that. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/hover.rs145
-rw-r--r--crates/ide_completion/src/completions/attribute.rs5
-rw-r--r--crates/ide_completion/src/completions/attribute/lint.rs127
-rw-r--r--crates/ide_completion/src/lib.rs1
-rw-r--r--crates/ide_db/src/helpers.rs1
-rw-r--r--crates/ide_db/src/helpers/generated_lints.rs (renamed from crates/ide_completion/src/generated_lint_completions.rs)7168
6 files changed, 3991 insertions, 3456 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 455a27e48..ed4f18e1f 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -6,12 +6,18 @@ use hir::{
6use ide_db::{ 6use ide_db::{
7 base_db::SourceDatabase, 7 base_db::SourceDatabase,
8 defs::{Definition, NameClass, NameRefClass}, 8 defs::{Definition, NameClass, NameRefClass},
9 helpers::FamousDefs, 9 helpers::{
10 generated_lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES},
11 FamousDefs,
12 },
10 RootDatabase, 13 RootDatabase,
11}; 14};
12use itertools::Itertools; 15use itertools::Itertools;
13use stdx::format_to; 16use stdx::format_to;
14use syntax::{ast, match_ast, AstNode, AstToken, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; 17use syntax::{
18 algo, ast, match_ast, AstNode, AstToken, Direction, SyntaxKind::*, SyntaxToken, TokenAtOffset,
19 T,
20};
15 21
16use crate::{ 22use crate::{
17 display::{macro_label, TryToNav}, 23 display::{macro_label, TryToNav},
@@ -118,8 +124,9 @@ pub(crate) fn hover(
118 |d| d.defined(db), 124 |d| d.defined(db),
119 ), 125 ),
120 126
121 _ => ast::Comment::cast(token.clone()) 127 _ => {
122 .and_then(|_| { 128 if ast::Comment::cast(token.clone()).is_some() {
129 cov_mark::hit!(no_highlight_on_comment_hover);
123 let (attributes, def) = doc_attributes(&sema, &node)?; 130 let (attributes, def) = doc_attributes(&sema, &node)?;
124 let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?; 131 let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
125 let (idl_range, link, ns) = 132 let (idl_range, link, ns) =
@@ -132,9 +139,13 @@ pub(crate) fn hover(
132 } 139 }
133 })?; 140 })?;
134 range = Some(idl_range); 141 range = Some(idl_range);
135 resolve_doc_path_for_def(db, def, &link, ns) 142 resolve_doc_path_for_def(db, def, &link, ns).map(Definition::ModuleDef)
136 }) 143 } else if let res@Some(_) = try_hover_for_attribute(&token) {
137 .map(Definition::ModuleDef), 144 return res;
145 } else {
146 None
147 }
148 },
138 } 149 }
139 }; 150 };
140 151
@@ -168,11 +179,6 @@ pub(crate) fn hover(
168 } 179 }
169 } 180 }
170 181
171 if token.kind() == syntax::SyntaxKind::COMMENT {
172 cov_mark::hit!(no_highlight_on_comment_hover);
173 return None;
174 }
175
176 if let res @ Some(_) = hover_for_keyword(&sema, links_in_hover, markdown, &token) { 182 if let res @ Some(_) = hover_for_keyword(&sema, links_in_hover, markdown, &token) {
177 return res; 183 return res;
178 } 184 }
@@ -201,6 +207,51 @@ pub(crate) fn hover(
201 Some(RangeInfo::new(range, res)) 207 Some(RangeInfo::new(range, res))
202} 208}
203 209
210fn try_hover_for_attribute(token: &SyntaxToken) -> Option<RangeInfo<HoverResult>> {
211 let attr = token.ancestors().nth(1).and_then(ast::Attr::cast)?;
212 let (path, tt) = attr.as_simple_call()?;
213 if !tt.syntax().text_range().contains(token.text_range().start()) {
214 return None;
215 }
216 let (is_clippy, lints) = match &*path {
217 "feature" => (false, FEATURES),
218 "allow" | "deny" | "forbid" | "warn" => {
219 let is_clippy = algo::non_trivia_sibling(token.clone().into(), Direction::Prev)
220 .filter(|t| t.kind() == T![:])
221 .and_then(|t| algo::non_trivia_sibling(t, Direction::Prev))
222 .filter(|t| t.kind() == T![:])
223 .and_then(|t| algo::non_trivia_sibling(t, Direction::Prev))
224 .map_or(false, |t| {
225 t.kind() == T![ident] && t.into_token().map_or(false, |t| t.text() == "clippy")
226 });
227 if is_clippy {
228 (true, CLIPPY_LINTS)
229 } else {
230 (false, DEFAULT_LINTS)
231 }
232 }
233 _ => return None,
234 };
235
236 let tmp;
237 let needle = if is_clippy {
238 tmp = format!("clippy::{}", token.text());
239 &tmp
240 } else {
241 &*token.text()
242 };
243
244 let lint =
245 lints.binary_search_by_key(&needle, |lint| lint.label).ok().map(|idx| &lints[idx])?;
246 Some(RangeInfo::new(
247 token.text_range(),
248 HoverResult {
249 markup: Markup::from(format!("```\n{}\n```\n___\n\n{}", lint.label, lint.description)),
250 ..Default::default()
251 },
252 ))
253}
254
204fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> { 255fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> {
205 fn to_action(nav_target: NavigationTarget) -> HoverAction { 256 fn to_action(nav_target: NavigationTarget) -> HoverAction {
206 HoverAction::Implementation(FilePosition { 257 HoverAction::Implementation(FilePosition {
@@ -4004,4 +4055,74 @@ pub fn foo() {}
4004 "#]], 4055 "#]],
4005 ) 4056 )
4006 } 4057 }
4058
4059 #[test]
4060 fn hover_feature() {
4061 check(
4062 r#"#![feature(box_syntax$0)]"#,
4063 expect![[r##"
4064 *box_syntax*
4065 ```
4066 box_syntax
4067 ```
4068 ___
4069
4070 # `box_syntax`
4071
4072 The tracking issue for this feature is: [#49733]
4073
4074 [#49733]: https://github.com/rust-lang/rust/issues/49733
4075
4076 See also [`box_patterns`](box-patterns.md)
4077
4078 ------------------------
4079
4080 Currently the only stable way to create a `Box` is via the `Box::new` method.
4081 Also it is not possible in stable Rust to destructure a `Box` in a match
4082 pattern. The unstable `box` keyword can be used to create a `Box`. An example
4083 usage would be:
4084
4085 ```rust
4086 #![feature(box_syntax)]
4087
4088 fn main() {
4089 let b = box 5;
4090 }
4091 ```
4092
4093 "##]],
4094 )
4095 }
4096
4097 #[test]
4098 fn hover_lint() {
4099 check(
4100 r#"#![allow(arithmetic_overflow$0)]"#,
4101 expect![[r#"
4102 *arithmetic_overflow*
4103 ```
4104 arithmetic_overflow
4105 ```
4106 ___
4107
4108 arithmetic operation overflows
4109 "#]],
4110 )
4111 }
4112
4113 #[test]
4114 fn hover_clippy_lint() {
4115 check(
4116 r#"#![allow(clippy::almost_swapped$0)]"#,
4117 expect![[r#"
4118 *almost_swapped*
4119 ```
4120 clippy::almost_swapped
4121 ```
4122 ___
4123
4124 Checks for `foo = bar; bar = foo` sequences.
4125 "#]],
4126 )
4127 }
4007} 4128}
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index c48bb9e66..f80d7eec3 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -3,20 +3,19 @@
3//! This module uses a bit of static metadata to provide completions 3//! This module uses a bit of static metadata to provide completions
4//! for built-in attributes. 4//! for built-in attributes.
5 5
6use ide_db::helpers::generated_lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES};
6use once_cell::sync::Lazy; 7use once_cell::sync::Lazy;
7use rustc_hash::{FxHashMap, FxHashSet}; 8use rustc_hash::{FxHashMap, FxHashSet};
8use syntax::{algo::non_trivia_sibling, ast, AstNode, Direction, NodeOrToken, SyntaxKind, T}; 9use syntax::{algo::non_trivia_sibling, ast, AstNode, Direction, NodeOrToken, SyntaxKind, T};
9 10
10use crate::{ 11use crate::{
11 context::CompletionContext, 12 context::CompletionContext,
12 generated_lint_completions::{CLIPPY_LINTS, FEATURES},
13 item::{CompletionItem, CompletionItemKind, CompletionKind}, 13 item::{CompletionItem, CompletionItemKind, CompletionKind},
14 Completions, 14 Completions,
15}; 15};
16 16
17mod derive; 17mod derive;
18mod lint; 18mod lint;
19pub(crate) use self::lint::LintCompletion;
20 19
21pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 20pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
22 let attribute = ctx.attribute_under_caret.as_ref()?; 21 let attribute = ctx.attribute_under_caret.as_ref()?;
@@ -25,7 +24,7 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
25 "derive" => derive::complete_derive(acc, ctx, token_tree), 24 "derive" => derive::complete_derive(acc, ctx, token_tree),
26 "feature" => lint::complete_lint(acc, ctx, token_tree, FEATURES), 25 "feature" => lint::complete_lint(acc, ctx, token_tree, FEATURES),
27 "allow" | "warn" | "deny" | "forbid" => { 26 "allow" | "warn" | "deny" | "forbid" => {
28 lint::complete_lint(acc, ctx, token_tree.clone(), lint::DEFAULT_LINT_COMPLETIONS); 27 lint::complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINTS);
29 lint::complete_lint(acc, ctx, token_tree, CLIPPY_LINTS); 28 lint::complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
30 } 29 }
31 _ => (), 30 _ => (),
diff --git a/crates/ide_completion/src/completions/attribute/lint.rs b/crates/ide_completion/src/completions/attribute/lint.rs
index 403630dce..b486c9093 100644
--- a/crates/ide_completion/src/completions/attribute/lint.rs
+++ b/crates/ide_completion/src/completions/attribute/lint.rs
@@ -1,4 +1,5 @@
1//! Completion for lints 1//! Completion for lints
2use ide_db::helpers::generated_lints::Lint;
2use syntax::ast; 3use syntax::ast;
3 4
4use crate::{ 5use crate::{
@@ -11,7 +12,7 @@ pub(super) fn complete_lint(
11 acc: &mut Completions, 12 acc: &mut Completions,
12 ctx: &CompletionContext, 13 ctx: &CompletionContext,
13 derive_input: ast::TokenTree, 14 derive_input: ast::TokenTree,
14 lints_completions: &[LintCompletion], 15 lints_completions: &[Lint],
15) { 16) {
16 if let Some(existing_lints) = super::parse_comma_sep_input(derive_input) { 17 if let Some(existing_lints) = super::parse_comma_sep_input(derive_input) {
17 for lint_completion in lints_completions 18 for lint_completion in lints_completions
@@ -29,130 +30,6 @@ pub(super) fn complete_lint(
29 } 30 }
30} 31}
31 32
32pub(crate) struct LintCompletion {
33 pub(crate) label: &'static str,
34 pub(crate) description: &'static str,
35}
36
37#[rustfmt::skip]
38pub(super) const DEFAULT_LINT_COMPLETIONS: &[LintCompletion] = &[
39 LintCompletion { label: "absolute_paths_not_starting_with_crate", description: r#"fully qualified paths that start with a module name instead of `crate`, `self`, or an extern crate name"# },
40 LintCompletion { label: "anonymous_parameters", description: r#"detects anonymous parameters"# },
41 LintCompletion { label: "box_pointers", description: r#"use of owned (Box type) heap memory"# },
42 LintCompletion { label: "deprecated_in_future", description: r#"detects use of items that will be deprecated in a future version"# },
43 LintCompletion { label: "elided_lifetimes_in_paths", description: r#"hidden lifetime parameters in types are deprecated"# },
44 LintCompletion { label: "explicit_outlives_requirements", description: r#"outlives requirements can be inferred"# },
45 LintCompletion { label: "indirect_structural_match", description: r#"pattern with const indirectly referencing non-structural-match type"# },
46 LintCompletion { label: "keyword_idents", description: r#"detects edition keywords being used as an identifier"# },
47 LintCompletion { label: "macro_use_extern_crate", description: r#"the `#[macro_use]` attribute is now deprecated in favor of using macros via the module system"# },
48 LintCompletion { label: "meta_variable_misuse", description: r#"possible meta-variable misuse at macro definition"# },
49 LintCompletion { label: "missing_copy_implementations", description: r#"detects potentially-forgotten implementations of `Copy`"# },
50 LintCompletion { label: "missing_crate_level_docs", description: r#"detects crates with no crate-level documentation"# },
51 LintCompletion { label: "missing_debug_implementations", description: r#"detects missing implementations of Debug"# },
52 LintCompletion { label: "missing_docs", description: r#"detects missing documentation for public members"# },
53 LintCompletion { label: "missing_doc_code_examples", description: r#"detects publicly-exported items without code samples in their documentation"# },
54 LintCompletion { label: "non_ascii_idents", description: r#"detects non-ASCII identifiers"# },
55 LintCompletion { label: "private_doc_tests", description: r#"detects code samples in docs of private items not documented by rustdoc"# },
56 LintCompletion { label: "single_use_lifetimes", description: r#"detects lifetime parameters that are only used once"# },
57 LintCompletion { label: "trivial_casts", description: r#"detects trivial casts which could be removed"# },
58 LintCompletion { label: "trivial_numeric_casts", description: r#"detects trivial casts of numeric types which could be removed"# },
59 LintCompletion { label: "unaligned_references", description: r#"detects unaligned references to fields of packed structs"# },
60 LintCompletion { label: "unreachable_pub", description: r#"`pub` items not reachable from crate root"# },
61 LintCompletion { label: "unsafe_code", description: r#"usage of `unsafe` code"# },
62 LintCompletion { label: "unsafe_op_in_unsafe_fn", description: r#"unsafe operations in unsafe functions without an explicit unsafe block are deprecated"# },
63 LintCompletion { label: "unstable_features", description: r#"enabling unstable features (deprecated. do not use)"# },
64 LintCompletion { label: "unused_crate_dependencies", description: r#"crate dependencies that are never used"# },
65 LintCompletion { label: "unused_extern_crates", description: r#"extern crates that are never used"# },
66 LintCompletion { label: "unused_import_braces", description: r#"unnecessary braces around an imported item"# },
67 LintCompletion { label: "unused_lifetimes", description: r#"detects lifetime parameters that are never used"# },
68 LintCompletion { label: "unused_qualifications", description: r#"detects unnecessarily qualified names"# },
69 LintCompletion { label: "unused_results", description: r#"unused result of an expression in a statement"# },
70 LintCompletion { label: "variant_size_differences", description: r#"detects enums with widely varying variant sizes"# },
71 LintCompletion { label: "array_into_iter", description: r#"detects calling `into_iter` on arrays"# },
72 LintCompletion { label: "asm_sub_register", description: r#"using only a subset of a register for inline asm inputs"# },
73 LintCompletion { label: "bare_trait_objects", description: r#"suggest using `dyn Trait` for trait objects"# },
74 LintCompletion { label: "bindings_with_variant_name", description: r#"detects pattern bindings with the same name as one of the matched variants"# },
75 LintCompletion { label: "cenum_impl_drop_cast", description: r#"a C-like enum implementing Drop is cast"# },
76 LintCompletion { label: "clashing_extern_declarations", description: r#"detects when an extern fn has been declared with the same name but different types"# },
77 LintCompletion { label: "coherence_leak_check", description: r#"distinct impls distinguished only by the leak-check code"# },
78 LintCompletion { label: "confusable_idents", description: r#"detects visually confusable pairs between identifiers"# },
79 LintCompletion { label: "dead_code", description: r#"detect unused, unexported items"# },
80 LintCompletion { label: "deprecated", description: r#"detects use of deprecated items"# },
81 LintCompletion { label: "ellipsis_inclusive_range_patterns", description: r#"`...` range patterns are deprecated"# },
82 LintCompletion { label: "exported_private_dependencies", description: r#"public interface leaks type from a private dependency"# },
83 LintCompletion { label: "illegal_floating_point_literal_pattern", description: r#"floating-point literals cannot be used in patterns"# },
84 LintCompletion { label: "improper_ctypes", description: r#"proper use of libc types in foreign modules"# },
85 LintCompletion { label: "improper_ctypes_definitions", description: r#"proper use of libc types in foreign item definitions"# },
86 LintCompletion { label: "incomplete_features", description: r#"incomplete features that may function improperly in some or all cases"# },
87 LintCompletion { label: "inline_no_sanitize", description: r#"detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`"# },
88 LintCompletion { label: "intra_doc_link_resolution_failure", description: r#"failures in resolving intra-doc link targets"# },
89 LintCompletion { label: "invalid_codeblock_attributes", description: r#"codeblock attribute looks a lot like a known one"# },
90 LintCompletion { label: "invalid_value", description: r#"an invalid value is being created (such as a NULL reference)"# },
91 LintCompletion { label: "irrefutable_let_patterns", description: r#"detects irrefutable patterns in if-let and while-let statements"# },
92 LintCompletion { label: "late_bound_lifetime_arguments", description: r#"detects generic lifetime arguments in path segments with late bound lifetime parameters"# },
93 LintCompletion { label: "mixed_script_confusables", description: r#"detects Unicode scripts whose mixed script confusables codepoints are solely used"# },
94 LintCompletion { label: "mutable_borrow_reservation_conflict", description: r#"reservation of a two-phased borrow conflicts with other shared borrows"# },
95 LintCompletion { label: "non_camel_case_types", description: r#"types, variants, traits and type parameters should have camel case names"# },
96 LintCompletion { label: "non_shorthand_field_patterns", description: r#"using `Struct { x: x }` instead of `Struct { x }` in a pattern"# },
97 LintCompletion { label: "non_snake_case", description: r#"variables, methods, functions, lifetime parameters and modules should have snake case names"# },
98 LintCompletion { label: "non_upper_case_globals", description: r#"static constants should have uppercase identifiers"# },
99 LintCompletion { label: "no_mangle_generic_items", description: r#"generic items must be mangled"# },
100 LintCompletion { label: "overlapping_patterns", description: r#"detects overlapping patterns"# },
101 LintCompletion { label: "path_statements", description: r#"path statements with no effect"# },
102 LintCompletion { label: "private_in_public", description: r#"detect private items in public interfaces not caught by the old implementation"# },
103 LintCompletion { label: "proc_macro_derive_resolution_fallback", description: r#"detects proc macro derives using inaccessible names from parent modules"# },
104 LintCompletion { label: "redundant_semicolons", description: r#"detects unnecessary trailing semicolons"# },
105 LintCompletion { label: "renamed_and_removed_lints", description: r#"lints that have been renamed or removed"# },
106 LintCompletion { label: "safe_packed_borrows", description: r#"safe borrows of fields of packed structs were erroneously allowed"# },
107 LintCompletion { label: "stable_features", description: r#"stable features found in `#[feature]` directive"# },
108 LintCompletion { label: "trivial_bounds", description: r#"these bounds don't depend on an type parameters"# },
109 LintCompletion { label: "type_alias_bounds", description: r#"bounds in type aliases are not enforced"# },
110 LintCompletion { label: "tyvar_behind_raw_pointer", description: r#"raw pointer to an inference variable"# },
111 LintCompletion { label: "uncommon_codepoints", description: r#"detects uncommon Unicode codepoints in identifiers"# },
112 LintCompletion { label: "unconditional_recursion", description: r#"functions that cannot return without calling themselves"# },
113 LintCompletion { label: "unknown_lints", description: r#"unrecognized lint attribute"# },
114 LintCompletion { label: "unnameable_test_items", description: r#"detects an item that cannot be named being marked as `#[test_case]`"# },
115 LintCompletion { label: "unreachable_code", description: r#"detects unreachable code paths"# },
116 LintCompletion { label: "unreachable_patterns", description: r#"detects unreachable patterns"# },
117 LintCompletion { label: "unstable_name_collisions", description: r#"detects name collision with an existing but unstable method"# },
118 LintCompletion { label: "unused_allocation", description: r#"detects unnecessary allocations that can be eliminated"# },
119 LintCompletion { label: "unused_assignments", description: r#"detect assignments that will never be read"# },
120 LintCompletion { label: "unused_attributes", description: r#"detects attributes that were not used by the compiler"# },
121 LintCompletion { label: "unused_braces", description: r#"unnecessary braces around an expression"# },
122 LintCompletion { label: "unused_comparisons", description: r#"comparisons made useless by limits of the types involved"# },
123 LintCompletion { label: "unused_doc_comments", description: r#"detects doc comments that aren't used by rustdoc"# },
124 LintCompletion { label: "unused_features", description: r#"unused features found in crate-level `#[feature]` directives"# },
125 LintCompletion { label: "unused_imports", description: r#"imports that are never used"# },
126 LintCompletion { label: "unused_labels", description: r#"detects labels that are never used"# },
127 LintCompletion { label: "unused_macros", description: r#"detects macros that were not used"# },
128 LintCompletion { label: "unused_must_use", description: r#"unused result of a type flagged as `#[must_use]`"# },
129 LintCompletion { label: "unused_mut", description: r#"detect mut variables which don't need to be mutable"# },
130 LintCompletion { label: "unused_parens", description: r#"`if`, `match`, `while` and `return` do not need parentheses"# },
131 LintCompletion { label: "unused_unsafe", description: r#"unnecessary use of an `unsafe` block"# },
132 LintCompletion { label: "unused_variables", description: r#"detect variables which are not used in any way"# },
133 LintCompletion { label: "warnings", description: r#"mass-change the level for lints which produce warnings"# },
134 LintCompletion { label: "where_clauses_object_safety", description: r#"checks the object safety of where clauses"# },
135 LintCompletion { label: "while_true", description: r#"suggest using `loop { }` instead of `while true { }`"# },
136 LintCompletion { label: "ambiguous_associated_items", description: r#"ambiguous associated items"# },
137 LintCompletion { label: "arithmetic_overflow", description: r#"arithmetic operation overflows"# },
138 LintCompletion { label: "conflicting_repr_hints", description: r#"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice"# },
139 LintCompletion { label: "const_err", description: r#"constant evaluation detected erroneous expression"# },
140 LintCompletion { label: "ill_formed_attribute_input", description: r#"ill-formed attribute inputs that were previously accepted and used in practice"# },
141 LintCompletion { label: "incomplete_include", description: r#"trailing content in included file"# },
142 LintCompletion { label: "invalid_type_param_default", description: r#"type parameter default erroneously allowed in invalid location"# },
143 LintCompletion { label: "macro_expanded_macro_exports_accessed_by_absolute_paths", description: r#"macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"# },
144 LintCompletion { label: "missing_fragment_specifier", description: r#"detects missing fragment specifiers in unused `macro_rules!` patterns"# },
145 LintCompletion { label: "mutable_transmutes", description: r#"mutating transmuted &mut T from &T may cause undefined behavior"# },
146 LintCompletion { label: "no_mangle_const_items", description: r#"const items will not have their symbols exported"# },
147 LintCompletion { label: "order_dependent_trait_objects", description: r#"trait-object types were treated as different depending on marker-trait order"# },
148 LintCompletion { label: "overflowing_literals", description: r#"literal out of range for its type"# },
149 LintCompletion { label: "patterns_in_fns_without_body", description: r#"patterns in functions without body were erroneously allowed"# },
150 LintCompletion { label: "pub_use_of_private_extern_crate", description: r#"detect public re-exports of private extern crates"# },
151 LintCompletion { label: "soft_unstable", description: r#"a feature gate that doesn't break dependent crates"# },
152 LintCompletion { label: "unconditional_panic", description: r#"operation will cause a panic at runtime"# },
153 LintCompletion { label: "unknown_crate_types", description: r#"unknown crate type found in `#[crate_type]` directive"# },
154];
155
156#[cfg(test)] 33#[cfg(test)]
157mod tests { 34mod tests {
158 35
diff --git a/crates/ide_completion/src/lib.rs b/crates/ide_completion/src/lib.rs
index 1152a9850..6fb38f50d 100644
--- a/crates/ide_completion/src/lib.rs
+++ b/crates/ide_completion/src/lib.rs
@@ -4,7 +4,6 @@ mod config;
4mod item; 4mod item;
5mod context; 5mod context;
6mod patterns; 6mod patterns;
7mod generated_lint_completions;
8#[cfg(test)] 7#[cfg(test)]
9mod test_utils; 8mod test_utils;
10mod render; 9mod render;
diff --git a/crates/ide_db/src/helpers.rs b/crates/ide_db/src/helpers.rs
index 21b48237a..00900cdc2 100644
--- a/crates/ide_db/src/helpers.rs
+++ b/crates/ide_db/src/helpers.rs
@@ -3,6 +3,7 @@ pub mod import_assets;
3pub mod insert_use; 3pub mod insert_use;
4pub mod merge_imports; 4pub mod merge_imports;
5pub mod rust_doc; 5pub mod rust_doc;
6pub mod generated_lints;
6 7
7use std::collections::VecDeque; 8use std::collections::VecDeque;
8 9
diff --git a/crates/ide_completion/src/generated_lint_completions.rs b/crates/ide_db/src/helpers/generated_lints.rs
index 0d405350d..6ccb0478e 100644
--- a/crates/ide_completion/src/generated_lint_completions.rs
+++ b/crates/ide_db/src/helpers/generated_lints.rs
@@ -1,320 +1,487 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3use crate::completions::attribute::LintCompletion; 3pub struct Lint {
4pub(super) const FEATURES: &[LintCompletion] = &[ 4 pub label: &'static str,
5 LintCompletion { 5 pub description: &'static str,
6 label: "plugin_registrar",
7 description: r##"# `plugin_registrar`
8
9The tracking issue for this feature is: [#29597]
10
11[#29597]: https://github.com/rust-lang/rust/issues/29597
12
13This feature is part of "compiler plugins." It will often be used with the
14[`plugin`] and `rustc_private` features as well. For more details, see
15their docs.
16
17[`plugin`]: plugin.md
18
19------------------------
20"##,
21 },
22 LintCompletion {
23 label: "inline_const",
24 description: r##"# `inline_const`
25
26The tracking issue for this feature is: [#76001]
27
28------
29
30This feature allows you to use inline constant expressions. For example, you can
31turn this code:
32
33```rust
34# fn add_one(x: i32) -> i32 { x + 1 }
35const MY_COMPUTATION: i32 = 1 + 2 * 3 / 4;
36
37fn main() {
38 let x = add_one(MY_COMPUTATION);
39} 6}
40```
41
42into this code:
43
44```rust
45#![feature(inline_const)]
46 7
47# fn add_one(x: i32) -> i32 { x + 1 } 8pub const DEFAULT_LINTS: &[Lint] = &[
48fn main() { 9 Lint {
49 let x = add_one(const { 1 + 2 * 3 / 4 }); 10 label: "absolute_paths_not_starting_with_crate",
50} 11 description: r##"fully qualified paths that start with a module name instead of `crate`, `self`, or an extern crate name"##,
51``` 12 },
52 13 Lint { label: "ambiguous_associated_items", description: r##"ambiguous associated items"## },
53You can also use inline constant expressions in patterns: 14 Lint { label: "anonymous_parameters", description: r##"detects anonymous parameters"## },
54 15 Lint { label: "arithmetic_overflow", description: r##"arithmetic operation overflows"## },
55```rust 16 Lint { label: "array_into_iter", description: r##"detects calling `into_iter` on arrays"## },
56#![feature(inline_const)] 17 Lint {
57 18 label: "asm_sub_register",
58const fn one() -> i32 { 1 } 19 description: r##"using only a subset of a register for inline asm inputs"##,
59 20 },
60let some_int = 3; 21 Lint { label: "bad_asm_style", description: r##"incorrect use of inline assembly"## },
61match some_int { 22 Lint {
62 const { 1 + 2 } => println!("Matched 1 + 2"), 23 label: "bare_trait_objects",
63 const { one() } => println!("Matched const fn returning 1"), 24 description: r##"suggest using `dyn Trait` for trait objects"##,
64 _ => println!("Didn't match anything :("), 25 },
65} 26 Lint {
66``` 27 label: "bindings_with_variant_name",
67 28 description: r##"detects pattern bindings with the same name as one of the matched variants"##,
68[#76001]: https://github.com/rust-lang/rust/issues/76001 29 },
69"##, 30 Lint { label: "box_pointers", description: r##"use of owned (Box type) heap memory"## },
31 Lint {
32 label: "cenum_impl_drop_cast",
33 description: r##"a C-like enum implementing Drop is cast"##,
34 },
35 Lint {
36 label: "clashing_extern_declarations",
37 description: r##"detects when an extern fn has been declared with the same name but different types"##,
38 },
39 Lint {
40 label: "coherence_leak_check",
41 description: r##"distinct impls distinguished only by the leak-check code"##,
42 },
43 Lint {
44 label: "conflicting_repr_hints",
45 description: r##"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice"##,
46 },
47 Lint {
48 label: "confusable_idents",
49 description: r##"detects visually confusable pairs between identifiers"##,
50 },
51 Lint {
52 label: "const_err",
53 description: r##"constant evaluation encountered erroneous expression"##,
54 },
55 Lint {
56 label: "const_evaluatable_unchecked",
57 description: r##"detects a generic constant is used in a type without a emitting a warning"##,
58 },
59 Lint {
60 label: "const_item_mutation",
61 description: r##"detects attempts to mutate a `const` item"##,
62 },
63 Lint { label: "dead_code", description: r##"detect unused, unexported items"## },
64 Lint { label: "deprecated", description: r##"detects use of deprecated items"## },
65 Lint {
66 label: "deprecated_in_future",
67 description: r##"detects use of items that will be deprecated in a future version"##,
68 },
69 Lint {
70 label: "deref_nullptr",
71 description: r##"detects when an null pointer is dereferenced"##,
72 },
73 Lint {
74 label: "disjoint_capture_migration",
75 description: r##"Drop reorder and auto traits error because of `capture_disjoint_fields`"##,
76 },
77 Lint { label: "drop_bounds", description: r##"bounds of the form `T: Drop` are useless"## },
78 Lint {
79 label: "elided_lifetimes_in_paths",
80 description: r##"hidden lifetime parameters in types are deprecated"##,
81 },
82 Lint {
83 label: "ellipsis_inclusive_range_patterns",
84 description: r##"`...` range patterns are deprecated"##,
85 },
86 Lint {
87 label: "explicit_outlives_requirements",
88 description: r##"outlives requirements can be inferred"##,
89 },
90 Lint {
91 label: "exported_private_dependencies",
92 description: r##"public interface leaks type from a private dependency"##,
93 },
94 Lint { label: "forbidden_lint_groups", description: r##"applying forbid to lint-groups"## },
95 Lint {
96 label: "function_item_references",
97 description: r##"suggest casting to a function pointer when attempting to take references to function items"##,
98 },
99 Lint {
100 label: "future_incompatible",
101 description: r##"lint group for: keyword-idents, anonymous-parameters, ellipsis-inclusive-range-patterns, 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, tyvar-behind-raw-pointer, bare-trait-objects, absolute-paths-not-starting-with-crate, 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, semicolon-in-expressions-from-macros, legacy-derive-helpers, proc-macro-back-compat, array-into-iter"##,
102 },
103 Lint {
104 label: "ill_formed_attribute_input",
105 description: r##"ill-formed attribute inputs that were previously accepted and used in practice"##,
106 },
107 Lint {
108 label: "illegal_floating_point_literal_pattern",
109 description: r##"floating-point literals cannot be used in patterns"##,
110 },
111 Lint {
112 label: "improper_ctypes",
113 description: r##"proper use of libc types in foreign modules"##,
114 },
115 Lint {
116 label: "improper_ctypes_definitions",
117 description: r##"proper use of libc types in foreign item definitions"##,
118 },
119 Lint {
120 label: "incomplete_features",
121 description: r##"incomplete features that may function improperly in some or all cases"##,
122 },
123 Lint { label: "incomplete_include", description: r##"trailing content in included file"## },
124 Lint {
125 label: "indirect_structural_match",
126 description: r##"constant used in pattern contains value of non-structural-match type in a field or a variant"##,
127 },
128 Lint {
129 label: "ineffective_unstable_trait_impl",
130 description: r##"detects `#[unstable]` on stable trait implementations for stable types"##,
131 },
132 Lint {
133 label: "inline_no_sanitize",
134 description: r##"detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`"##,
135 },
136 Lint {
137 label: "invalid_type_param_default",
138 description: r##"type parameter default erroneously allowed in invalid location"##,
139 },
140 Lint {
141 label: "invalid_value",
142 description: r##"an invalid value is being created (such as a null reference)"##,
143 },
144 Lint {
145 label: "irrefutable_let_patterns",
146 description: r##"detects irrefutable patterns in `if let` and `while let` statements"##,
147 },
148 Lint {
149 label: "keyword_idents",
150 description: r##"detects edition keywords being used as an identifier"##,
151 },
152 Lint { label: "large_assignments", description: r##"detects large moves or copies"## },
153 Lint {
154 label: "late_bound_lifetime_arguments",
155 description: r##"detects generic lifetime arguments in path segments with late bound lifetime parameters"##,
156 },
157 Lint {
158 label: "legacy_derive_helpers",
159 description: r##"detects derive helper attributes that are used before they are introduced"##,
160 },
161 Lint {
162 label: "macro_expanded_macro_exports_accessed_by_absolute_paths",
163 description: r##"macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"##,
164 },
165 Lint {
166 label: "macro_use_extern_crate",
167 description: r##"the `#[macro_use]` attribute is now deprecated in favor of using macros via the module system"##,
168 },
169 Lint {
170 label: "meta_variable_misuse",
171 description: r##"possible meta-variable misuse at macro definition"##,
172 },
173 Lint { label: "missing_abi", description: r##"No declared ABI for extern declaration"## },
174 Lint {
175 label: "missing_copy_implementations",
176 description: r##"detects potentially-forgotten implementations of `Copy`"##,
177 },
178 Lint {
179 label: "missing_debug_implementations",
180 description: r##"detects missing implementations of Debug"##,
181 },
182 Lint {
183 label: "missing_docs",
184 description: r##"detects missing documentation for public members"##,
185 },
186 Lint {
187 label: "missing_fragment_specifier",
188 description: r##"detects missing fragment specifiers in unused `macro_rules!` patterns"##,
189 },
190 Lint {
191 label: "mixed_script_confusables",
192 description: r##"detects Unicode scripts whose mixed script confusables codepoints are solely used"##,
193 },
194 Lint {
195 label: "mutable_borrow_reservation_conflict",
196 description: r##"reservation of a two-phased borrow conflicts with other shared borrows"##,
197 },
198 Lint {
199 label: "mutable_transmutes",
200 description: r##"mutating transmuted &mut T from &T may cause undefined behavior"##,
201 },
202 Lint {
203 label: "no_mangle_const_items",
204 description: r##"const items will not have their symbols exported"##,
205 },
206 Lint { label: "no_mangle_generic_items", description: r##"generic items must be mangled"## },
207 Lint { label: "non_ascii_idents", description: r##"detects non-ASCII identifiers"## },
208 Lint {
209 label: "non_camel_case_types",
210 description: r##"types, variants, traits and type parameters should have camel case names"##,
211 },
212 Lint {
213 label: "non_fmt_panic",
214 description: r##"detect single-argument panic!() invocations in which the argument is not a format string"##,
215 },
216 Lint {
217 label: "non_shorthand_field_patterns",
218 description: r##"using `Struct { x: x }` instead of `Struct { x }` in a pattern"##,
219 },
220 Lint {
221 label: "non_snake_case",
222 description: r##"variables, methods, functions, lifetime parameters and modules should have snake case names"##,
223 },
224 Lint {
225 label: "non_upper_case_globals",
226 description: r##"static constants should have uppercase identifiers"##,
227 },
228 Lint {
229 label: "nonstandard_style",
230 description: r##"lint group for: non-camel-case-types, non-snake-case, non-upper-case-globals"##,
231 },
232 Lint {
233 label: "nontrivial_structural_match",
234 description: r##"constant used in pattern of non-structural-match type and the constant's initializer expression contains values of non-structural-match types"##,
235 },
236 Lint {
237 label: "noop_method_call",
238 description: r##"detects the use of well-known noop methods"##,
239 },
240 Lint {
241 label: "or_patterns_back_compat",
242 description: r##"detects usage of old versions of or-patterns"##,
243 },
244 Lint {
245 label: "order_dependent_trait_objects",
246 description: r##"trait-object types were treated as different depending on marker-trait order"##,
247 },
248 Lint { label: "overflowing_literals", description: r##"literal out of range for its type"## },
249 Lint {
250 label: "overlapping_range_endpoints",
251 description: r##"detects range patterns with overlapping endpoints"##,
252 },
253 Lint { label: "path_statements", description: r##"path statements with no effect"## },
254 Lint {
255 label: "patterns_in_fns_without_body",
256 description: r##"patterns in functions without body were erroneously allowed"##,
257 },
258 Lint {
259 label: "pointer_structural_match",
260 description: r##"pointers are not structural-match"##,
261 },
262 Lint {
263 label: "private_in_public",
264 description: r##"detect private items in public interfaces not caught by the old implementation"##,
265 },
266 Lint {
267 label: "proc_macro_back_compat",
268 description: r##"detects usage of old versions of certain proc-macro crates"##,
269 },
270 Lint {
271 label: "proc_macro_derive_resolution_fallback",
272 description: r##"detects proc macro derives using inaccessible names from parent modules"##,
273 },
274 Lint {
275 label: "pub_use_of_private_extern_crate",
276 description: r##"detect public re-exports of private extern crates"##,
277 },
278 Lint {
279 label: "redundant_semicolons",
280 description: r##"detects unnecessary trailing semicolons"##,
281 },
282 Lint {
283 label: "renamed_and_removed_lints",
284 description: r##"lints that have been renamed or removed"##,
285 },
286 Lint {
287 label: "rust_2018_compatibility",
288 description: r##"lint group for: keyword-idents, anonymous-parameters, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate"##,
289 },
290 Lint {
291 label: "rust_2018_idioms",
292 description: r##"lint group for: bare-trait-objects, unused-extern-crates, ellipsis-inclusive-range-patterns, elided-lifetimes-in-paths, explicit-outlives-requirements"##,
293 },
294 Lint {
295 label: "rust_2021_compatibility",
296 description: r##"lint group for: ellipsis-inclusive-range-patterns, bare-trait-objects"##,
297 },
298 Lint {
299 label: "semicolon_in_expressions_from_macros",
300 description: r##"trailing semicolon in macro body used as expression"##,
301 },
302 Lint {
303 label: "single_use_lifetimes",
304 description: r##"detects lifetime parameters that are only used once"##,
305 },
306 Lint {
307 label: "soft_unstable",
308 description: r##"a feature gate that doesn't break dependent crates"##,
309 },
310 Lint {
311 label: "stable_features",
312 description: r##"stable features found in `#[feature]` directive"##,
313 },
314 Lint {
315 label: "temporary_cstring_as_ptr",
316 description: r##"detects getting the inner pointer of a temporary `CString`"##,
317 },
318 Lint {
319 label: "trivial_bounds",
320 description: r##"these bounds don't depend on an type parameters"##,
321 },
322 Lint {
323 label: "trivial_casts",
324 description: r##"detects trivial casts which could be removed"##,
325 },
326 Lint {
327 label: "trivial_numeric_casts",
328 description: r##"detects trivial casts of numeric types which could be removed"##,
329 },
330 Lint {
331 label: "type_alias_bounds",
332 description: r##"bounds in type aliases are not enforced"##,
333 },
334 Lint {
335 label: "tyvar_behind_raw_pointer",
336 description: r##"raw pointer to an inference variable"##,
337 },
338 Lint {
339 label: "unaligned_references",
340 description: r##"detects unaligned references to fields of packed structs"##,
341 },
342 Lint {
343 label: "uncommon_codepoints",
344 description: r##"detects uncommon Unicode codepoints in identifiers"##,
345 },
346 Lint {
347 label: "unconditional_panic",
348 description: r##"operation will cause a panic at runtime"##,
349 },
350 Lint {
351 label: "unconditional_recursion",
352 description: r##"functions that cannot return without calling themselves"##,
353 },
354 Lint { label: "uninhabited_static", description: r##"uninhabited static"## },
355 Lint {
356 label: "unknown_crate_types",
357 description: r##"unknown crate type found in `#[crate_type]` directive"##,
358 },
359 Lint { label: "unknown_lints", description: r##"unrecognized lint attribute"## },
360 Lint {
361 label: "unnameable_test_items",
362 description: r##"detects an item that cannot be named being marked as `#[test_case]`"##,
363 },
364 Lint { label: "unreachable_code", description: r##"detects unreachable code paths"## },
365 Lint { label: "unreachable_patterns", description: r##"detects unreachable patterns"## },
366 Lint {
367 label: "unreachable_pub",
368 description: r##"`pub` items not reachable from crate root"##,
369 },
370 Lint { label: "unsafe_code", description: r##"usage of `unsafe` code"## },
371 Lint {
372 label: "unsafe_op_in_unsafe_fn",
373 description: r##"unsafe operations in unsafe functions without an explicit unsafe block are deprecated"##,
374 },
375 Lint {
376 label: "unstable_features",
377 description: r##"enabling unstable features (deprecated. do not use)"##,
378 },
379 Lint {
380 label: "unstable_name_collisions",
381 description: r##"detects name collision with an existing but unstable method"##,
382 },
383 Lint {
384 label: "unsupported_naked_functions",
385 description: r##"unsupported naked function definitions"##,
386 },
387 Lint {
388 label: "unused",
389 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"##,
390 },
391 Lint {
392 label: "unused_allocation",
393 description: r##"detects unnecessary allocations that can be eliminated"##,
394 },
395 Lint {
396 label: "unused_assignments",
397 description: r##"detect assignments that will never be read"##,
398 },
399 Lint {
400 label: "unused_attributes",
401 description: r##"detects attributes that were not used by the compiler"##,
402 },
403 Lint { label: "unused_braces", description: r##"unnecessary braces around an expression"## },
404 Lint {
405 label: "unused_comparisons",
406 description: r##"comparisons made useless by limits of the types involved"##,
407 },
408 Lint {
409 label: "unused_crate_dependencies",
410 description: r##"crate dependencies that are never used"##,
411 },
412 Lint {
413 label: "unused_doc_comments",
414 description: r##"detects doc comments that aren't used by rustdoc"##,
415 },
416 Lint { label: "unused_extern_crates", description: r##"extern crates that are never used"## },
417 Lint {
418 label: "unused_features",
419 description: r##"unused features found in crate-level `#[feature]` directives"##,
420 },
421 Lint {
422 label: "unused_import_braces",
423 description: r##"unnecessary braces around an imported item"##,
424 },
425 Lint { label: "unused_imports", description: r##"imports that are never used"## },
426 Lint { label: "unused_labels", description: r##"detects labels that are never used"## },
427 Lint {
428 label: "unused_lifetimes",
429 description: r##"detects lifetime parameters that are never used"##,
430 },
431 Lint { label: "unused_macros", description: r##"detects macros that were not used"## },
432 Lint {
433 label: "unused_must_use",
434 description: r##"unused result of a type flagged as `#[must_use]`"##,
435 },
436 Lint {
437 label: "unused_mut",
438 description: r##"detect mut variables which don't need to be mutable"##,
439 },
440 Lint {
441 label: "unused_parens",
442 description: r##"`if`, `match`, `while` and `return` do not need parentheses"##,
443 },
444 Lint {
445 label: "unused_qualifications",
446 description: r##"detects unnecessarily qualified names"##,
447 },
448 Lint {
449 label: "unused_results",
450 description: r##"unused result of an expression in a statement"##,
451 },
452 Lint { label: "unused_unsafe", description: r##"unnecessary use of an `unsafe` block"## },
453 Lint {
454 label: "unused_variables",
455 description: r##"detect variables which are not used in any way"##,
456 },
457 Lint {
458 label: "useless_deprecated",
459 description: r##"detects deprecation attributes with no effect"##,
460 },
461 Lint {
462 label: "variant_size_differences",
463 description: r##"detects enums with widely varying variant sizes"##,
464 },
465 Lint {
466 label: "warnings",
467 description: r##"mass-change the level for lints which produce warnings"##,
468 },
469 Lint {
470 label: "warnings",
471 description: r##"lint group for: all lints that are set to issue warnings"##,
472 },
473 Lint {
474 label: "where_clauses_object_safety",
475 description: r##"checks the object safety of where clauses"##,
476 },
477 Lint {
478 label: "while_true",
479 description: r##"suggest using `loop { }` instead of `while true { }`"##,
70 }, 480 },
71 LintCompletion { 481];
72 label: "auto_traits",
73 description: r##"# `auto_traits`
74
75The tracking issue for this feature is [#13231]
76
77[#13231]: https://github.com/rust-lang/rust/issues/13231
78
79----
80
81The `auto_traits` feature gate allows you to define auto traits.
82
83Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits
84that are automatically implemented for every type, unless the type, or a type it contains,
85has explicitly opted out via a negative impl. (Negative impls are separately controlled
86by the `negative_impls` feature.)
87
88[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
89[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
90
91```rust,ignore (partial-example)
92impl !Trait for Type {}
93```
94
95Example:
96
97```rust
98#![feature(negative_impls)]
99#![feature(auto_traits)]
100
101auto trait Valid {}
102
103struct True;
104struct False;
105
106impl !Valid for False {}
107
108struct MaybeValid<T>(T);
109
110fn must_be_valid<T: Valid>(_t: T) { }
111
112fn main() {
113 // works
114 must_be_valid( MaybeValid(True) );
115
116 // compiler error - trait bound not satisfied
117 // must_be_valid( MaybeValid(False) );
118}
119```
120
121## Automatic trait implementations
122
123When a type is declared as an `auto trait`, we will automatically
124create impls for every struct/enum/union, unless an explicit impl is
125provided. These automatic impls contain a where clause for each field
126of the form `T: AutoTrait`, where `T` is the type of the field and
127`AutoTrait` is the auto trait in question. As an example, consider the
128struct `List` and the auto trait `Send`:
129
130```rust
131struct List<T> {
132 data: T,
133 next: Option<Box<List<T>>>,
134}
135```
136
137Presuming that there is no explicit impl of `Send` for `List`, the
138compiler will supply an automatic impl of the form:
139
140```rust
141struct List<T> {
142 data: T,
143 next: Option<Box<List<T>>>,
144}
145
146unsafe impl<T> Send for List<T>
147where
148 T: Send, // from the field `data`
149 Option<Box<List<T>>>: Send, // from the field `next`
150{ }
151```
152
153Explicit impls may be either positive or negative. They take the form:
154
155```rust,ignore (partial-example)
156impl<...> AutoTrait for StructName<..> { }
157impl<...> !AutoTrait for StructName<..> { }
158```
159
160## Coinduction: Auto traits permit cyclic matching
161
162Unlike ordinary trait matching, auto traits are **coinductive**. This
163means, in short, that cycles which occur in trait matching are
164considered ok. As an example, consider the recursive struct `List`
165introduced in the previous section. In attempting to determine whether
166`List: Send`, we would wind up in a cycle: to apply the impl, we must
167show that `Option<Box<List>>: Send`, which will in turn require
168`Box<List>: Send` and then finally `List: Send` again. Under ordinary
169trait matching, this cycle would be an error, but for an auto trait it
170is considered a successful match.
171
172## Items
173
174Auto traits cannot have any trait items, such as methods or associated types. This ensures that we can generate default implementations.
175
176## Supertraits
177
178Auto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile.
179"##,
180 },
181 LintCompletion {
182 label: "ffi_const",
183 description: r##"# `ffi_const`
184
185The tracking issue for this feature is: [#58328]
186
187------
188
189The `#[ffi_const]` attribute applies clang's `const` attribute to foreign
190functions declarations.
191
192That is, `#[ffi_const]` functions shall have no effects except for its return
193value, which can only depend on the values of the function parameters, and is
194not affected by changes to the observable state of the program.
195
196Applying the `#[ffi_const]` attribute to a function that violates these
197requirements is undefined behaviour.
198
199This attribute enables Rust to perform common optimizations, like sub-expression
200elimination, and it can avoid emitting some calls in repeated invocations of the
201function with the same argument values regardless of other operations being
202performed in between these functions calls (as opposed to `#[ffi_pure]`
203functions).
204
205## Pitfalls
206
207A `#[ffi_const]` function can only read global memory that would not affect
208its return value for the whole execution of the program (e.g. immutable global
209memory). `#[ffi_const]` functions are referentially-transparent and therefore
210more strict than `#[ffi_pure]` functions.
211
212A common pitfall involves applying the `#[ffi_const]` attribute to a
213function that reads memory through pointer arguments which do not necessarily
214point to immutable global memory.
215
216A `#[ffi_const]` function that returns unit has no effect on the abstract
217machine's state, and a `#[ffi_const]` function cannot be `#[ffi_pure]`.
218
219A `#[ffi_const]` function must not diverge, neither via a side effect (e.g. a
220call to `abort`) nor by infinite loops.
221
222When translating C headers to Rust FFI, it is worth verifying for which targets
223the `const` attribute is enabled in those headers, and using the appropriate
224`cfg` macros in the Rust side to match those definitions. While the semantics of
225`const` are implemented identically by many C and C++ compilers, e.g., clang,
226[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily
227implemented in this way on all of them. It is therefore also worth verifying
228that the semantics of the C toolchain used to compile the binary being linked
229against are compatible with those of the `#[ffi_const]`.
230
231[#58328]: https://github.com/rust-lang/rust/issues/58328
232[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacgigch.html
233[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute
234[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_const.htm
235"##,
236 },
237 LintCompletion {
238 label: "external_doc",
239 description: r##"# `external_doc`
240
241The tracking issue for this feature is: [#44732]
242
243The `external_doc` feature allows the use of the `include` parameter to the `#[doc]` attribute, to
244include external files in documentation. Use the attribute in place of, or in addition to, regular
245doc comments and `#[doc]` attributes, and `rustdoc` will load the given file when it renders
246documentation for your crate.
247
248With the following files in the same directory:
249
250`external-doc.md`:
251
252```markdown
253# My Awesome Type
254
255This is the documentation for this spectacular type.
256```
257
258`lib.rs`:
259
260```no_run (needs-external-files)
261#![feature(external_doc)]
262
263#[doc(include = "external-doc.md")]
264pub struct MyAwesomeType;
265```
266
267`rustdoc` will load the file `external-doc.md` and use it as the documentation for the `MyAwesomeType`
268struct.
269
270When locating files, `rustdoc` will base paths in the `src/` directory, as if they were alongside the
271`lib.rs` for your crate. So if you want a `docs/` folder to live alongside the `src/` directory,
272start your paths with `../docs/` for `rustdoc` to properly find the file.
273
274This feature was proposed in [RFC #1990] and initially implemented in PR [#44781].
275
276[#44732]: https://github.com/rust-lang/rust/issues/44732
277[RFC #1990]: https://github.com/rust-lang/rfcs/pull/1990
278[#44781]: https://github.com/rust-lang/rust/pull/44781
279"##,
280 },
281 LintCompletion {
282 label: "box_patterns",
283 description: r##"# `box_patterns`
284
285The tracking issue for this feature is: [#29641]
286
287[#29641]: https://github.com/rust-lang/rust/issues/29641
288
289See also [`box_syntax`](box-syntax.md)
290
291------------------------
292
293Box patterns let you match on `Box<T>`s:
294
295
296```rust
297#![feature(box_patterns)]
298 482
299fn main() { 483pub const FEATURES: &[Lint] = &[
300 let b = Some(Box::new(5)); 484 Lint {
301 match b {
302 Some(box n) if n < 0 => {
303 println!("Box contains negative number {}", n);
304 },
305 Some(box n) if n >= 0 => {
306 println!("Box contains non-negative number {}", n);
307 },
308 None => {
309 println!("No box");
310 },
311 _ => unreachable!()
312 }
313}
314```
315"##,
316 },
317 LintCompletion {
318 label: "abi_c_cmse_nonsecure_call", 485 label: "abi_c_cmse_nonsecure_call",
319 description: r##"# `abi_c_cmse_nonsecure_call` 486 description: r##"# `abi_c_cmse_nonsecure_call`
320 487
@@ -406,1682 +573,7 @@ call_nonsecure_function:
406``` 573```
407"##, 574"##,
408 }, 575 },
409 LintCompletion { 576 Lint {
410 label: "member_constraints",
411 description: r##"# `member_constraints`
412
413The tracking issue for this feature is: [#61997]
414
415[#61997]: https://github.com/rust-lang/rust/issues/61997
416
417------------------------
418
419The `member_constraints` feature gate lets you use `impl Trait` syntax with
420multiple unrelated lifetime parameters.
421
422A simple example is:
423
424```rust
425#![feature(member_constraints)]
426
427trait Trait<'a, 'b> { }
428impl<T> Trait<'_, '_> for T {}
429
430fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Trait<'a, 'b> {
431 (x, y)
432}
433
434fn main() { }
435```
436
437Without the `member_constraints` feature gate, the above example is an
438error because both `'a` and `'b` appear in the impl Trait bounds, but
439neither outlives the other.
440"##,
441 },
442 LintCompletion {
443 label: "allocator_internals",
444 description: r##"# `allocator_internals`
445
446This feature does not have a tracking issue, it is an unstable implementation
447detail of the `global_allocator` feature not intended for use outside the
448compiler.
449
450------------------------
451"##,
452 },
453 LintCompletion {
454 label: "cfg_sanitize",
455 description: r##"# `cfg_sanitize`
456
457The tracking issue for this feature is: [#39699]
458
459[#39699]: https://github.com/rust-lang/rust/issues/39699
460
461------------------------
462
463The `cfg_sanitize` feature makes it possible to execute different code
464depending on whether a particular sanitizer is enabled or not.
465
466## Examples
467
468```rust
469#![feature(cfg_sanitize)]
470
471#[cfg(sanitize = "thread")]
472fn a() {
473 // ...
474}
475
476#[cfg(not(sanitize = "thread"))]
477fn a() {
478 // ...
479}
480
481fn b() {
482 if cfg!(sanitize = "leak") {
483 // ...
484 } else {
485 // ...
486 }
487}
488```
489"##,
490 },
491 LintCompletion {
492 label: "cfg_panic",
493 description: r##"# `cfg_panic`
494
495The tracking issue for this feature is: [#77443]
496
497[#77443]: https://github.com/rust-lang/rust/issues/77443
498
499------------------------
500
501The `cfg_panic` feature makes it possible to execute different code
502depending on the panic strategy.
503
504Possible values at the moment are `"unwind"` or `"abort"`, although
505it is possible that new panic strategies may be added to Rust in the
506future.
507
508## Examples
509
510```rust
511#![feature(cfg_panic)]
512
513#[cfg(panic = "unwind")]
514fn a() {
515 // ...
516}
517
518#[cfg(not(panic = "unwind"))]
519fn a() {
520 // ...
521}
522
523fn b() {
524 if cfg!(panic = "abort") {
525 // ...
526 } else {
527 // ...
528 }
529}
530```
531"##,
532 },
533 LintCompletion {
534 label: "ffi_pure",
535 description: r##"# `ffi_pure`
536
537The tracking issue for this feature is: [#58329]
538
539------
540
541The `#[ffi_pure]` attribute applies clang's `pure` attribute to foreign
542functions declarations.
543
544That is, `#[ffi_pure]` functions shall have no effects except for its return
545value, which shall not change across two consecutive function calls with
546the same parameters.
547
548Applying the `#[ffi_pure]` attribute to a function that violates these
549requirements is undefined behavior.
550
551This attribute enables Rust to perform common optimizations, like sub-expression
552elimination and loop optimizations. Some common examples of pure functions are
553`strlen` or `memcmp`.
554
555These optimizations are only applicable when the compiler can prove that no
556program state observable by the `#[ffi_pure]` function has changed between calls
557of the function, which could alter the result. See also the `#[ffi_const]`
558attribute, which provides stronger guarantees regarding the allowable behavior
559of a function, enabling further optimization.
560
561## Pitfalls
562
563A `#[ffi_pure]` function can read global memory through the function
564parameters (e.g. pointers), globals, etc. `#[ffi_pure]` functions are not
565referentially-transparent, and are therefore more relaxed than `#[ffi_const]`
566functions.
567
568However, accessing global memory through volatile or atomic reads can violate the
569requirement that two consecutive function calls shall return the same value.
570
571A `pure` function that returns unit has no effect on the abstract machine's
572state.
573
574A `#[ffi_pure]` function must not diverge, neither via a side effect (e.g. a
575call to `abort`) nor by infinite loops.
576
577When translating C headers to Rust FFI, it is worth verifying for which targets
578the `pure` attribute is enabled in those headers, and using the appropriate
579`cfg` macros in the Rust side to match those definitions. While the semantics of
580`pure` are implemented identically by many C and C++ compilers, e.g., clang,
581[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily
582implemented in this way on all of them. It is therefore also worth verifying
583that the semantics of the C toolchain used to compile the binary being linked
584against are compatible with those of the `#[ffi_pure]`.
585
586
587[#58329]: https://github.com/rust-lang/rust/issues/58329
588[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacigdac.html
589[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
590[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_pure.htm
591"##,
592 },
593 LintCompletion {
594 label: "repr128",
595 description: r##"# `repr128`
596
597The tracking issue for this feature is: [#56071]
598
599[#56071]: https://github.com/rust-lang/rust/issues/56071
600
601------------------------
602
603The `repr128` feature adds support for `#[repr(u128)]` on `enum`s.
604
605```rust
606#![feature(repr128)]
607
608#[repr(u128)]
609enum Foo {
610 Bar(u64),
611}
612```
613"##,
614 },
615 LintCompletion {
616 label: "generators",
617 description: r##"# `generators`
618
619The tracking issue for this feature is: [#43122]
620
621[#43122]: https://github.com/rust-lang/rust/issues/43122
622
623------------------------
624
625The `generators` feature gate in Rust allows you to define generator or
626coroutine literals. A generator is a "resumable function" that syntactically
627resembles a closure but compiles to much different semantics in the compiler
628itself. The primary feature of a generator is that it can be suspended during
629execution to be resumed at a later date. Generators use the `yield` keyword to
630"return", and then the caller can `resume` a generator to resume execution just
631after the `yield` keyword.
632
633Generators are an extra-unstable feature in the compiler right now. Added in
634[RFC 2033] they're mostly intended right now as a information/constraint
635gathering phase. The intent is that experimentation can happen on the nightly
636compiler before actual stabilization. A further RFC will be required to
637stabilize generators/coroutines and will likely contain at least a few small
638tweaks to the overall design.
639
640[RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033
641
642A syntactical example of a generator is:
643
644```rust
645#![feature(generators, generator_trait)]
646
647use std::ops::{Generator, GeneratorState};
648use std::pin::Pin;
649
650fn main() {
651 let mut generator = || {
652 yield 1;
653 return "foo"
654 };
655
656 match Pin::new(&mut generator).resume(()) {
657 GeneratorState::Yielded(1) => {}
658 _ => panic!("unexpected value from resume"),
659 }
660 match Pin::new(&mut generator).resume(()) {
661 GeneratorState::Complete("foo") => {}
662 _ => panic!("unexpected value from resume"),
663 }
664}
665```
666
667Generators are closure-like literals which can contain a `yield` statement. The
668`yield` statement takes an optional expression of a value to yield out of the
669generator. All generator literals implement the `Generator` trait in the
670`std::ops` module. The `Generator` trait has one main method, `resume`, which
671resumes execution of the generator at the previous suspension point.
672
673An example of the control flow of generators is that the following example
674prints all numbers in order:
675
676```rust
677#![feature(generators, generator_trait)]
678
679use std::ops::Generator;
680use std::pin::Pin;
681
682fn main() {
683 let mut generator = || {
684 println!("2");
685 yield;
686 println!("4");
687 };
688
689 println!("1");
690 Pin::new(&mut generator).resume(());
691 println!("3");
692 Pin::new(&mut generator).resume(());
693 println!("5");
694}
695```
696
697At this time the main intended use case of generators is an implementation
698primitive for async/await syntax, but generators will likely be extended to
699ergonomic implementations of iterators and other primitives in the future.
700Feedback on the design and usage is always appreciated!
701
702### The `Generator` trait
703
704The `Generator` trait in `std::ops` currently looks like:
705
706```rust
707# #![feature(arbitrary_self_types, generator_trait)]
708# use std::ops::GeneratorState;
709# use std::pin::Pin;
710
711pub trait Generator<R = ()> {
712 type Yield;
713 type Return;
714 fn resume(self: Pin<&mut Self>, resume: R) -> GeneratorState<Self::Yield, Self::Return>;
715}
716```
717
718The `Generator::Yield` type is the type of values that can be yielded with the
719`yield` statement. The `Generator::Return` type is the returned type of the
720generator. This is typically the last expression in a generator's definition or
721any value passed to `return` in a generator. The `resume` function is the entry
722point for executing the `Generator` itself.
723
724The return value of `resume`, `GeneratorState`, looks like:
725
726```rust
727pub enum GeneratorState<Y, R> {
728 Yielded(Y),
729 Complete(R),
730}
731```
732
733The `Yielded` variant indicates that the generator can later be resumed. This
734corresponds to a `yield` point in a generator. The `Complete` variant indicates
735that the generator is complete and cannot be resumed again. Calling `resume`
736after a generator has returned `Complete` will likely result in a panic of the
737program.
738
739### Closure-like semantics
740
741The closure-like syntax for generators alludes to the fact that they also have
742closure-like semantics. Namely:
743
744* When created, a generator executes no code. A closure literal does not
745 actually execute any of the closure's code on construction, and similarly a
746 generator literal does not execute any code inside the generator when
747 constructed.
748
749* Generators can capture outer variables by reference or by move, and this can
750 be tweaked with the `move` keyword at the beginning of the closure. Like
751 closures all generators will have an implicit environment which is inferred by
752 the compiler. Outer variables can be moved into a generator for use as the
753 generator progresses.
754
755* Generator literals produce a value with a unique type which implements the
756 `std::ops::Generator` trait. This allows actual execution of the generator
757 through the `Generator::resume` method as well as also naming it in return
758 types and such.
759
760* Traits like `Send` and `Sync` are automatically implemented for a `Generator`
761 depending on the captured variables of the environment. Unlike closures,
762 generators also depend on variables live across suspension points. This means
763 that although the ambient environment may be `Send` or `Sync`, the generator
764 itself may not be due to internal variables live across `yield` points being
765 not-`Send` or not-`Sync`. Note that generators do
766 not implement traits like `Copy` or `Clone` automatically.
767
768* Whenever a generator is dropped it will drop all captured environment
769 variables.
770
771### Generators as state machines
772
773In the compiler, generators are currently compiled as state machines. Each
774`yield` expression will correspond to a different state that stores all live
775variables over that suspension point. Resumption of a generator will dispatch on
776the current state and then execute internally until a `yield` is reached, at
777which point all state is saved off in the generator and a value is returned.
778
779Let's take a look at an example to see what's going on here:
780
781```rust
782#![feature(generators, generator_trait)]
783
784use std::ops::Generator;
785use std::pin::Pin;
786
787fn main() {
788 let ret = "foo";
789 let mut generator = move || {
790 yield 1;
791 return ret
792 };
793
794 Pin::new(&mut generator).resume(());
795 Pin::new(&mut generator).resume(());
796}
797```
798
799This generator literal will compile down to something similar to:
800
801```rust
802#![feature(arbitrary_self_types, generators, generator_trait)]
803
804use std::ops::{Generator, GeneratorState};
805use std::pin::Pin;
806
807fn main() {
808 let ret = "foo";
809 let mut generator = {
810 enum __Generator {
811 Start(&'static str),
812 Yield1(&'static str),
813 Done,
814 }
815
816 impl Generator for __Generator {
817 type Yield = i32;
818 type Return = &'static str;
819
820 fn resume(mut self: Pin<&mut Self>, resume: ()) -> GeneratorState<i32, &'static str> {
821 use std::mem;
822 match mem::replace(&mut *self, __Generator::Done) {
823 __Generator::Start(s) => {
824 *self = __Generator::Yield1(s);
825 GeneratorState::Yielded(1)
826 }
827
828 __Generator::Yield1(s) => {
829 *self = __Generator::Done;
830 GeneratorState::Complete(s)
831 }
832
833 __Generator::Done => {
834 panic!("generator resumed after completion")
835 }
836 }
837 }
838 }
839
840 __Generator::Start(ret)
841 };
842
843 Pin::new(&mut generator).resume(());
844 Pin::new(&mut generator).resume(());
845}
846```
847
848Notably here we can see that the compiler is generating a fresh type,
849`__Generator` in this case. This type has a number of states (represented here
850as an `enum`) corresponding to each of the conceptual states of the generator.
851At the beginning we're closing over our outer variable `foo` and then that
852variable is also live over the `yield` point, so it's stored in both states.
853
854When the generator starts it'll immediately yield 1, but it saves off its state
855just before it does so indicating that it has reached the yield point. Upon
856resuming again we'll execute the `return ret` which returns the `Complete`
857state.
858
859Here we can also note that the `Done` state, if resumed, panics immediately as
860it's invalid to resume a completed generator. It's also worth noting that this
861is just a rough desugaring, not a normative specification for what the compiler
862does.
863"##,
864 },
865 LintCompletion {
866 label: "non_ascii_idents",
867 description: r##"# `non_ascii_idents`
868
869The tracking issue for this feature is: [#55467]
870
871[#55467]: https://github.com/rust-lang/rust/issues/55467
872
873------------------------
874
875The `non_ascii_idents` feature adds support for non-ASCII identifiers.
876
877## Examples
878
879```rust
880#![feature(non_ascii_idents)]
881
882const ε: f64 = 0.00001f64;
883const Π: f64 = 3.14f64;
884```
885
886## Changes to the language reference
887
888> **<sup>Lexer:<sup>**\
889> IDENTIFIER :\
890> &nbsp;&nbsp; &nbsp;&nbsp; XID_start XID_continue<sup>\*</sup>\
891> &nbsp;&nbsp; | `_` XID_continue<sup>+</sup>
892
893An identifier is any nonempty Unicode string of the following form:
894
895Either
896
897 * The first character has property [`XID_start`]
898 * The remaining characters have property [`XID_continue`]
899
900Or
901
902 * The first character is `_`
903 * The identifier is more than one character, `_` alone is not an identifier
904 * The remaining characters have property [`XID_continue`]
905
906that does _not_ occur in the set of [strict keywords].
907
908> **Note**: [`XID_start`] and [`XID_continue`] as character properties cover the
909> character ranges used to form the more familiar C and Java language-family
910> identifiers.
911
912[`XID_start`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Start%3A%5D&abb=on&g=&i=
913[`XID_continue`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Continue%3A%5D&abb=on&g=&i=
914[strict keywords]: ../../reference/keywords.md#strict-keywords
915"##,
916 },
917 LintCompletion {
918 label: "compiler_builtins",
919 description: r##"# `compiler_builtins`
920
921This feature is internal to the Rust compiler and is not intended for general use.
922
923------------------------
924"##,
925 },
926 LintCompletion {
927 label: "or_patterns",
928 description: r##"# `or_patterns`
929
930The tracking issue for this feature is: [#54883]
931
932[#54883]: https://github.com/rust-lang/rust/issues/54883
933
934------------------------
935
936The `or_pattern` language feature allows `|` to be arbitrarily nested within
937a pattern, for example, `Some(A(0) | B(1 | 2))` becomes a valid pattern.
938
939## Examples
940
941```rust,no_run
942#![feature(or_patterns)]
943
944pub enum Foo {
945 Bar,
946 Baz,
947 Quux,
948}
949
950pub fn example(maybe_foo: Option<Foo>) {
951 match maybe_foo {
952 Some(Foo::Bar | Foo::Baz) => {
953 println!("The value contained `Bar` or `Baz`");
954 }
955 Some(_) => {
956 println!("The value did not contain `Bar` or `Baz`");
957 }
958 None => {
959 println!("The value was `None`");
960 }
961 }
962}
963```
964"##,
965 },
966 LintCompletion {
967 label: "negative_impls",
968 description: r##"# `negative_impls`
969
970The tracking issue for this feature is [#68318].
971
972[#68318]: https://github.com/rust-lang/rust/issues/68318
973
974----
975
976With the feature gate `negative_impls`, you can write negative impls as well as positive ones:
977
978```rust
979#![feature(negative_impls)]
980trait DerefMut { }
981impl<T: ?Sized> !DerefMut for &T { }
982```
983
984Negative 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.
985
986Negative impls have the following characteristics:
987
988* They do not have any items.
989* They must obey the orphan rules as if they were a positive impl.
990* They cannot "overlap" with any positive impls.
991
992## Semver interaction
993
994It is a breaking change to remove a negative impl. Negative impls are a commitment not to implement the given trait for the named types.
995
996## Orphan and overlap rules
997
998Negative 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.
999
1000Similarly, 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.)
1001
1002## Interaction with auto traits
1003
1004Declaring a negative impl `impl !SomeAutoTrait for SomeType` for an
1005auto-trait serves two purposes:
1006
1007* as with any trait, it declares that `SomeType` will never implement `SomeAutoTrait`;
1008* it disables the automatic `SomeType: SomeAutoTrait` impl that would otherwise have been generated.
1009
1010Note that, at present, there is no way to indicate that a given type
1011does not implement an auto trait *but that it may do so in the
1012future*. For ordinary types, this is done by simply not declaring any
1013impl at all, but that is not an option for auto traits. A workaround
1014is that one could embed a marker type as one of the fields, where the
1015marker type is `!AutoTrait`.
1016
1017## Immediate uses
1018
1019Negative 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).
1020
1021This serves two purposes:
1022
1023* For proving the correctness of unsafe code, we can use that impl as evidence that no `DerefMut` or `Clone` impl exists.
1024* It prevents downstream crates from creating such impls.
1025"##,
1026 },
1027 LintCompletion {
1028 label: "cmse_nonsecure_entry",
1029 description: r##"# `cmse_nonsecure_entry`
1030
1031The tracking issue for this feature is: [#75835]
1032
1033[#75835]: https://github.com/rust-lang/rust/issues/75835
1034
1035------------------------
1036
1037The [TrustZone-M
1038feature](https://developer.arm.com/documentation/100690/latest/) is available
1039for targets with the Armv8-M architecture profile (`thumbv8m` in their target
1040name).
1041LLVM, the Rust compiler and the linker are providing
1042[support](https://developer.arm.com/documentation/ecm0359818/latest/) for the
1043TrustZone-M feature.
1044
1045One of the things provided, with this unstable feature, is the
1046`cmse_nonsecure_entry` attribute. This attribute marks a Secure function as an
1047entry function (see [section
10485.4](https://developer.arm.com/documentation/ecm0359818/latest/) for details).
1049With this attribute, the compiler will do the following:
1050* add a special symbol on the function which is the `__acle_se_` prefix and the
1051 standard function name
1052* constrain the number of parameters to avoid using the Non-Secure stack
1053* before returning from the function, clear registers that might contain Secure
1054 information
1055* use the `BXNS` instruction to return
1056
1057Because the stack can not be used to pass parameters, there will be compilation
1058errors if:
1059* the total size of all parameters is too big (for example more than four 32
1060 bits integers)
1061* the entry function is not using a C ABI
1062
1063The special symbol `__acle_se_` will be used by the linker to generate a secure
1064gateway veneer.
1065
1066<!-- NOTE(ignore) this example is specific to thumbv8m targets -->
1067
1068``` rust,ignore
1069#![feature(cmse_nonsecure_entry)]
1070
1071#[no_mangle]
1072#[cmse_nonsecure_entry]
1073pub extern "C" fn entry_function(input: u32) -> u32 {
1074 input + 6
1075}
1076```
1077
1078``` text
1079$ rustc --emit obj --crate-type lib --target thumbv8m.main-none-eabi function.rs
1080$ arm-none-eabi-objdump -D function.o
1081
108200000000 <entry_function>:
1083 0: b580 push {r7, lr}
1084 2: 466f mov r7, sp
1085 4: b082 sub sp, #8
1086 6: 9001 str r0, [sp, #4]
1087 8: 1d81 adds r1, r0, #6
1088 a: 460a mov r2, r1
1089 c: 4281 cmp r1, r0
1090 e: 9200 str r2, [sp, #0]
1091 10: d30b bcc.n 2a <entry_function+0x2a>
1092 12: e7ff b.n 14 <entry_function+0x14>
1093 14: 9800 ldr r0, [sp, #0]
1094 16: b002 add sp, #8
1095 18: e8bd 4080 ldmia.w sp!, {r7, lr}
1096 1c: 4671 mov r1, lr
1097 1e: 4672 mov r2, lr
1098 20: 4673 mov r3, lr
1099 22: 46f4 mov ip, lr
1100 24: f38e 8800 msr CPSR_f, lr
1101 28: 4774 bxns lr
1102 2a: f240 0000 movw r0, #0
1103 2e: f2c0 0000 movt r0, #0
1104 32: f240 0200 movw r2, #0
1105 36: f2c0 0200 movt r2, #0
1106 3a: 211c movs r1, #28
1107 3c: f7ff fffe bl 0 <_ZN4core9panicking5panic17h5c028258ca2fb3f5E>
1108 40: defe udf #254 ; 0xfe
1109```
1110"##,
1111 },
1112 LintCompletion {
1113 label: "plugin",
1114 description: r##"# `plugin`
1115
1116The tracking issue for this feature is: [#29597]
1117
1118[#29597]: https://github.com/rust-lang/rust/issues/29597
1119
1120
1121This feature is part of "compiler plugins." It will often be used with the
1122[`plugin_registrar`] and `rustc_private` features.
1123
1124[`plugin_registrar`]: plugin-registrar.md
1125
1126------------------------
1127
1128`rustc` can load compiler plugins, which are user-provided libraries that
1129extend the compiler's behavior with new lint checks, etc.
1130
1131A plugin is a dynamic library crate with a designated *registrar* function that
1132registers extensions with `rustc`. Other crates can load these extensions using
1133the crate attribute `#![plugin(...)]`. See the
1134`rustc_driver::plugin` documentation for more about the
1135mechanics of defining and loading a plugin.
1136
1137In the vast majority of cases, a plugin should *only* be used through
1138`#![plugin]` and not through an `extern crate` item. Linking a plugin would
1139pull in all of librustc_ast and librustc as dependencies of your crate. This is
1140generally unwanted unless you are building another plugin.
1141
1142The usual practice is to put compiler plugins in their own crate, separate from
1143any `macro_rules!` macros or ordinary Rust code meant to be used by consumers
1144of a library.
1145
1146# Lint plugins
1147
1148Plugins can extend [Rust's lint
1149infrastructure](../../reference/attributes/diagnostics.md#lint-check-attributes) with
1150additional checks for code style, safety, etc. Now let's write a plugin
1151[`lint-plugin-test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs)
1152that warns about any item named `lintme`.
1153
1154```rust,ignore (requires-stage-2)
1155#![feature(plugin_registrar)]
1156#![feature(box_syntax, rustc_private)]
1157
1158extern crate rustc_ast;
1159
1160// Load rustc as a plugin to get macros
1161extern crate rustc_driver;
1162#[macro_use]
1163extern crate rustc_lint;
1164#[macro_use]
1165extern crate rustc_session;
1166
1167use rustc_driver::plugin::Registry;
1168use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
1169use rustc_ast::ast;
1170declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
1171
1172declare_lint_pass!(Pass => [TEST_LINT]);
1173
1174impl EarlyLintPass for Pass {
1175 fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
1176 if it.ident.name.as_str() == "lintme" {
1177 cx.lint(TEST_LINT, |lint| {
1178 lint.build("item is named 'lintme'").set_span(it.span).emit()
1179 });
1180 }
1181 }
1182}
1183
1184#[plugin_registrar]
1185pub fn plugin_registrar(reg: &mut Registry) {
1186 reg.lint_store.register_lints(&[&TEST_LINT]);
1187 reg.lint_store.register_early_pass(|| box Pass);
1188}
1189```
1190
1191Then code like
1192
1193```rust,ignore (requires-plugin)
1194#![feature(plugin)]
1195#![plugin(lint_plugin_test)]
1196
1197fn lintme() { }
1198```
1199
1200will produce a compiler warning:
1201
1202```txt
1203foo.rs:4:1: 4:16 warning: item is named 'lintme', #[warn(test_lint)] on by default
1204foo.rs:4 fn lintme() { }
1205 ^~~~~~~~~~~~~~~
1206```
1207
1208The components of a lint plugin are:
1209
1210* one or more `declare_lint!` invocations, which define static `Lint` structs;
1211
1212* a struct holding any state needed by the lint pass (here, none);
1213
1214* a `LintPass`
1215 implementation defining how to check each syntax element. A single
1216 `LintPass` may call `span_lint` for several different `Lint`s, but should
1217 register them all through the `get_lints` method.
1218
1219Lint passes are syntax traversals, but they run at a late stage of compilation
1220where type information is available. `rustc`'s [built-in
1221lints](https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs)
1222mostly use the same infrastructure as lint plugins, and provide examples of how
1223to access type information.
1224
1225Lints defined by plugins are controlled by the usual [attributes and compiler
1226flags](../../reference/attributes/diagnostics.md#lint-check-attributes), e.g.
1227`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the
1228first argument to `declare_lint!`, with appropriate case and punctuation
1229conversion.
1230
1231You can run `rustc -W help foo.rs` to see a list of lints known to `rustc`,
1232including those provided by plugins loaded by `foo.rs`.
1233"##,
1234 },
1235 LintCompletion {
1236 label: "intrinsics",
1237 description: r##"# `intrinsics`
1238
1239The tracking issue for this feature is: None.
1240
1241Intrinsics are never intended to be stable directly, but intrinsics are often
1242exported in some sort of stable manner. Prefer using the stable interfaces to
1243the intrinsic directly when you can.
1244
1245------------------------
1246
1247
1248These are imported as if they were FFI functions, with the special
1249`rust-intrinsic` ABI. For example, if one was in a freestanding
1250context, but wished to be able to `transmute` between types, and
1251perform efficient pointer arithmetic, one would import those functions
1252via a declaration like
1253
1254```rust
1255#![feature(intrinsics)]
1256# fn main() {}
1257
1258extern "rust-intrinsic" {
1259 fn transmute<T, U>(x: T) -> U;
1260
1261 fn offset<T>(dst: *const T, offset: isize) -> *const T;
1262}
1263```
1264
1265As with any other FFI functions, these are always `unsafe` to call.
1266"##,
1267 },
1268 LintCompletion {
1269 label: "rustc_attrs",
1270 description: r##"# `rustc_attrs`
1271
1272This feature has no tracking issue, and is therefore internal to
1273the compiler, not being intended for general use.
1274
1275Note: `rustc_attrs` enables many rustc-internal attributes and this page
1276only discuss a few of them.
1277
1278------------------------
1279
1280The `rustc_attrs` feature allows debugging rustc type layouts by using
1281`#[rustc_layout(...)]` to debug layout at compile time (it even works
1282with `cargo check`) as an alternative to `rustc -Z print-type-sizes`
1283that is way more verbose.
1284
1285Options provided by `#[rustc_layout(...)]` are `debug`, `size`, `align`,
1286`abi`. Note that it only works on sized types without generics.
1287
1288## Examples
1289
1290```rust,compile_fail
1291#![feature(rustc_attrs)]
1292
1293#[rustc_layout(abi, size)]
1294pub enum X {
1295 Y(u8, u8, u8),
1296 Z(isize),
1297}
1298```
1299
1300When that is compiled, the compiler will error with something like
1301
1302```text
1303error: abi: Aggregate { sized: true }
1304 --> src/lib.rs:4:1
1305 |
13064 | / pub enum T {
13075 | | Y(u8, u8, u8),
13086 | | Z(isize),
13097 | | }
1310 | |_^
1311
1312error: size: Size { raw: 16 }
1313 --> src/lib.rs:4:1
1314 |
13154 | / pub enum T {
13165 | | Y(u8, u8, u8),
13176 | | Z(isize),
13187 | | }
1319 | |_^
1320
1321error: aborting due to 2 previous errors
1322```
1323"##,
1324 },
1325 LintCompletion {
1326 label: "const_fn",
1327 description: r##"# `const_fn`
1328
1329The tracking issue for this feature is: [#57563]
1330
1331[#57563]: https://github.com/rust-lang/rust/issues/57563
1332
1333------------------------
1334
1335The `const_fn` feature enables additional functionality not stabilized in the
1336[minimal subset of `const_fn`](https://github.com/rust-lang/rust/issues/53555)
1337"##,
1338 },
1339 LintCompletion {
1340 label: "abi_thiscall",
1341 description: r##"# `abi_thiscall`
1342
1343The tracking issue for this feature is: [#42202]
1344
1345[#42202]: https://github.com/rust-lang/rust/issues/42202
1346
1347------------------------
1348
1349The MSVC ABI on x86 Windows uses the `thiscall` calling convention for C++
1350instance methods by default; it is identical to the usual (C) calling
1351convention on x86 Windows except that the first parameter of the method,
1352the `this` pointer, is passed in the ECX register.
1353"##,
1354 },
1355 LintCompletion {
1356 label: "trait_alias",
1357 description: r##"# `trait_alias`
1358
1359The tracking issue for this feature is: [#41517]
1360
1361[#41517]: https://github.com/rust-lang/rust/issues/41517
1362
1363------------------------
1364
1365The `trait_alias` feature adds support for trait aliases. These allow aliases
1366to be created for one or more traits (currently just a single regular trait plus
1367any number of auto-traits), and used wherever traits would normally be used as
1368either bounds or trait objects.
1369
1370```rust
1371#![feature(trait_alias)]
1372
1373trait Foo = std::fmt::Debug + Send;
1374trait Bar = Foo + Sync;
1375
1376// Use trait alias as bound on type parameter.
1377fn foo<T: Foo>(v: &T) {
1378 println!("{:?}", v);
1379}
1380
1381pub fn main() {
1382 foo(&1);
1383
1384 // Use trait alias for trait objects.
1385 let a: &Bar = &123;
1386 println!("{:?}", a);
1387 let b = Box::new(456) as Box<dyn Foo>;
1388 println!("{:?}", b);
1389}
1390```
1391"##,
1392 },
1393 LintCompletion {
1394 label: "lang_items",
1395 description: r##"# `lang_items`
1396
1397The tracking issue for this feature is: None.
1398
1399------------------------
1400
1401The `rustc` compiler has certain pluggable operations, that is,
1402functionality that isn't hard-coded into the language, but is
1403implemented in libraries, with a special marker to tell the compiler
1404it exists. The marker is the attribute `#[lang = "..."]` and there are
1405various different values of `...`, i.e. various different 'lang
1406items'.
1407
1408For example, `Box` pointers require two lang items, one for allocation
1409and one for deallocation. A freestanding program that uses the `Box`
1410sugar for dynamic allocations via `malloc` and `free`:
1411
1412```rust,ignore (libc-is-finicky)
1413#![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)]
1414#![no_std]
1415use core::intrinsics;
1416use core::panic::PanicInfo;
1417
1418extern crate libc;
1419
1420#[lang = "owned_box"]
1421pub struct Box<T>(*mut T);
1422
1423#[lang = "exchange_malloc"]
1424unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
1425 let p = libc::malloc(size as libc::size_t) as *mut u8;
1426
1427 // Check if `malloc` failed:
1428 if p as usize == 0 {
1429 intrinsics::abort();
1430 }
1431
1432 p
1433}
1434
1435#[lang = "box_free"]
1436unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
1437 libc::free(ptr as *mut libc::c_void)
1438}
1439
1440#[start]
1441fn main(_argc: isize, _argv: *const *const u8) -> isize {
1442 let _x = box 1;
1443
1444 0
1445}
1446
1447#[lang = "eh_personality"] extern fn rust_eh_personality() {}
1448#[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
1449#[no_mangle] pub extern fn rust_eh_register_frames () {}
1450#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
1451```
1452
1453Note the use of `abort`: the `exchange_malloc` lang item is assumed to
1454return a valid pointer, and so needs to do the check internally.
1455
1456Other features provided by lang items include:
1457
1458- overloadable operators via traits: the traits corresponding to the
1459 `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
1460 marked with lang items; those specific four are `eq`, `ord`,
1461 `deref`, and `add` respectively.
1462- stack unwinding and general failure; the `eh_personality`,
1463 `panic` and `panic_bounds_check` lang items.
1464- the traits in `std::marker` used to indicate types of
1465 various kinds; lang items `send`, `sync` and `copy`.
1466- the marker types and variance indicators found in
1467 `std::marker`; lang items `covariant_type`,
1468 `contravariant_lifetime`, etc.
1469
1470Lang items are loaded lazily by the compiler; e.g. if one never uses
1471`Box` then there is no need to define functions for `exchange_malloc`
1472and `box_free`. `rustc` will emit an error when an item is needed
1473but not found in the current crate or any that it depends on.
1474
1475Most lang items are defined by `libcore`, but if you're trying to build
1476an executable without the standard library, you'll run into the need
1477for lang items. The rest of this page focuses on this use-case, even though
1478lang items are a bit broader than that.
1479
1480### Using libc
1481
1482In order to build a `#[no_std]` executable we will need libc as a dependency.
1483We can specify this using our `Cargo.toml` file:
1484
1485```toml
1486[dependencies]
1487libc = { version = "0.2.14", default-features = false }
1488```
1489
1490Note that the default features have been disabled. This is a critical step -
1491**the default features of libc include the standard library and so must be
1492disabled.**
1493
1494### Writing an executable without stdlib
1495
1496Controlling the entry point is possible in two ways: the `#[start]` attribute,
1497or overriding the default shim for the C `main` function with your own.
1498
1499The function marked `#[start]` is passed the command line parameters
1500in the same format as C:
1501
1502```rust,ignore (libc-is-finicky)
1503#![feature(lang_items, core_intrinsics, rustc_private)]
1504#![feature(start)]
1505#![no_std]
1506use core::intrinsics;
1507use core::panic::PanicInfo;
1508
1509// Pull in the system libc library for what crt0.o likely requires.
1510extern crate libc;
1511
1512// Entry point for this program.
1513#[start]
1514fn start(_argc: isize, _argv: *const *const u8) -> isize {
1515 0
1516}
1517
1518// These functions are used by the compiler, but not
1519// for a bare-bones hello world. These are normally
1520// provided by libstd.
1521#[lang = "eh_personality"]
1522#[no_mangle]
1523pub extern fn rust_eh_personality() {
1524}
1525
1526#[lang = "panic_impl"]
1527#[no_mangle]
1528pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
1529 unsafe { intrinsics::abort() }
1530}
1531```
1532
1533To override the compiler-inserted `main` shim, one has to disable it
1534with `#![no_main]` and then create the appropriate symbol with the
1535correct ABI and the correct name, which requires overriding the
1536compiler's name mangling too:
1537
1538```rust,ignore (libc-is-finicky)
1539#![feature(lang_items, core_intrinsics, rustc_private)]
1540#![feature(start)]
1541#![no_std]
1542#![no_main]
1543use core::intrinsics;
1544use core::panic::PanicInfo;
1545
1546// Pull in the system libc library for what crt0.o likely requires.
1547extern crate libc;
1548
1549// Entry point for this program.
1550#[no_mangle] // ensure that this symbol is called `main` in the output
1551pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
1552 0
1553}
1554
1555// These functions are used by the compiler, but not
1556// for a bare-bones hello world. These are normally
1557// provided by libstd.
1558#[lang = "eh_personality"]
1559#[no_mangle]
1560pub extern fn rust_eh_personality() {
1561}
1562
1563#[lang = "panic_impl"]
1564#[no_mangle]
1565pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
1566 unsafe { intrinsics::abort() }
1567}
1568```
1569
1570In many cases, you may need to manually link to the `compiler_builtins` crate
1571when building a `no_std` binary. You may observe this via linker error messages
1572such as "```undefined reference to `__rust_probestack'```".
1573
1574## More about the language items
1575
1576The compiler currently makes a few assumptions about symbols which are
1577available in the executable to call. Normally these functions are provided by
1578the standard library, but without it you must define your own. These symbols
1579are called "language items", and they each have an internal name, and then a
1580signature that an implementation must conform to.
1581
1582The first of these functions, `rust_eh_personality`, is used by the failure
1583mechanisms of the compiler. This is often mapped to GCC's personality function
1584(see the [libstd implementation][unwind] for more information), but crates
1585which do not trigger a panic can be assured that this function is never
1586called. The language item's name is `eh_personality`.
1587
1588[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs
1589
1590The second function, `rust_begin_panic`, is also used by the failure mechanisms of the
1591compiler. When a panic happens, this controls the message that's displayed on
1592the screen. While the language item's name is `panic_impl`, the symbol name is
1593`rust_begin_panic`.
1594
1595Finally, a `eh_catch_typeinfo` static is needed for certain targets which
1596implement Rust panics on top of C++ exceptions.
1597
1598## List of all language items
1599
1600This is a list of all language items in Rust along with where they are located in
1601the source code.
1602
1603- Primitives
1604 - `i8`: `libcore/num/mod.rs`
1605 - `i16`: `libcore/num/mod.rs`
1606 - `i32`: `libcore/num/mod.rs`
1607 - `i64`: `libcore/num/mod.rs`
1608 - `i128`: `libcore/num/mod.rs`
1609 - `isize`: `libcore/num/mod.rs`
1610 - `u8`: `libcore/num/mod.rs`
1611 - `u16`: `libcore/num/mod.rs`
1612 - `u32`: `libcore/num/mod.rs`
1613 - `u64`: `libcore/num/mod.rs`
1614 - `u128`: `libcore/num/mod.rs`
1615 - `usize`: `libcore/num/mod.rs`
1616 - `f32`: `libstd/f32.rs`
1617 - `f64`: `libstd/f64.rs`
1618 - `char`: `libcore/char.rs`
1619 - `slice`: `liballoc/slice.rs`
1620 - `str`: `liballoc/str.rs`
1621 - `const_ptr`: `libcore/ptr.rs`
1622 - `mut_ptr`: `libcore/ptr.rs`
1623 - `unsafe_cell`: `libcore/cell.rs`
1624- Runtime
1625 - `start`: `libstd/rt.rs`
1626 - `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)
1627 - `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)
1628 - `eh_personality`: `libpanic_unwind/seh.rs` (SEH)
1629 - `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)
1630 - `panic`: `libcore/panicking.rs`
1631 - `panic_bounds_check`: `libcore/panicking.rs`
1632 - `panic_impl`: `libcore/panicking.rs`
1633 - `panic_impl`: `libstd/panicking.rs`
1634- Allocations
1635 - `owned_box`: `liballoc/boxed.rs`
1636 - `exchange_malloc`: `liballoc/heap.rs`
1637 - `box_free`: `liballoc/heap.rs`
1638- Operands
1639 - `not`: `libcore/ops/bit.rs`
1640 - `bitand`: `libcore/ops/bit.rs`
1641 - `bitor`: `libcore/ops/bit.rs`
1642 - `bitxor`: `libcore/ops/bit.rs`
1643 - `shl`: `libcore/ops/bit.rs`
1644 - `shr`: `libcore/ops/bit.rs`
1645 - `bitand_assign`: `libcore/ops/bit.rs`
1646 - `bitor_assign`: `libcore/ops/bit.rs`
1647 - `bitxor_assign`: `libcore/ops/bit.rs`
1648 - `shl_assign`: `libcore/ops/bit.rs`
1649 - `shr_assign`: `libcore/ops/bit.rs`
1650 - `deref`: `libcore/ops/deref.rs`
1651 - `deref_mut`: `libcore/ops/deref.rs`
1652 - `index`: `libcore/ops/index.rs`
1653 - `index_mut`: `libcore/ops/index.rs`
1654 - `add`: `libcore/ops/arith.rs`
1655 - `sub`: `libcore/ops/arith.rs`
1656 - `mul`: `libcore/ops/arith.rs`
1657 - `div`: `libcore/ops/arith.rs`
1658 - `rem`: `libcore/ops/arith.rs`
1659 - `neg`: `libcore/ops/arith.rs`
1660 - `add_assign`: `libcore/ops/arith.rs`
1661 - `sub_assign`: `libcore/ops/arith.rs`
1662 - `mul_assign`: `libcore/ops/arith.rs`
1663 - `div_assign`: `libcore/ops/arith.rs`
1664 - `rem_assign`: `libcore/ops/arith.rs`
1665 - `eq`: `libcore/cmp.rs`
1666 - `ord`: `libcore/cmp.rs`
1667- Functions
1668 - `fn`: `libcore/ops/function.rs`
1669 - `fn_mut`: `libcore/ops/function.rs`
1670 - `fn_once`: `libcore/ops/function.rs`
1671 - `generator_state`: `libcore/ops/generator.rs`
1672 - `generator`: `libcore/ops/generator.rs`
1673- Other
1674 - `coerce_unsized`: `libcore/ops/unsize.rs`
1675 - `drop`: `libcore/ops/drop.rs`
1676 - `drop_in_place`: `libcore/ptr.rs`
1677 - `clone`: `libcore/clone.rs`
1678 - `copy`: `libcore/marker.rs`
1679 - `send`: `libcore/marker.rs`
1680 - `sized`: `libcore/marker.rs`
1681 - `unsize`: `libcore/marker.rs`
1682 - `sync`: `libcore/marker.rs`
1683 - `phantom_data`: `libcore/marker.rs`
1684 - `discriminant_kind`: `libcore/marker.rs`
1685 - `freeze`: `libcore/marker.rs`
1686 - `debug_trait`: `libcore/fmt/mod.rs`
1687 - `non_zero`: `libcore/nonzero.rs`
1688 - `arc`: `liballoc/sync.rs`
1689 - `rc`: `liballoc/rc.rs`
1690"##,
1691 },
1692 LintCompletion {
1693 label: "doc_spotlight",
1694 description: r##"# `doc_spotlight`
1695
1696The tracking issue for this feature is: [#45040]
1697
1698The `doc_spotlight` feature allows the use of the `spotlight` parameter to the `#[doc]` attribute,
1699to "spotlight" a specific trait on the return values of functions. Adding a `#[doc(spotlight)]`
1700attribute to a trait definition will make rustdoc print extra information for functions which return
1701a type that implements that trait. For example, this attribute is applied to the `Iterator`,
1702`io::Read`, `io::Write`, and `Future` traits in the standard library.
1703
1704You can do this on your own traits, like this:
1705
1706```
1707#![feature(doc_spotlight)]
1708
1709#[doc(spotlight)]
1710pub trait MyTrait {}
1711
1712pub struct MyStruct;
1713impl MyTrait for MyStruct {}
1714
1715/// The docs for this function will have an extra line about `MyStruct` implementing `MyTrait`,
1716/// without having to write that yourself!
1717pub fn my_fn() -> MyStruct { MyStruct }
1718```
1719
1720This feature was originally implemented in PR [#45039].
1721
1722[#45040]: https://github.com/rust-lang/rust/issues/45040
1723[#45039]: https://github.com/rust-lang/rust/pull/45039
1724"##,
1725 },
1726 LintCompletion {
1727 label: "c_variadic",
1728 description: r##"# `c_variadic`
1729
1730The tracking issue for this feature is: [#44930]
1731
1732[#44930]: https://github.com/rust-lang/rust/issues/44930
1733
1734------------------------
1735
1736The `c_variadic` language feature enables C-variadic functions to be
1737defined in Rust. The may be called both from within Rust and via FFI.
1738
1739## Examples
1740
1741```rust
1742#![feature(c_variadic)]
1743
1744pub unsafe extern "C" fn add(n: usize, mut args: ...) -> usize {
1745 let mut sum = 0;
1746 for _ in 0..n {
1747 sum += args.arg::<usize>();
1748 }
1749 sum
1750}
1751```
1752"##,
1753 },
1754 LintCompletion {
1755 label: "intra_doc_pointers",
1756 description: r##"# `intra-doc-pointers`
1757
1758The tracking issue for this feature is: [#80896]
1759
1760[#80896]: https://github.com/rust-lang/rust/issues/80896
1761
1762------------------------
1763
1764Rustdoc does not currently allow disambiguating between `*const` and `*mut`, and
1765raw pointers in intra-doc links are unstable until it does.
1766
1767```rust
1768#![feature(intra_doc_pointers)]
1769//! [pointer::add]
1770```
1771"##,
1772 },
1773 LintCompletion {
1774 label: "box_syntax",
1775 description: r##"# `box_syntax`
1776
1777The tracking issue for this feature is: [#49733]
1778
1779[#49733]: https://github.com/rust-lang/rust/issues/49733
1780
1781See also [`box_patterns`](box-patterns.md)
1782
1783------------------------
1784
1785Currently the only stable way to create a `Box` is via the `Box::new` method.
1786Also it is not possible in stable Rust to destructure a `Box` in a match
1787pattern. The unstable `box` keyword can be used to create a `Box`. An example
1788usage would be:
1789
1790```rust
1791#![feature(box_syntax)]
1792
1793fn main() {
1794 let b = box 5;
1795}
1796```
1797"##,
1798 },
1799 LintCompletion {
1800 label: "unsized_locals",
1801 description: r##"# `unsized_locals`
1802
1803The tracking issue for this feature is: [#48055]
1804
1805[#48055]: https://github.com/rust-lang/rust/issues/48055
1806
1807------------------------
1808
1809This implements [RFC1909]. When turned on, you can have unsized arguments and locals:
1810
1811[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md
1812
1813```rust
1814#![allow(incomplete_features)]
1815#![feature(unsized_locals, unsized_fn_params)]
1816
1817use std::any::Any;
1818
1819fn main() {
1820 let x: Box<dyn Any> = Box::new(42);
1821 let x: dyn Any = *x;
1822 // ^ unsized local variable
1823 // ^^ unsized temporary
1824 foo(x);
1825}
1826
1827fn foo(_: dyn Any) {}
1828// ^^^^^^ unsized argument
1829```
1830
1831The RFC still forbids the following unsized expressions:
1832
1833```rust,compile_fail
1834#![feature(unsized_locals)]
1835
1836use std::any::Any;
1837
1838struct MyStruct<T: ?Sized> {
1839 content: T,
1840}
1841
1842struct MyTupleStruct<T: ?Sized>(T);
1843
1844fn answer() -> Box<dyn Any> {
1845 Box::new(42)
1846}
1847
1848fn main() {
1849 // You CANNOT have unsized statics.
1850 static X: dyn Any = *answer(); // ERROR
1851 const Y: dyn Any = *answer(); // ERROR
1852
1853 // You CANNOT have struct initialized unsized.
1854 MyStruct { content: *answer() }; // ERROR
1855 MyTupleStruct(*answer()); // ERROR
1856 (42, *answer()); // ERROR
1857
1858 // You CANNOT have unsized return types.
1859 fn my_function() -> dyn Any { *answer() } // ERROR
1860
1861 // You CAN have unsized local variables...
1862 let mut x: dyn Any = *answer(); // OK
1863 // ...but you CANNOT reassign to them.
1864 x = *answer(); // ERROR
1865
1866 // You CANNOT even initialize them separately.
1867 let y: dyn Any; // OK
1868 y = *answer(); // ERROR
1869
1870 // Not mentioned in the RFC, but by-move captured variables are also Sized.
1871 let x: dyn Any = *answer();
1872 (move || { // ERROR
1873 let y = x;
1874 })();
1875
1876 // You CAN create a closure with unsized arguments,
1877 // but you CANNOT call it.
1878 // This is an implementation detail and may be changed in the future.
1879 let f = |x: dyn Any| {};
1880 f(*answer()); // ERROR
1881}
1882```
1883
1884## By-value trait objects
1885
1886With this feature, you can have by-value `self` arguments without `Self: Sized` bounds.
1887
1888```rust
1889#![feature(unsized_fn_params)]
1890
1891trait Foo {
1892 fn foo(self) {}
1893}
1894
1895impl<T: ?Sized> Foo for T {}
1896
1897fn main() {
1898 let slice: Box<[i32]> = Box::new([1, 2, 3]);
1899 <[i32] as Foo>::foo(*slice);
1900}
1901```
1902
1903And `Foo` will also be object-safe.
1904
1905```rust
1906#![feature(unsized_fn_params)]
1907
1908trait Foo {
1909 fn foo(self) {}
1910}
1911
1912impl<T: ?Sized> Foo for T {}
1913
1914fn main () {
1915 let slice: Box<dyn Foo> = Box::new([1, 2, 3]);
1916 // doesn't compile yet
1917 <dyn Foo as Foo>::foo(*slice);
1918}
1919```
1920
1921One of the objectives of this feature is to allow `Box<dyn FnOnce>`.
1922
1923## Variable length arrays
1924
1925The 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]`.
1926
1927```rust,ignore (not-yet-implemented)
1928#![feature(unsized_locals)]
1929
1930fn mergesort<T: Ord>(a: &mut [T]) {
1931 let mut tmp = [T; dyn a.len()];
1932 // ...
1933}
1934
1935fn main() {
1936 let mut a = [3, 1, 5, 6];
1937 mergesort(&mut a);
1938 assert_eq!(a, [1, 3, 5, 6]);
1939}
1940```
1941
1942VLAs 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]`.
1943
1944## Advisory on stack usage
1945
1946It's advised not to casually use the `#![feature(unsized_locals)]` feature. Typical use-cases are:
1947
1948- When you need a by-value trait objects.
1949- When you really need a fast allocation of small temporary arrays.
1950
1951Another 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
1952
1953```rust
1954#![feature(unsized_locals)]
1955
1956fn main() {
1957 let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);
1958 let _x = {{{{{{{{{{*x}}}}}}}}}};
1959}
1960```
1961
1962and the code
1963
1964```rust
1965#![feature(unsized_locals)]
1966
1967fn main() {
1968 for _ in 0..10 {
1969 let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);
1970 let _x = *x;
1971 }
1972}
1973```
1974
1975will unnecessarily extend the stack frame.
1976"##,
1977 },
1978 LintCompletion {
1979 label: "arbitrary_enum_discriminant",
1980 description: r##"# `arbitrary_enum_discriminant`
1981
1982The tracking issue for this feature is: [#60553]
1983
1984[#60553]: https://github.com/rust-lang/rust/issues/60553
1985
1986------------------------
1987
1988The `arbitrary_enum_discriminant` feature permits tuple-like and
1989struct-like enum variants with `#[repr(<int-type>)]` to have explicit discriminants.
1990
1991## Examples
1992
1993```rust
1994#![feature(arbitrary_enum_discriminant)]
1995
1996#[allow(dead_code)]
1997#[repr(u8)]
1998enum Enum {
1999 Unit = 3,
2000 Tuple(u16) = 2,
2001 Struct {
2002 a: u8,
2003 b: u16,
2004 } = 1,
2005}
2006
2007impl Enum {
2008 fn tag(&self) -> u8 {
2009 unsafe { *(self as *const Self as *const u8) }
2010 }
2011}
2012
2013assert_eq!(3, Enum::Unit.tag());
2014assert_eq!(2, Enum::Tuple(5).tag());
2015assert_eq!(1, Enum::Struct{a: 7, b: 11}.tag());
2016```
2017"##,
2018 },
2019 LintCompletion {
2020 label: "unboxed_closures",
2021 description: r##"# `unboxed_closures`
2022
2023The tracking issue for this feature is [#29625]
2024
2025See Also: [`fn_traits`](../library-features/fn-traits.md)
2026
2027[#29625]: https://github.com/rust-lang/rust/issues/29625
2028
2029----
2030
2031The `unboxed_closures` feature allows you to write functions using the `"rust-call"` ABI,
2032required for implementing the [`Fn*`] family of traits. `"rust-call"` functions must have
2033exactly one (non self) argument, a tuple representing the argument list.
2034
2035[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html
2036
2037```rust
2038#![feature(unboxed_closures)]
2039
2040extern "rust-call" fn add_args(args: (u32, u32)) -> u32 {
2041 args.0 + args.1
2042}
2043
2044fn main() {}
2045```
2046"##,
2047 },
2048 LintCompletion {
2049 label: "custom_test_frameworks",
2050 description: r##"# `custom_test_frameworks`
2051
2052The tracking issue for this feature is: [#50297]
2053
2054[#50297]: https://github.com/rust-lang/rust/issues/50297
2055
2056------------------------
2057
2058The `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`.
2059Any function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`)
2060and be passed to the test runner determined by the `#![test_runner]` crate attribute.
2061
2062```rust
2063#![feature(custom_test_frameworks)]
2064#![test_runner(my_runner)]
2065
2066fn my_runner(tests: &[&i32]) {
2067 for t in tests {
2068 if **t == 0 {
2069 println!("PASSED");
2070 } else {
2071 println!("FAILED");
2072 }
2073 }
2074}
2075
2076#[test_case]
2077const WILL_PASS: i32 = 0;
2078
2079#[test_case]
2080const WILL_FAIL: i32 = 4;
2081```
2082"##,
2083 },
2084 LintCompletion {
2085 label: "abi_msp430_interrupt", 577 label: "abi_msp430_interrupt",
2086 description: r##"# `abi_msp430_interrupt` 578 description: r##"# `abi_msp430_interrupt`
2087 579
@@ -2127,201 +619,7 @@ Disassembly of section .text:
2127``` 619```
2128"##, 620"##,
2129 }, 621 },
2130 LintCompletion { 622 Lint {
2131 label: "impl_trait_in_bindings",
2132 description: r##"# `impl_trait_in_bindings`
2133
2134The tracking issue for this feature is: [#63065]
2135
2136[#63065]: https://github.com/rust-lang/rust/issues/63065
2137
2138------------------------
2139
2140The `impl_trait_in_bindings` feature gate lets you use `impl Trait` syntax in
2141`let`, `static`, and `const` bindings.
2142
2143A simple example is:
2144
2145```rust
2146#![feature(impl_trait_in_bindings)]
2147
2148use std::fmt::Debug;
2149
2150fn main() {
2151 let a: impl Debug + Clone = 42;
2152 let b = a.clone();
2153 println!("{:?}", b); // prints `42`
2154}
2155```
2156
2157Note however that because the types of `a` and `b` are opaque in the above
2158example, calling inherent methods or methods outside of the specified traits
2159(e.g., `a.abs()` or `b.abs()`) is not allowed, and yields an error.
2160"##,
2161 },
2162 LintCompletion {
2163 label: "cfg_version",
2164 description: r##"# `cfg_version`
2165
2166The tracking issue for this feature is: [#64796]
2167
2168[#64796]: https://github.com/rust-lang/rust/issues/64796
2169
2170------------------------
2171
2172The `cfg_version` feature makes it possible to execute different code
2173depending on the compiler version.
2174
2175## Examples
2176
2177```rust
2178#![feature(cfg_version)]
2179
2180#[cfg(version("1.42"))]
2181fn a() {
2182 // ...
2183}
2184
2185#[cfg(not(version("1.42")))]
2186fn a() {
2187 // ...
2188}
2189
2190fn b() {
2191 if cfg!(version("1.42")) {
2192 // ...
2193 } else {
2194 // ...
2195 }
2196}
2197```
2198"##,
2199 },
2200 LintCompletion {
2201 label: "link_cfg",
2202 description: r##"# `link_cfg`
2203
2204This feature is internal to the Rust compiler and is not intended for general use.
2205
2206------------------------
2207"##,
2208 },
2209 LintCompletion {
2210 label: "infer_static_outlives_requirements",
2211 description: r##"# `infer_static_outlives_requirements`
2212
2213The tracking issue for this feature is: [#54185]
2214
2215[#54185]: https://github.com/rust-lang/rust/issues/54185
2216
2217------------------------
2218The `infer_static_outlives_requirements` feature indicates that certain
2219`'static` outlives requirements can be inferred by the compiler rather than
2220stating them explicitly.
2221
2222Note: It is an accompanying feature to `infer_outlives_requirements`,
2223which must be enabled to infer outlives requirements.
2224
2225For example, currently generic struct definitions that contain
2226references, require where-clauses of the form T: 'static. By using
2227this feature the outlives predicates will be inferred, although
2228they may still be written explicitly.
2229
2230```rust,ignore (pseudo-Rust)
2231struct Foo<U> where U: 'static { // <-- currently required
2232 bar: Bar<U>
2233}
2234struct Bar<T: 'static> {
2235 x: T,
2236}
2237```
2238
2239
2240## Examples:
2241
2242```rust,ignore (pseudo-Rust)
2243#![feature(infer_outlives_requirements)]
2244#![feature(infer_static_outlives_requirements)]
2245
2246#[rustc_outlives]
2247// Implicitly infer U: 'static
2248struct Foo<U> {
2249 bar: Bar<U>
2250}
2251struct Bar<T: 'static> {
2252 x: T,
2253}
2254```
2255"##,
2256 },
2257 LintCompletion {
2258 label: "marker_trait_attr",
2259 description: r##"# `marker_trait_attr`
2260
2261The tracking issue for this feature is: [#29864]
2262
2263[#29864]: https://github.com/rust-lang/rust/issues/29864
2264
2265------------------------
2266
2267Normally, Rust keeps you from adding trait implementations that could
2268overlap with each other, as it would be ambiguous which to use. This
2269feature, however, carves out an exception to that rule: a trait can
2270opt-in to having overlapping implementations, at the cost that those
2271implementations are not allowed to override anything (and thus the
2272trait itself cannot have any associated items, as they're pointless
2273when they'd need to do the same thing for every type anyway).
2274
2275```rust
2276#![feature(marker_trait_attr)]
2277
2278#[marker] trait CheapToClone: Clone {}
2279
2280impl<T: Copy> CheapToClone for T {}
2281
2282// These could potentially overlap with the blanket implementation above,
2283// so are only allowed because CheapToClone is a marker trait.
2284impl<T: CheapToClone, U: CheapToClone> CheapToClone for (T, U) {}
2285impl<T: CheapToClone> CheapToClone for std::ops::Range<T> {}
2286
2287fn cheap_clone<T: CheapToClone>(t: T) -> T {
2288 t.clone()
2289}
2290```
2291
2292This is expected to replace the unstable `overlapping_marker_traits`
2293feature, which applied to all empty traits (without needing an opt-in).
2294"##,
2295 },
2296 LintCompletion {
2297 label: "doc_masked",
2298 description: r##"# `doc_masked`
2299
2300The tracking issue for this feature is: [#44027]
2301
2302-----
2303
2304The `doc_masked` feature allows a crate to exclude types from a given crate from appearing in lists
2305of trait implementations. The specifics of the feature are as follows:
2306
23071. When rustdoc encounters an `extern crate` statement annotated with a `#[doc(masked)]` attribute,
2308 it marks the crate as being masked.
2309
23102. When listing traits a given type implements, rustdoc ensures that traits from masked crates are
2311 not emitted into the documentation.
2312
23133. When listing types that implement a given trait, rustdoc ensures that types from masked crates
2314 are not emitted into the documentation.
2315
2316This feature was introduced in PR [#44026] to ensure that compiler-internal and
2317implementation-specific types and traits were not included in the standard library's documentation.
2318Such types would introduce broken links into the documentation.
2319
2320[#44026]: https://github.com/rust-lang/rust/pull/44026
2321[#44027]: https://github.com/rust-lang/rust/pull/44027
2322"##,
2323 },
2324 LintCompletion {
2325 label: "abi_ptx", 623 label: "abi_ptx",
2326 description: r##"# `abi_ptx` 624 description: r##"# `abi_ptx`
2327 625
@@ -2385,340 +683,94 @@ $ cat $(find -name '*.s')
2385``` 683```
2386"##, 684"##,
2387 }, 685 },
2388 LintCompletion { 686 Lint {
2389 label: "profiler_runtime", 687 label: "abi_thiscall",
2390 description: r##"# `profiler_runtime` 688 description: r##"# `abi_thiscall`
2391
2392The tracking issue for this feature is: [#42524](https://github.com/rust-lang/rust/issues/42524).
2393
2394------------------------
2395"##,
2396 },
2397 LintCompletion {
2398 label: "crate_visibility_modifier",
2399 description: r##"# `crate_visibility_modifier`
2400
2401The tracking issue for this feature is: [#53120]
2402
2403[#53120]: https://github.com/rust-lang/rust/issues/53120
2404
2405-----
2406
2407The `crate_visibility_modifier` feature allows the `crate` keyword to be used
2408as a visibility modifier synonymous to `pub(crate)`, indicating that a type
2409(function, _&c._) is to be visible to the entire enclosing crate, but not to
2410other crates.
2411
2412```rust
2413#![feature(crate_visibility_modifier)]
2414
2415crate struct Foo {
2416 bar: usize,
2417}
2418```
2419"##,
2420 },
2421 LintCompletion {
2422 label: "doc_cfg",
2423 description: r##"# `doc_cfg`
2424
2425The tracking issue for this feature is: [#43781]
2426
2427------
2428
2429The `doc_cfg` feature allows an API be documented as only available in some specific platforms.
2430This attribute has two effects:
2431
24321. In the annotated item's documentation, there will be a message saying "This is supported on
2433 (platform) only".
2434
24352. The item's doc-tests will only run on the specific platform.
2436
2437In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a
2438special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your
2439crate.
2440
2441This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
2442standard library be documented.
2443
2444```rust
2445#![feature(doc_cfg)]
2446
2447#[cfg(any(windows, doc))]
2448#[doc(cfg(windows))]
2449/// The application's icon in the notification area (a.k.a. system tray).
2450///
2451/// # Examples
2452///
2453/// ```no_run
2454/// extern crate my_awesome_ui_library;
2455/// use my_awesome_ui_library::current_app;
2456/// use my_awesome_ui_library::windows::notification;
2457///
2458/// let icon = current_app().get::<notification::Icon>();
2459/// icon.show();
2460/// icon.show_message("Hello");
2461/// ```
2462pub struct Icon {
2463 // ...
2464}
2465```
2466
2467[#43781]: https://github.com/rust-lang/rust/issues/43781
2468[#43348]: https://github.com/rust-lang/rust/issues/43348
2469"##,
2470 },
2471 LintCompletion {
2472 label: "unsized_tuple_coercion",
2473 description: r##"# `unsized_tuple_coercion`
2474 689
2475The tracking issue for this feature is: [#42877] 690The tracking issue for this feature is: [#42202]
2476 691
2477[#42877]: https://github.com/rust-lang/rust/issues/42877 692[#42202]: https://github.com/rust-lang/rust/issues/42202
2478 693
2479------------------------ 694------------------------
2480 695
2481This is a part of [RFC0401]. According to the RFC, there should be an implementation like this: 696The MSVC ABI on x86 Windows uses the `thiscall` calling convention for C++
2482 697instance methods by default; it is identical to the usual (C) calling
2483```rust,ignore (partial-example) 698convention on x86 Windows except that the first parameter of the method,
2484impl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized<U> {} 699the `this` pointer, is passed in the ECX register.
2485```
2486
2487This implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this:
2488
2489```rust
2490#![feature(unsized_tuple_coercion)]
2491
2492fn main() {
2493 let x : ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]);
2494 let y : &([i32; 3], [i32]) = &x;
2495 assert_eq!(y.1[0], 4);
2496}
2497```
2498
2499[RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
2500"##, 700"##,
2501 }, 701 },
2502 LintCompletion { 702 Lint {
2503 label: "no_sanitize", 703 label: "allocator_api",
2504 description: r##"# `no_sanitize` 704 description: r##"# `allocator_api`
2505 705
2506The tracking issue for this feature is: [#39699] 706The tracking issue for this feature is [#32838]
2507 707
2508[#39699]: https://github.com/rust-lang/rust/issues/39699 708[#32838]: https://github.com/rust-lang/rust/issues/32838
2509 709
2510------------------------ 710------------------------
2511 711
2512The `no_sanitize` attribute can be used to selectively disable sanitizer 712Sometimes you want the memory for one collection to use a different
2513instrumentation in an annotated function. This might be useful to: avoid 713allocator than the memory for another collection. In this case,
2514instrumentation overhead in a performance critical function, or avoid 714replacing the global allocator is not a workable option. Instead,
2515instrumenting code that contains constructs unsupported by given sanitizer. 715you need to pass in an instance of an `AllocRef` to each collection
2516 716for which you want a custom allocator.
2517The precise effect of this annotation depends on particular sanitizer in use.
2518For example, with `no_sanitize(thread)`, the thread sanitizer will no longer
2519instrument non-atomic store / load operations, but it will instrument atomic
2520operations to avoid reporting false positives and provide meaning full stack
2521traces.
2522
2523## Examples
2524
2525``` rust
2526#![feature(no_sanitize)]
2527 717
2528#[no_sanitize(address)] 718TBD
2529fn foo() {
2530 // ...
2531}
2532```
2533"##, 719"##,
2534 }, 720 },
2535 LintCompletion { 721 Lint {
2536 label: "try_blocks", 722 label: "allocator_internals",
2537 description: r##"# `try_blocks` 723 description: r##"# `allocator_internals`
2538
2539The tracking issue for this feature is: [#31436]
2540 724
2541[#31436]: https://github.com/rust-lang/rust/issues/31436 725This feature does not have a tracking issue, it is an unstable implementation
726detail of the `global_allocator` feature not intended for use outside the
727compiler.
2542 728
2543------------------------ 729------------------------
2544
2545The `try_blocks` feature adds support for `try` blocks. A `try`
2546block creates a new scope one can use the `?` operator in.
2547
2548```rust,edition2018
2549#![feature(try_blocks)]
2550
2551use std::num::ParseIntError;
2552
2553let result: Result<i32, ParseIntError> = try {
2554 "1".parse::<i32>()?
2555 + "2".parse::<i32>()?
2556 + "3".parse::<i32>()?
2557};
2558assert_eq!(result, Ok(6));
2559
2560let result: Result<i32, ParseIntError> = try {
2561 "1".parse::<i32>()?
2562 + "foo".parse::<i32>()?
2563 + "3".parse::<i32>()?
2564};
2565assert!(result.is_err());
2566```
2567"##, 730"##,
2568 }, 731 },
2569 LintCompletion { 732 Lint {
2570 label: "transparent_unions", 733 label: "arbitrary_enum_discriminant",
2571 description: r##"# `transparent_unions` 734 description: r##"# `arbitrary_enum_discriminant`
2572
2573The tracking issue for this feature is [#60405]
2574
2575[#60405]: https://github.com/rust-lang/rust/issues/60405
2576
2577----
2578 735
2579The `transparent_unions` feature allows you mark `union`s as 736The tracking issue for this feature is: [#60553]
2580`#[repr(transparent)]`. A `union` may be `#[repr(transparent)]` in exactly the
2581same conditions in which a `struct` may be `#[repr(transparent)]` (generally,
2582this means the `union` must have exactly one non-zero-sized field). Some
2583concrete illustrations follow.
2584 737
2585```rust 738[#60553]: https://github.com/rust-lang/rust/issues/60553
2586#![feature(transparent_unions)]
2587 739
2588// This union has the same representation as `f32`. 740------------------------
2589#[repr(transparent)]
2590union SingleFieldUnion {
2591 field: f32,
2592}
2593 741
2594// This union has the same representation as `usize`. 742The `arbitrary_enum_discriminant` feature permits tuple-like and
2595#[repr(transparent)] 743struct-like enum variants with `#[repr(<int-type>)]` to have explicit discriminants.
2596union MultiFieldUnion {
2597 field: usize,
2598 nothing: (),
2599}
2600```
2601 744
2602For consistency with transparent `struct`s, `union`s must have exactly one 745## Examples
2603non-zero-sized field. If all fields are zero-sized, the `union` must not be
2604`#[repr(transparent)]`:
2605 746
2606```rust 747```rust
2607#![feature(transparent_unions)] 748#![feature(arbitrary_enum_discriminant)]
2608 749
2609// This (non-transparent) union is already valid in stable Rust: 750#[allow(dead_code)]
2610pub union GoodUnion { 751#[repr(u8)]
2611 pub nothing: (), 752enum Enum {
753 Unit = 3,
754 Tuple(u16) = 2,
755 Struct {
756 a: u8,
757 b: u16,
758 } = 1,
2612} 759}
2613 760
2614// Error: transparent union needs exactly one non-zero-sized field, but has 0 761impl Enum {
2615// #[repr(transparent)] 762 fn tag(&self) -> u8 {
2616// pub union BadUnion { 763 unsafe { *(self as *const Self as *const u8) }
2617// pub nothing: (), 764 }
2618// }
2619```
2620
2621The one exception is if the `union` is generic over `T` and has a field of type
2622`T`, it may be `#[repr(transparent)]` even if `T` is a zero-sized type:
2623
2624```rust
2625#![feature(transparent_unions)]
2626
2627// This union has the same representation as `T`.
2628#[repr(transparent)]
2629pub union GenericUnion<T: Copy> { // Unions with non-`Copy` fields are unstable.
2630 pub field: T,
2631 pub nothing: (),
2632} 765}
2633 766
2634// This is okay even though `()` is a zero-sized type. 767assert_eq!(3, Enum::Unit.tag());
2635pub const THIS_IS_OKAY: GenericUnion<()> = GenericUnion { field: () }; 768assert_eq!(2, Enum::Tuple(5).tag());
2636``` 769assert_eq!(1, Enum::Struct{a: 7, b: 11}.tag());
2637
2638Like transarent `struct`s, a transparent `union` of type `U` has the same
2639layout, size, and ABI as its single non-ZST field. If it is generic over a type
2640`T`, and all its fields are ZSTs except for exactly one field of type `T`, then
2641it has the same layout and ABI as `T` (even if `T` is a ZST when monomorphized).
2642
2643Like transparent `struct`s, transparent `union`s are FFI-safe if and only if
2644their underlying representation type is also FFI-safe.
2645
2646A `union` may not be eligible for the same nonnull-style optimizations that a
2647`struct` or `enum` (with the same fields) are eligible for. Adding
2648`#[repr(transparent)]` to `union` does not change this. To give a more concrete
2649example, it is unspecified whether `size_of::<T>()` is equal to
2650`size_of::<Option<T>>()`, where `T` is a `union` (regardless of whether or not
2651it is transparent). The Rust compiler is free to perform this optimization if
2652possible, but is not required to, and different compiler versions may differ in
2653their application of these optimizations.
2654"##,
2655 },
2656 LintCompletion {
2657 label: "const_eval_limit",
2658 description: r##"# `const_eval_limit`
2659
2660The tracking issue for this feature is: [#67217]
2661
2662[#67217]: https://github.com/rust-lang/rust/issues/67217
2663
2664The `const_eval_limit` allows someone to limit the evaluation steps the CTFE undertakes to evaluate a `const fn`.
2665"##,
2666 },
2667 LintCompletion {
2668 label: "link_args",
2669 description: r##"# `link_args`
2670
2671The tracking issue for this feature is: [#29596]
2672
2673[#29596]: https://github.com/rust-lang/rust/issues/29596
2674
2675------------------------
2676
2677You can tell `rustc` how to customize linking, and that is via the `link_args`
2678attribute. This attribute is applied to `extern` blocks and specifies raw flags
2679which need to get passed to the linker when producing an artifact. An example
2680usage would be:
2681
2682```rust,no_run
2683#![feature(link_args)]
2684
2685#[link_args = "-foo -bar -baz"]
2686extern "C" {}
2687# fn main() {}
2688``` 770```
2689
2690Note that this feature is currently hidden behind the `feature(link_args)` gate
2691because this is not a sanctioned way of performing linking. Right now `rustc`
2692shells out to the system linker (`gcc` on most systems, `link.exe` on MSVC), so
2693it makes sense to provide extra command line arguments, but this will not
2694always be the case. In the future `rustc` may use LLVM directly to link native
2695libraries, in which case `link_args` will have no meaning. You can achieve the
2696same effect as the `link_args` attribute with the `-C link-args` argument to
2697`rustc`.
2698
2699It is highly recommended to *not* use this attribute, and rather use the more
2700formal `#[link(...)]` attribute on `extern` blocks instead.
2701"##,
2702 },
2703 LintCompletion {
2704 label: "internal_output_capture",
2705 description: r##"# `internal_output_capture`
2706
2707This feature is internal to the Rust compiler and is not intended for general use.
2708
2709------------------------
2710"##,
2711 },
2712 LintCompletion {
2713 label: "windows_handle",
2714 description: r##"# `windows_handle`
2715
2716This feature is internal to the Rust compiler and is not intended for general use.
2717
2718------------------------
2719"##, 771"##,
2720 }, 772 },
2721 LintCompletion { 773 Lint {
2722 label: "asm", 774 label: "asm",
2723 description: r##"# `asm` 775 description: r##"# `asm`
2724 776
@@ -2748,6 +800,7 @@ Inline assembly is currently supported on the following architectures:
2748- AArch64 800- AArch64
2749- RISC-V 801- RISC-V
2750- NVPTX 802- NVPTX
803- PowerPC
2751- Hexagon 804- Hexagon
2752- MIPS32r2 and MIPS64r2 805- MIPS32r2 and MIPS64r2
2753- wasm32 806- wasm32
@@ -2757,7 +810,7 @@ Inline assembly is currently supported on the following architectures:
2757Let us start with the simplest possible example: 810Let us start with the simplest possible example:
2758 811
2759```rust,allow_fail 812```rust,allow_fail
2760# #![feature(asm)] 813#![feature(asm)]
2761unsafe { 814unsafe {
2762 asm!("nop"); 815 asm!("nop");
2763} 816}
@@ -2774,7 +827,7 @@ Now inserting an instruction that does nothing is rather boring. Let us do somet
2774actually acts on data: 827actually acts on data:
2775 828
2776```rust,allow_fail 829```rust,allow_fail
2777# #![feature(asm)] 830#![feature(asm)]
2778let x: u64; 831let x: u64;
2779unsafe { 832unsafe {
2780 asm!("mov {}, 5", out(reg) x); 833 asm!("mov {}, 5", out(reg) x);
@@ -2796,7 +849,7 @@ the template and will read the variable from there after the inline assembly fin
2796Let us see another example that also uses an input: 849Let us see another example that also uses an input:
2797 850
2798```rust,allow_fail 851```rust,allow_fail
2799# #![feature(asm)] 852#![feature(asm)]
2800let i: u64 = 3; 853let i: u64 = 3;
2801let o: u64; 854let o: u64;
2802unsafe { 855unsafe {
@@ -2836,7 +889,7 @@ readability, and allows reordering instructions without changing the argument or
2836We can further refine the above example to avoid the `mov` instruction: 889We can further refine the above example to avoid the `mov` instruction:
2837 890
2838```rust,allow_fail 891```rust,allow_fail
2839# #![feature(asm)] 892#![feature(asm)]
2840let mut x: u64 = 3; 893let mut x: u64 = 3;
2841unsafe { 894unsafe {
2842 asm!("add {0}, {number}", inout(reg) x, number = const 5); 895 asm!("add {0}, {number}", inout(reg) x, number = const 5);
@@ -2850,7 +903,7 @@ This is different from specifying an input and output separately in that it is g
2850It is also possible to specify different variables for the input and output parts of an `inout` operand: 903It is also possible to specify different variables for the input and output parts of an `inout` operand:
2851 904
2852```rust,allow_fail 905```rust,allow_fail
2853# #![feature(asm)] 906#![feature(asm)]
2854let x: u64 = 3; 907let x: u64 = 3;
2855let y: u64; 908let y: u64;
2856unsafe { 909unsafe {
@@ -2872,7 +925,7 @@ There is also a `inlateout` variant of this specifier.
2872Here is an example where `inlateout` *cannot* be used: 925Here is an example where `inlateout` *cannot* be used:
2873 926
2874```rust,allow_fail 927```rust,allow_fail
2875# #![feature(asm)] 928#![feature(asm)]
2876let mut a: u64 = 4; 929let mut a: u64 = 4;
2877let b: u64 = 4; 930let b: u64 = 4;
2878let c: u64 = 4; 931let c: u64 = 4;
@@ -2893,7 +946,7 @@ Here the compiler is free to allocate the same register for inputs `b` and `c` s
2893However the following example can use `inlateout` since the output is only modified after all input registers have been read: 946However the following example can use `inlateout` since the output is only modified after all input registers have been read:
2894 947
2895```rust,allow_fail 948```rust,allow_fail
2896# #![feature(asm)] 949#![feature(asm)]
2897let mut a: u64 = 4; 950let mut a: u64 = 4;
2898let b: u64 = 4; 951let b: u64 = 4;
2899unsafe { 952unsafe {
@@ -2912,7 +965,7 @@ While `reg` is generally available on any architecture, these are highly archite
2912among others can be addressed by their name. 965among others can be addressed by their name.
2913 966
2914```rust,allow_fail,no_run 967```rust,allow_fail,no_run
2915# #![feature(asm)] 968#![feature(asm)]
2916let cmd = 0xd1; 969let cmd = 0xd1;
2917unsafe { 970unsafe {
2918 asm!("out 0x64, eax", in("eax") cmd); 971 asm!("out 0x64, eax", in("eax") cmd);
@@ -2928,7 +981,7 @@ Note that unlike other operand types, explicit register operands cannot be used
2928Consider this example which uses the x86 `mul` instruction: 981Consider this example which uses the x86 `mul` instruction:
2929 982
2930```rust,allow_fail 983```rust,allow_fail
2931# #![feature(asm)] 984#![feature(asm)]
2932fn mul(a: u64, b: u64) -> u128 { 985fn mul(a: u64, b: u64) -> u128 {
2933 let lo: u64; 986 let lo: u64;
2934 let hi: u64; 987 let hi: u64;
@@ -2964,7 +1017,7 @@ We need to tell the compiler about this since it may need to save and restore th
2964around the inline assembly block. 1017around the inline assembly block.
2965 1018
2966```rust,allow_fail 1019```rust,allow_fail
2967# #![feature(asm)] 1020#![feature(asm)]
2968let ebx: u32; 1021let ebx: u32;
2969let ecx: u32; 1022let ecx: u32;
2970 1023
@@ -2994,7 +1047,7 @@ However we still need to tell the compiler that `eax` and `edx` have been modifi
2994This can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code: 1047This can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:
2995 1048
2996```rust,allow_fail 1049```rust,allow_fail
2997# #![feature(asm)] 1050#![feature(asm)]
2998// Multiply x by 6 using shifts and adds 1051// Multiply x by 6 using shifts and adds
2999let mut x: u64 = 4; 1052let mut x: u64 = 4;
3000unsafe { 1053unsafe {
@@ -3016,7 +1069,7 @@ A special operand type, `sym`, allows you to use the symbol name of a `fn` or `s
3016This allows you to call a function or access a global variable without needing to keep its address in a register. 1069This allows you to call a function or access a global variable without needing to keep its address in a register.
3017 1070
3018```rust,allow_fail 1071```rust,allow_fail
3019# #![feature(asm)] 1072#![feature(asm)]
3020extern "C" fn foo(arg: i32) { 1073extern "C" fn foo(arg: i32) {
3021 println!("arg = {}", arg); 1074 println!("arg = {}", arg);
3022} 1075}
@@ -3028,13 +1081,19 @@ fn call_foo(arg: i32) {
3028 sym foo, 1081 sym foo,
3029 // 1st argument in rdi, which is caller-saved 1082 // 1st argument in rdi, which is caller-saved
3030 inout("rdi") arg => _, 1083 inout("rdi") arg => _,
3031 // All caller-saved registers must be marked as clobberred 1084 // All caller-saved registers must be marked as clobbered
3032 out("rax") _, out("rcx") _, out("rdx") _, out("rsi") _, 1085 out("rax") _, out("rcx") _, out("rdx") _, out("rsi") _,
3033 out("r8") _, out("r9") _, out("r10") _, out("r11") _, 1086 out("r8") _, out("r9") _, out("r10") _, out("r11") _,
3034 out("xmm0") _, out("xmm1") _, out("xmm2") _, out("xmm3") _, 1087 out("xmm0") _, out("xmm1") _, out("xmm2") _, out("xmm3") _,
3035 out("xmm4") _, out("xmm5") _, out("xmm6") _, out("xmm7") _, 1088 out("xmm4") _, out("xmm5") _, out("xmm6") _, out("xmm7") _,
3036 out("xmm8") _, out("xmm9") _, out("xmm10") _, out("xmm11") _, 1089 out("xmm8") _, out("xmm9") _, out("xmm10") _, out("xmm11") _,
3037 out("xmm12") _, out("xmm13") _, out("xmm14") _, out("xmm15") _, 1090 out("xmm12") _, out("xmm13") _, out("xmm14") _, out("xmm15") _,
1091 // Also mark AVX-512 registers as clobbered. This is accepted by the
1092 // compiler even if AVX-512 is not enabled on the current target.
1093 out("xmm16") _, out("xmm17") _, out("xmm18") _, out("xmm19") _,
1094 out("xmm20") _, out("xmm21") _, out("xmm22") _, out("xmm23") _,
1095 out("xmm24") _, out("xmm25") _, out("xmm26") _, out("xmm27") _,
1096 out("xmm28") _, out("xmm29") _, out("xmm30") _, out("xmm31") _,
3038 ) 1097 )
3039 } 1098 }
3040} 1099}
@@ -3052,7 +1111,7 @@ By default the compiler will always choose the name that refers to the full regi
3052This default can be overriden by using modifiers on the template string operands, just like you would with format strings: 1111This default can be overriden by using modifiers on the template string operands, just like you would with format strings:
3053 1112
3054```rust,allow_fail 1113```rust,allow_fail
3055# #![feature(asm)] 1114#![feature(asm)]
3056let mut x: u16 = 0xab; 1115let mut x: u16 = 0xab;
3057 1116
3058unsafe { 1117unsafe {
@@ -3077,7 +1136,7 @@ For example, in x86/x86_64 and intel assembly syntax, you should wrap inputs/out
3077to indicate they are memory operands: 1136to indicate they are memory operands:
3078 1137
3079```rust,allow_fail 1138```rust,allow_fail
3080# #![feature(asm, llvm_asm)] 1139#![feature(asm, llvm_asm)]
3081# fn load_fpu_control_word(control: u16) { 1140# fn load_fpu_control_word(control: u16) {
3082unsafe { 1141unsafe {
3083 asm!("fldcw [{}]", in(reg) &control, options(nostack)); 1142 asm!("fldcw [{}]", in(reg) &control, options(nostack));
@@ -3088,6 +1147,43 @@ unsafe {
3088# } 1147# }
3089``` 1148```
3090 1149
1150## Labels
1151
1152The compiler is allowed to instantiate multiple copies an `asm!` block, for example when the function containing it is inlined in multiple places. As a consequence, you should only use GNU assembler [local labels] inside inline assembly code. Defining symbols in assembly code may lead to assembler and/or linker errors due to duplicate symbol definitions.
1153
1154Moreover, due to [an llvm bug], you shouldn't use labels exclusively made of `0` and `1` digits, e.g. `0`, `11` or `101010`, as they may end up being interpreted as binary values.
1155
1156```rust,allow_fail
1157#![feature(asm)]
1158
1159let mut a = 0;
1160unsafe {
1161 asm!(
1162 "mov {0}, 10",
1163 "2:",
1164 "sub {0}, 1",
1165 "cmp {0}, 3",
1166 "jle 2f",
1167 "jmp 2b",
1168 "2:",
1169 "add {0}, 2",
1170 out(reg) a
1171 );
1172}
1173assert_eq!(a, 5);
1174```
1175
1176This will decrement the `{0}` register value from 10 to 3, then add 2 and store it in `a`.
1177
1178This example show a few thing:
1179
1180First that the same number can be used as a label multiple times in the same inline block.
1181
1182Second, that when a numeric label is used as a reference (as an instruction operand, for example), the suffixes b (“backward”) or f (“forward”) should be added to the numeric label. It will then refer to the nearest label defined by this number in this direction.
1183
1184[local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
1185[an llvm bug]: https://bugs.llvm.org/show_bug.cgi?id=36144
1186
3091## Options 1187## Options
3092 1188
3093By default, an inline assembly block is treated the same way as an external FFI function call with a custom calling convention: it may read/write memory, have observable side effects, etc. However in many cases, it is desirable to give the compiler more information about what the assembly code is actually doing so that it can optimize better. 1189By default, an inline assembly block is treated the same way as an external FFI function call with a custom calling convention: it may read/write memory, have observable side effects, etc. However in many cases, it is desirable to give the compiler more information about what the assembly code is actually doing so that it can optimize better.
@@ -3095,7 +1191,7 @@ By default, an inline assembly block is treated the same way as an external FFI
3095Let's take our previous example of an `add` instruction: 1191Let's take our previous example of an `add` instruction:
3096 1192
3097```rust,allow_fail 1193```rust,allow_fail
3098# #![feature(asm)] 1194#![feature(asm)]
3099let mut a: u64 = 4; 1195let mut a: u64 = 4;
3100let b: u64 = 4; 1196let b: u64 = 4;
3101unsafe { 1197unsafe {
@@ -3138,7 +1234,7 @@ options := "options(" option *["," option] [","] ")"
3138asm := "asm!(" format_string *("," format_string) *("," [ident "="] operand) ["," options] [","] ")" 1234asm := "asm!(" format_string *("," format_string) *("," [ident "="] operand) ["," options] [","] ")"
3139``` 1235```
3140 1236
3141The macro will initially be supported only on ARM, AArch64, Hexagon, x86, x86-64 and RISC-V targets. Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target. 1237The macro will initially be supported only on ARM, AArch64, Hexagon, PowerPC, x86, x86-64 and RISC-V targets. Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.
3142 1238
3143[format-syntax]: https://doc.rust-lang.org/std/fmt/#syntax 1239[format-syntax]: https://doc.rust-lang.org/std/fmt/#syntax
3144 1240
@@ -3187,7 +1283,7 @@ Several types of operands are supported:
3187 - Identical to `inout` except that the register allocator can reuse a register allocated to an `in` (this can happen if the compiler knows the `in` has the same initial value as the `inlateout`). 1283 - Identical to `inout` except that the register allocator can reuse a register allocated to an `in` (this can happen if the compiler knows the `in` has the same initial value as the `inlateout`).
3188 - You should only write to the register after all inputs are read, otherwise you may clobber an input. 1284 - You should only write to the register after all inputs are read, otherwise you may clobber an input.
3189* `const <expr>` 1285* `const <expr>`
3190 - `<expr>` must be an integer or floating-point constant expression. 1286 - `<expr>` must be an integer constant expression.
3191 - The value of the expression is formatted as a string and substituted directly into the asm template string. 1287 - The value of the expression is formatted as a string and substituted directly into the asm template string.
3192* `sym <path>` 1288* `sym <path>`
3193 - `<path>` must refer to a `fn` or `static`. 1289 - `<path>` must refer to a `fn` or `static`.
@@ -3214,20 +1310,20 @@ Here is the list of currently supported register classes:
3214 1310
3215| Architecture | Register class | Registers | LLVM constraint code | 1311| Architecture | Register class | Registers | LLVM constraint code |
3216| ------------ | -------------- | --------- | -------------------- | 1312| ------------ | -------------- | --------- | -------------------- |
3217| x86 | `reg` | `ax`, `bx`, `cx`, `dx`, `si`, `di`, `r[8-15]` (x86-64 only) | `r` | 1313| x86 | `reg` | `ax`, `bx`, `cx`, `dx`, `si`, `di`, `bp`, `r[8-15]` (x86-64 only) | `r` |
3218| x86 | `reg_abcd` | `ax`, `bx`, `cx`, `dx` | `Q` | 1314| x86 | `reg_abcd` | `ax`, `bx`, `cx`, `dx` | `Q` |
3219| x86-32 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `ah`, `bh`, `ch`, `dh` | `q` | 1315| x86-32 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `ah`, `bh`, `ch`, `dh` | `q` |
3220| x86-64 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `sil`, `dil`, `r[8-15]b`, `ah`\*, `bh`\*, `ch`\*, `dh`\* | `q` | 1316| x86-64 | `reg_byte`\* | `al`, `bl`, `cl`, `dl`, `sil`, `dil`, `bpl`, `r[8-15]b` | `q` |
3221| x86 | `xmm_reg` | `xmm[0-7]` (x86) `xmm[0-15]` (x86-64) | `x` | 1317| x86 | `xmm_reg` | `xmm[0-7]` (x86) `xmm[0-15]` (x86-64) | `x` |
3222| x86 | `ymm_reg` | `ymm[0-7]` (x86) `ymm[0-15]` (x86-64) | `x` | 1318| x86 | `ymm_reg` | `ymm[0-7]` (x86) `ymm[0-15]` (x86-64) | `x` |
3223| x86 | `zmm_reg` | `zmm[0-7]` (x86) `zmm[0-31]` (x86-64) | `v` | 1319| x86 | `zmm_reg` | `zmm[0-7]` (x86) `zmm[0-31]` (x86-64) | `v` |
3224| x86 | `kreg` | `k[1-7]` | `Yk` | 1320| x86 | `kreg` | `k[1-7]` | `Yk` |
3225| AArch64 | `reg` | `x[0-28]`, `x30` | `r` | 1321| AArch64 | `reg` | `x[0-30]` | `r` |
3226| AArch64 | `vreg` | `v[0-31]` | `w` | 1322| AArch64 | `vreg` | `v[0-31]` | `w` |
3227| AArch64 | `vreg_low16` | `v[0-15]` | `x` | 1323| AArch64 | `vreg_low16` | `v[0-15]` | `x` |
3228| ARM | `reg` | `r[0-5]` `r7`\*, `r[8-10]`, `r11`\*, `r12`, `r14` | `r` | 1324| ARM | `reg` | `r[0-12]`, `r14` | `r` |
3229| ARM (Thumb) | `reg_thumb` | `r[0-r7]` | `l` | 1325| ARM (Thumb) | `reg_thumb` | `r[0-r7]` | `l` |
3230| ARM (ARM) | `reg_thumb` | `r[0-r10]`, `r12`, `r14` | `l` | 1326| ARM (ARM) | `reg_thumb` | `r[0-r12]`, `r14` | `l` |
3231| ARM | `sreg` | `s[0-31]` | `t` | 1327| ARM | `sreg` | `s[0-31]` | `t` |
3232| ARM | `sreg_low16` | `s[0-15]` | `x` | 1328| ARM | `sreg_low16` | `s[0-15]` | `x` |
3233| ARM | `dreg` | `d[0-31]` | `w` | 1329| ARM | `dreg` | `d[0-31]` | `w` |
@@ -3244,17 +1340,18 @@ Here is the list of currently supported register classes:
3244| RISC-V | `reg` | `x1`, `x[5-7]`, `x[9-15]`, `x[16-31]` (non-RV32E) | `r` | 1340| RISC-V | `reg` | `x1`, `x[5-7]`, `x[9-15]`, `x[16-31]` (non-RV32E) | `r` |
3245| RISC-V | `freg` | `f[0-31]` | `f` | 1341| RISC-V | `freg` | `f[0-31]` | `f` |
3246| Hexagon | `reg` | `r[0-28]` | `r` | 1342| Hexagon | `reg` | `r[0-28]` | `r` |
1343| PowerPC | `reg` | `r[0-31]` | `r` |
1344| PowerPC | `reg_nonzero` | | `r[1-31]` | `b` |
1345| PowerPC | `freg` | `f[0-31]` | `f` |
3247| wasm32 | `local` | None\* | `r` | 1346| wasm32 | `local` | None\* | `r` |
3248 1347
3249> **Note**: On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register. 1348> **Note**: On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.
3250> 1349>
3251> Note #2: On x86-64 the high byte registers (e.g. `ah`) are only available when used as an explicit register. Specifying the `reg_byte` register class for an operand will always allocate a low byte register. 1350> Note #2: On x86-64 the high byte registers (e.g. `ah`) are not available in the `reg_byte` register class.
3252> 1351>
3253> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported. 1352> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported.
3254> 1353>
3255> Note #4: On ARM the frame pointer is either `r7` or `r11` depending on the platform. 1354> Note #4: WebAssembly doesn't have registers, so named registers are not supported.
3256>
3257> Note #5: WebAssembly doesn't have registers, so named registers are not supported.
3258 1355
3259Additional register classes may be added in the future based on demand (e.g. MMX, x87, etc). 1356Additional register classes may be added in the future based on demand (e.g. MMX, x87, etc).
3260 1357
@@ -3288,6 +1385,9 @@ Each register class has constraints on which value types they can be used with.
3288| RISC-V | `freg` | `f` | `f32` | 1385| RISC-V | `freg` | `f` | `f32` |
3289| RISC-V | `freg` | `d` | `f64` | 1386| RISC-V | `freg` | `d` | `f64` |
3290| Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` | 1387| Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |
1388| PowerPC | `reg` | None | `i8`, `i16`, `i32` |
1389| PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32` |
1390| PowerPC | `freg` | None | `f32`, `f64` |
3291| wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` | 1391| wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` |
3292 1392
3293> **Note**: For the purposes of the above table pointers, function pointers and `isize`/`usize` are treated as the equivalent integer type (`i16`/`i32`/`i64` depending on the target). 1393> **Note**: For the purposes of the above table pointers, function pointers and `isize`/`usize` are treated as the equivalent integer type (`i16`/`i32`/`i64` depending on the target).
@@ -3356,13 +1456,14 @@ Some registers cannot be used for input or output operands:
3356| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. | 1456| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |
3357| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon), `$fp` (MIPS) | The frame pointer cannot be used as an input or output. | 1457| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon), `$fp` (MIPS) | The frame pointer cannot be used as an input or output. |
3358| ARM | `r7` or `r11` | On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. | 1458| ARM | `r7` or `r11` | On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. |
3359| ARM | `r6` | `r6` is used internally by LLVM as a base pointer and therefore cannot be used as an input or output. | 1459| All | `si` (x86-32), `bx` (x86-64), `r6` (ARM), `x19` (AArch64), `r19` (Hexagon), `x9` (RISC-V) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
3360| x86 | `k0` | This is a constant zero register which can't be modified. | 1460| x86 | `k0` | This is a constant zero register which can't be modified. |
3361| x86 | `ip` | This is the program counter, not a real register. | 1461| x86 | `ip` | This is the program counter, not a real register. |
3362| x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). | 1462| x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). |
3363| x86 | `st([0-7])` | x87 registers are not currently supported (but may be in the future). | 1463| x86 | `st([0-7])` | x87 registers are not currently supported (but may be in the future). |
3364| AArch64 | `xzr` | This is a constant zero register which can't be modified. | 1464| AArch64 | `xzr` | This is a constant zero register which can't be modified. |
3365| ARM | `pc` | This is the program counter, not a real register. | 1465| ARM | `pc` | This is the program counter, not a real register. |
1466| ARM | `r9` | This is a reserved register on some ARM targets. |
3366| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. | 1467| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
3367| MIPS | `$1` or `$at` | Reserved for assembler. | 1468| MIPS | `$1` or `$at` | Reserved for assembler. |
3368| MIPS | `$26`/`$k0`, `$27`/`$k1` | OS-reserved registers. | 1469| MIPS | `$26`/`$k0`, `$27`/`$k1` | OS-reserved registers. |
@@ -3372,9 +1473,10 @@ Some registers cannot be used for input or output operands:
3372| RISC-V | `gp`, `tp` | These registers are reserved and cannot be used as inputs or outputs. | 1473| RISC-V | `gp`, `tp` | These registers are reserved and cannot be used as inputs or outputs. |
3373| Hexagon | `lr` | This is the link register which cannot be used as an input or output. | 1474| Hexagon | `lr` | This is the link register which cannot be used as an input or output. |
3374 1475
3375In some cases LLVM will allocate a "reserved register" for `reg` operands even though this register cannot be explicitly specified. Assembly code making use of reserved registers should be careful since `reg` operands may alias with those registers. Reserved registers are: 1476In some cases LLVM will allocate a "reserved register" for `reg` operands even though this register cannot be explicitly specified. Assembly code making use of reserved registers should be careful since `reg` operands may alias with those registers. Reserved registers are the frame pointer and base pointer
3376- The frame pointer on all architectures. 1477- The frame pointer and LLVM base pointer on all architectures.
3377- `r6` on ARM. 1478- `r9` on ARM.
1479- `x18` on AArch64.
3378 1480
3379## Template modifiers 1481## Template modifiers
3380 1482
@@ -3423,6 +1525,9 @@ The supported modifiers are a subset of LLVM's (and GCC's) [asm template argumen
3423| RISC-V | `reg` | None | `x1` | None | 1525| RISC-V | `reg` | None | `x1` | None |
3424| RISC-V | `freg` | None | `f0` | None | 1526| RISC-V | `freg` | None | `f0` | None |
3425| Hexagon | `reg` | None | `r0` | None | 1527| Hexagon | `reg` | None | `r0` | None |
1528| PowerPC | `reg` | None | `0` | None |
1529| PowerPC | `reg_nonzero` | None | `3` | `b` |
1530| PowerPC | `freg` | None | `0` | None |
3426 1531
3427> Notes: 1532> Notes:
3428> - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register. 1533> - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register.
@@ -3503,116 +1608,633 @@ The compiler performs some additional checks on options:
3503 - You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds). 1608 - You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds).
3504 - The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited. 1609 - The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.
3505- You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places. 1610- You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places.
3506 - As a consequence, you should only use [local labels] inside inline assembly code. Defining symbols in assembly code may lead to assembler and/or linker errors due to duplicate symbol definitions.
3507 1611
3508> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call. 1612> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.
1613"##,
1614 },
1615 Lint {
1616 label: "auto_traits",
1617 description: r##"# `auto_traits`
3509 1618
3510[local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels 1619The tracking issue for this feature is [#13231]
1620
1621[#13231]: https://github.com/rust-lang/rust/issues/13231
1622
1623----
1624
1625The `auto_traits` feature gate allows you to define auto traits.
1626
1627Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits
1628that are automatically implemented for every type, unless the type, or a type it contains,
1629has explicitly opted out via a negative impl. (Negative impls are separately controlled
1630by the `negative_impls` feature.)
1631
1632[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
1633[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
1634
1635```rust,ignore (partial-example)
1636impl !Trait for Type {}
1637```
1638
1639Example:
1640
1641```rust
1642#![feature(negative_impls)]
1643#![feature(auto_traits)]
1644
1645auto trait Valid {}
1646
1647struct True;
1648struct False;
1649
1650impl !Valid for False {}
1651
1652struct MaybeValid<T>(T);
1653
1654fn must_be_valid<T: Valid>(_t: T) { }
1655
1656fn main() {
1657 // works
1658 must_be_valid( MaybeValid(True) );
1659
1660 // compiler error - trait bound not satisfied
1661 // must_be_valid( MaybeValid(False) );
1662}
1663```
1664
1665## Automatic trait implementations
1666
1667When a type is declared as an `auto trait`, we will automatically
1668create impls for every struct/enum/union, unless an explicit impl is
1669provided. These automatic impls contain a where clause for each field
1670of the form `T: AutoTrait`, where `T` is the type of the field and
1671`AutoTrait` is the auto trait in question. As an example, consider the
1672struct `List` and the auto trait `Send`:
1673
1674```rust
1675struct List<T> {
1676 data: T,
1677 next: Option<Box<List<T>>>,
1678}
1679```
1680
1681Presuming that there is no explicit impl of `Send` for `List`, the
1682compiler will supply an automatic impl of the form:
1683
1684```rust
1685struct List<T> {
1686 data: T,
1687 next: Option<Box<List<T>>>,
1688}
1689
1690unsafe impl<T> Send for List<T>
1691where
1692 T: Send, // from the field `data`
1693 Option<Box<List<T>>>: Send, // from the field `next`
1694{ }
1695```
1696
1697Explicit impls may be either positive or negative. They take the form:
1698
1699```rust,ignore (partial-example)
1700impl<...> AutoTrait for StructName<..> { }
1701impl<...> !AutoTrait for StructName<..> { }
1702```
1703
1704## Coinduction: Auto traits permit cyclic matching
1705
1706Unlike ordinary trait matching, auto traits are **coinductive**. This
1707means, in short, that cycles which occur in trait matching are
1708considered ok. As an example, consider the recursive struct `List`
1709introduced in the previous section. In attempting to determine whether
1710`List: Send`, we would wind up in a cycle: to apply the impl, we must
1711show that `Option<Box<List>>: Send`, which will in turn require
1712`Box<List>: Send` and then finally `List: Send` again. Under ordinary
1713trait matching, this cycle would be an error, but for an auto trait it
1714is considered a successful match.
1715
1716## Items
1717
1718Auto traits cannot have any trait items, such as methods or associated types. This ensures that we can generate default implementations.
1719
1720## Supertraits
1721
1722Auto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile.
3511"##, 1723"##,
3512 }, 1724 },
3513 LintCompletion { 1725 Lint {
3514 label: "flt2dec", 1726 label: "box_patterns",
3515 description: r##"# `flt2dec` 1727 description: r##"# `box_patterns`
1728
1729The tracking issue for this feature is: [#29641]
1730
1731[#29641]: https://github.com/rust-lang/rust/issues/29641
1732
1733See also [`box_syntax`](box-syntax.md)
1734
1735------------------------
1736
1737Box patterns let you match on `Box<T>`s:
1738
1739
1740```rust
1741#![feature(box_patterns)]
1742
1743fn main() {
1744 let b = Some(Box::new(5));
1745 match b {
1746 Some(box n) if n < 0 => {
1747 println!("Box contains negative number {}", n);
1748 },
1749 Some(box n) if n >= 0 => {
1750 println!("Box contains non-negative number {}", n);
1751 },
1752 None => {
1753 println!("No box");
1754 },
1755 _ => unreachable!()
1756 }
1757}
1758```
1759"##,
1760 },
1761 Lint {
1762 label: "box_syntax",
1763 description: r##"# `box_syntax`
1764
1765The tracking issue for this feature is: [#49733]
1766
1767[#49733]: https://github.com/rust-lang/rust/issues/49733
1768
1769See also [`box_patterns`](box-patterns.md)
1770
1771------------------------
1772
1773Currently the only stable way to create a `Box` is via the `Box::new` method.
1774Also it is not possible in stable Rust to destructure a `Box` in a match
1775pattern. The unstable `box` keyword can be used to create a `Box`. An example
1776usage would be:
1777
1778```rust
1779#![feature(box_syntax)]
1780
1781fn main() {
1782 let b = box 5;
1783}
1784```
1785"##,
1786 },
1787 Lint {
1788 label: "c_unwind",
1789 description: r##"# `c_unwind`
1790
1791The tracking issue for this feature is: [#74990]
1792
1793[#74990]: https://github.com/rust-lang/rust/issues/74990
1794
1795------------------------
1796
1797Introduces four new ABI strings: "C-unwind", "stdcall-unwind",
1798"thiscall-unwind", and "system-unwind". These enable unwinding from other
1799languages (such as C++) into Rust frames and from Rust into other languages.
1800
1801See [RFC 2945] for more information.
1802
1803[RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
1804"##,
1805 },
1806 Lint {
1807 label: "c_variadic",
1808 description: r##"# `c_variadic`
1809
1810The tracking issue for this feature is: [#44930]
1811
1812[#44930]: https://github.com/rust-lang/rust/issues/44930
1813
1814------------------------
1815
1816The `c_variadic` language feature enables C-variadic functions to be
1817defined in Rust. The may be called both from within Rust and via FFI.
1818
1819## Examples
1820
1821```rust
1822#![feature(c_variadic)]
1823
1824pub unsafe extern "C" fn add(n: usize, mut args: ...) -> usize {
1825 let mut sum = 0;
1826 for _ in 0..n {
1827 sum += args.arg::<usize>();
1828 }
1829 sum
1830}
1831```
1832"##,
1833 },
1834 Lint {
1835 label: "c_variadic",
1836 description: r##"# `c_variadic`
1837
1838The tracking issue for this feature is: [#44930]
1839
1840[#44930]: https://github.com/rust-lang/rust/issues/44930
1841
1842------------------------
1843
1844The `c_variadic` library feature exposes the `VaList` structure,
1845Rust's analogue of C's `va_list` type.
1846
1847## Examples
1848
1849```rust
1850#![feature(c_variadic)]
1851
1852use std::ffi::VaList;
1853
1854pub unsafe extern "C" fn vadd(n: usize, mut args: VaList) -> usize {
1855 let mut sum = 0;
1856 for _ in 0..n {
1857 sum += args.arg::<usize>();
1858 }
1859 sum
1860}
1861```
1862"##,
1863 },
1864 Lint {
1865 label: "c_void_variant",
1866 description: r##"# `c_void_variant`
3516 1867
3517This feature is internal to the Rust compiler and is not intended for general use. 1868This feature is internal to the Rust compiler and is not intended for general use.
3518 1869
3519------------------------ 1870------------------------
3520"##, 1871"##,
3521 }, 1872 },
3522 LintCompletion { 1873 Lint {
3523 label: "global_asm", 1874 label: "cfg_panic",
3524 description: r##"# `global_asm` 1875 description: r##"# `cfg_panic`
3525 1876
3526The tracking issue for this feature is: [#35119] 1877The tracking issue for this feature is: [#77443]
3527 1878
3528[#35119]: https://github.com/rust-lang/rust/issues/35119 1879[#77443]: https://github.com/rust-lang/rust/issues/77443
3529 1880
3530------------------------ 1881------------------------
3531 1882
3532The `global_asm!` macro allows the programmer to write arbitrary 1883The `cfg_panic` feature makes it possible to execute different code
3533assembly outside the scope of a function body, passing it through 1884depending on the panic strategy.
3534`rustc` and `llvm` to the assembler. The macro is a no-frills
3535interface to LLVM's concept of [module-level inline assembly]. That is,
3536all caveats applicable to LLVM's module-level inline assembly apply
3537to `global_asm!`.
3538 1885
3539[module-level inline assembly]: http://llvm.org/docs/LangRef.html#module-level-inline-assembly 1886Possible values at the moment are `"unwind"` or `"abort"`, although
1887it is possible that new panic strategies may be added to Rust in the
1888future.
3540 1889
3541`global_asm!` fills a role not currently satisfied by either `asm!` 1890## Examples
3542or `#[naked]` functions. The programmer has _all_ features of the
3543assembler at their disposal. The linker will expect to resolve any
3544symbols defined in the inline assembly, modulo any symbols marked as
3545external. It also means syntax for directives and assembly follow the
3546conventions of the assembler in your toolchain.
3547 1891
3548A simple usage looks like this: 1892```rust
1893#![feature(cfg_panic)]
3549 1894
3550```rust,ignore (requires-external-file) 1895#[cfg(panic = "unwind")]
3551#![feature(global_asm)] 1896fn a() {
3552# // you also need relevant target_arch cfgs 1897 // ...
3553global_asm!(include_str!("something_neato.s")); 1898}
1899
1900#[cfg(not(panic = "unwind"))]
1901fn a() {
1902 // ...
1903}
1904
1905fn b() {
1906 if cfg!(panic = "abort") {
1907 // ...
1908 } else {
1909 // ...
1910 }
1911}
3554``` 1912```
1913"##,
1914 },
1915 Lint {
1916 label: "cfg_sanitize",
1917 description: r##"# `cfg_sanitize`
3555 1918
3556And a more complicated usage looks like this: 1919The tracking issue for this feature is: [#39699]
3557 1920
3558```rust,no_run 1921[#39699]: https://github.com/rust-lang/rust/issues/39699
3559#![feature(global_asm)]
3560# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
3561# mod x86 {
3562 1922
3563pub mod sally { 1923------------------------
3564 global_asm!(r#"
3565 .global foo
3566 foo:
3567 jmp baz
3568 "#);
3569 1924
3570 #[no_mangle] 1925The `cfg_sanitize` feature makes it possible to execute different code
3571 pub unsafe extern "C" fn baz() {} 1926depending on whether a particular sanitizer is enabled or not.
1927
1928## Examples
1929
1930```rust
1931#![feature(cfg_sanitize)]
1932
1933#[cfg(sanitize = "thread")]
1934fn a() {
1935 // ...
3572} 1936}
3573 1937
3574// the symbols `foo` and `bar` are global, no matter where 1938#[cfg(not(sanitize = "thread"))]
3575// `global_asm!` was used. 1939fn a() {
3576extern "C" { 1940 // ...
3577 fn foo();
3578 fn bar();
3579} 1941}
3580 1942
3581pub mod harry { 1943fn b() {
3582 global_asm!(r#" 1944 if cfg!(sanitize = "leak") {
3583 .global bar 1945 // ...
3584 bar: 1946 } else {
3585 jmp quux 1947 // ...
3586 "#); 1948 }
1949}
1950```
1951"##,
1952 },
1953 Lint {
1954 label: "cfg_version",
1955 description: r##"# `cfg_version`
3587 1956
3588 #[no_mangle] 1957The tracking issue for this feature is: [#64796]
3589 pub unsafe extern "C" fn quux() {} 1958
1959[#64796]: https://github.com/rust-lang/rust/issues/64796
1960
1961------------------------
1962
1963The `cfg_version` feature makes it possible to execute different code
1964depending on the compiler version. It will return true if the compiler
1965version is greater than or equal to the specified version.
1966
1967## Examples
1968
1969```rust
1970#![feature(cfg_version)]
1971
1972#[cfg(version("1.42"))] // 1.42 and above
1973fn a() {
1974 // ...
1975}
1976
1977#[cfg(not(version("1.42")))] // 1.41 and below
1978fn a() {
1979 // ...
1980}
1981
1982fn b() {
1983 if cfg!(version("1.42")) {
1984 // ...
1985 } else {
1986 // ...
1987 }
3590} 1988}
3591# }
3592``` 1989```
1990"##,
1991 },
1992 Lint {
1993 label: "char_error_internals",
1994 description: r##"# `char_error_internals`
3593 1995
3594You may use `global_asm!` multiple times, anywhere in your crate, in 1996This feature is internal to the Rust compiler and is not intended for general use.
3595whatever way suits you. The effect is as if you concatenated all
3596usages and placed the larger, single usage in the crate root.
3597 1997
3598------------------------ 1998------------------------
1999"##,
2000 },
2001 Lint {
2002 label: "cmse_nonsecure_entry",
2003 description: r##"# `cmse_nonsecure_entry`
3599 2004
3600If you don't need quite as much power and flexibility as 2005The tracking issue for this feature is: [#75835]
3601`global_asm!` provides, and you don't mind restricting your inline 2006
3602assembly to `fn` bodies only, you might try the 2007[#75835]: https://github.com/rust-lang/rust/issues/75835
3603[asm](asm.md) feature instead. 2008
2009------------------------
2010
2011The [TrustZone-M
2012feature](https://developer.arm.com/documentation/100690/latest/) is available
2013for targets with the Armv8-M architecture profile (`thumbv8m` in their target
2014name).
2015LLVM, the Rust compiler and the linker are providing
2016[support](https://developer.arm.com/documentation/ecm0359818/latest/) for the
2017TrustZone-M feature.
2018
2019One of the things provided, with this unstable feature, is the
2020`cmse_nonsecure_entry` attribute. This attribute marks a Secure function as an
2021entry function (see [section
20225.4](https://developer.arm.com/documentation/ecm0359818/latest/) for details).
2023With this attribute, the compiler will do the following:
2024* add a special symbol on the function which is the `__acle_se_` prefix and the
2025 standard function name
2026* constrain the number of parameters to avoid using the Non-Secure stack
2027* before returning from the function, clear registers that might contain Secure
2028 information
2029* use the `BXNS` instruction to return
2030
2031Because the stack can not be used to pass parameters, there will be compilation
2032errors if:
2033* the total size of all parameters is too big (for example more than four 32
2034 bits integers)
2035* the entry function is not using a C ABI
2036
2037The special symbol `__acle_se_` will be used by the linker to generate a secure
2038gateway veneer.
2039
2040<!-- NOTE(ignore) this example is specific to thumbv8m targets -->
2041
2042``` rust,ignore
2043#![feature(cmse_nonsecure_entry)]
2044
2045#[no_mangle]
2046#[cmse_nonsecure_entry]
2047pub extern "C" fn entry_function(input: u32) -> u32 {
2048 input + 6
2049}
2050```
2051
2052``` text
2053$ rustc --emit obj --crate-type lib --target thumbv8m.main-none-eabi function.rs
2054$ arm-none-eabi-objdump -D function.o
2055
205600000000 <entry_function>:
2057 0: b580 push {r7, lr}
2058 2: 466f mov r7, sp
2059 4: b082 sub sp, #8
2060 6: 9001 str r0, [sp, #4]
2061 8: 1d81 adds r1, r0, #6
2062 a: 460a mov r2, r1
2063 c: 4281 cmp r1, r0
2064 e: 9200 str r2, [sp, #0]
2065 10: d30b bcc.n 2a <entry_function+0x2a>
2066 12: e7ff b.n 14 <entry_function+0x14>
2067 14: 9800 ldr r0, [sp, #0]
2068 16: b002 add sp, #8
2069 18: e8bd 4080 ldmia.w sp!, {r7, lr}
2070 1c: 4671 mov r1, lr
2071 1e: 4672 mov r2, lr
2072 20: 4673 mov r3, lr
2073 22: 46f4 mov ip, lr
2074 24: f38e 8800 msr CPSR_f, lr
2075 28: 4774 bxns lr
2076 2a: f240 0000 movw r0, #0
2077 2e: f2c0 0000 movt r0, #0
2078 32: f240 0200 movw r2, #0
2079 36: f2c0 0200 movt r2, #0
2080 3a: 211c movs r1, #28
2081 3c: f7ff fffe bl 0 <_ZN4core9panicking5panic17h5c028258ca2fb3f5E>
2082 40: defe udf #254 ; 0xfe
2083```
3604"##, 2084"##,
3605 }, 2085 },
3606 LintCompletion { 2086 Lint {
3607 label: "derive_eq", 2087 label: "compiler_builtins",
3608 description: r##"# `derive_eq` 2088 description: r##"# `compiler_builtins`
3609 2089
3610This feature is internal to the Rust compiler and is not intended for general use. 2090This feature is internal to the Rust compiler and is not intended for general use.
3611 2091
3612------------------------ 2092------------------------
3613"##, 2093"##,
3614 }, 2094 },
3615 LintCompletion { 2095 Lint {
2096 label: "concat_idents",
2097 description: r##"# `concat_idents`
2098
2099The tracking issue for this feature is: [#29599]
2100
2101[#29599]: https://github.com/rust-lang/rust/issues/29599
2102
2103------------------------
2104
2105The `concat_idents` feature adds a macro for concatenating multiple identifiers
2106into one identifier.
2107
2108## Examples
2109
2110```rust
2111#![feature(concat_idents)]
2112
2113fn main() {
2114 fn foobar() -> u32 { 23 }
2115 let f = concat_idents!(foo, bar);
2116 assert_eq!(f(), 23);
2117}
2118```
2119"##,
2120 },
2121 Lint {
2122 label: "const_eval_limit",
2123 description: r##"# `const_eval_limit`
2124
2125The tracking issue for this feature is: [#67217]
2126
2127[#67217]: https://github.com/rust-lang/rust/issues/67217
2128
2129The `const_eval_limit` allows someone to limit the evaluation steps the CTFE undertakes to evaluate a `const fn`.
2130"##,
2131 },
2132 Lint {
2133 label: "core_intrinsics",
2134 description: r##"# `core_intrinsics`
2135
2136This feature is internal to the Rust compiler and is not intended for general use.
2137
2138------------------------
2139"##,
2140 },
2141 Lint {
2142 label: "core_panic",
2143 description: r##"# `core_panic`
2144
2145This feature is internal to the Rust compiler and is not intended for general use.
2146
2147------------------------
2148"##,
2149 },
2150 Lint {
2151 label: "core_private_bignum",
2152 description: r##"# `core_private_bignum`
2153
2154This feature is internal to the Rust compiler and is not intended for general use.
2155
2156------------------------
2157"##,
2158 },
2159 Lint {
2160 label: "core_private_diy_float",
2161 description: r##"# `core_private_diy_float`
2162
2163This feature is internal to the Rust compiler and is not intended for general use.
2164
2165------------------------
2166"##,
2167 },
2168 Lint {
2169 label: "crate_visibility_modifier",
2170 description: r##"# `crate_visibility_modifier`
2171
2172The tracking issue for this feature is: [#53120]
2173
2174[#53120]: https://github.com/rust-lang/rust/issues/53120
2175
2176-----
2177
2178The `crate_visibility_modifier` feature allows the `crate` keyword to be used
2179as a visibility modifier synonymous to `pub(crate)`, indicating that a type
2180(function, _&c._) is to be visible to the entire enclosing crate, but not to
2181other crates.
2182
2183```rust
2184#![feature(crate_visibility_modifier)]
2185
2186crate struct Foo {
2187 bar: usize,
2188}
2189```
2190"##,
2191 },
2192 Lint {
2193 label: "custom_test_frameworks",
2194 description: r##"# `custom_test_frameworks`
2195
2196The tracking issue for this feature is: [#50297]
2197
2198[#50297]: https://github.com/rust-lang/rust/issues/50297
2199
2200------------------------
2201
2202The `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`.
2203Any function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`)
2204and be passed to the test runner determined by the `#![test_runner]` crate attribute.
2205
2206```rust
2207#![feature(custom_test_frameworks)]
2208#![test_runner(my_runner)]
2209
2210fn my_runner(tests: &[&i32]) {
2211 for t in tests {
2212 if **t == 0 {
2213 println!("PASSED");
2214 } else {
2215 println!("FAILED");
2216 }
2217 }
2218}
2219
2220#[test_case]
2221const WILL_PASS: i32 = 0;
2222
2223#[test_case]
2224const WILL_FAIL: i32 = 4;
2225```
2226"##,
2227 },
2228 Lint {
2229 label: "dec2flt",
2230 description: r##"# `dec2flt`
2231
2232This feature is internal to the Rust compiler and is not intended for general use.
2233
2234------------------------
2235"##,
2236 },
2237 Lint {
3616 label: "default_free_fn", 2238 label: "default_free_fn",
3617 description: r##"# `default_free_fn` 2239 description: r##"# `default_free_fn`
3618 2240
@@ -3663,75 +2285,375 @@ fn main() {
3663``` 2285```
3664"##, 2286"##,
3665 }, 2287 },
3666 LintCompletion { 2288 Lint {
3667 label: "char_error_internals", 2289 label: "derive_clone_copy",
3668 description: r##"# `char_error_internals` 2290 description: r##"# `derive_clone_copy`
3669 2291
3670This feature is internal to the Rust compiler and is not intended for general use. 2292This feature is internal to the Rust compiler and is not intended for general use.
3671 2293
3672------------------------ 2294------------------------
3673"##, 2295"##,
3674 }, 2296 },
3675 LintCompletion { 2297 Lint {
3676 label: "libstd_sys_internals", 2298 label: "derive_eq",
3677 description: r##"# `libstd_sys_internals` 2299 description: r##"# `derive_eq`
3678 2300
3679This feature is internal to the Rust compiler and is not intended for general use. 2301This feature is internal to the Rust compiler and is not intended for general use.
3680 2302
3681------------------------ 2303------------------------
3682"##, 2304"##,
3683 }, 2305 },
3684 LintCompletion { 2306 Lint {
3685 label: "is_sorted", 2307 label: "doc_cfg",
3686 description: r##"# `is_sorted` 2308 description: r##"# `doc_cfg`
3687 2309
3688The tracking issue for this feature is: [#53485] 2310The tracking issue for this feature is: [#43781]
3689 2311
3690[#53485]: https://github.com/rust-lang/rust/issues/53485 2312------
3691 2313
3692------------------------ 2314The `doc_cfg` feature allows an API be documented as only available in some specific platforms.
2315This attribute has two effects:
3693 2316
3694Add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to `[T]`; 23171. In the annotated item's documentation, there will be a message saying "This is supported on
3695add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to 2318 (platform) only".
3696`Iterator`. 2319
23202. The item's doc-tests will only run on the specific platform.
2321
2322In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a
2323special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your
2324crate.
2325
2326This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
2327standard library be documented.
2328
2329```rust
2330#![feature(doc_cfg)]
2331
2332#[cfg(any(windows, doc))]
2333#[doc(cfg(windows))]
2334/// The application's icon in the notification area (a.k.a. system tray).
2335///
2336/// # Examples
2337///
2338/// ```no_run
2339/// extern crate my_awesome_ui_library;
2340/// use my_awesome_ui_library::current_app;
2341/// use my_awesome_ui_library::windows::notification;
2342///
2343/// let icon = current_app().get::<notification::Icon>();
2344/// icon.show();
2345/// icon.show_message("Hello");
2346/// ```
2347pub struct Icon {
2348 // ...
2349}
2350```
2351
2352[#43781]: https://github.com/rust-lang/rust/issues/43781
2353[#43348]: https://github.com/rust-lang/rust/issues/43348
3697"##, 2354"##,
3698 }, 2355 },
3699 LintCompletion { 2356 Lint {
3700 label: "c_void_variant", 2357 label: "doc_masked",
3701 description: r##"# `c_void_variant` 2358 description: r##"# `doc_masked`
2359
2360The tracking issue for this feature is: [#44027]
2361
2362-----
2363
2364The `doc_masked` feature allows a crate to exclude types from a given crate from appearing in lists
2365of trait implementations. The specifics of the feature are as follows:
2366
23671. When rustdoc encounters an `extern crate` statement annotated with a `#[doc(masked)]` attribute,
2368 it marks the crate as being masked.
2369
23702. When listing traits a given type implements, rustdoc ensures that traits from masked crates are
2371 not emitted into the documentation.
2372
23733. When listing types that implement a given trait, rustdoc ensures that types from masked crates
2374 are not emitted into the documentation.
2375
2376This feature was introduced in PR [#44026] to ensure that compiler-internal and
2377implementation-specific types and traits were not included in the standard library's documentation.
2378Such types would introduce broken links into the documentation.
2379
2380[#44026]: https://github.com/rust-lang/rust/pull/44026
2381[#44027]: https://github.com/rust-lang/rust/pull/44027
2382"##,
2383 },
2384 Lint {
2385 label: "doc_notable_trait",
2386 description: r##"# `doc_notable_trait`
2387
2388The tracking issue for this feature is: [#45040]
2389
2390The `doc_notable_trait` feature allows the use of the `#[doc(notable_trait)]`
2391attribute, which will display the trait in a "Notable traits" dialog for
2392functions returning types that implement the trait. For example, this attribute
2393is applied to the `Iterator`, `Future`, `io::Read`, and `io::Write` traits in
2394the standard library.
2395
2396You can do this on your own traits like so:
2397
2398```
2399#![feature(doc_notable_trait)]
2400
2401#[doc(notable_trait)]
2402pub trait MyTrait {}
2403
2404pub struct MyStruct;
2405impl MyTrait for MyStruct {}
2406
2407/// The docs for this function will have a button that displays a dialog about
2408/// `MyStruct` implementing `MyTrait`.
2409pub fn my_fn() -> MyStruct { MyStruct }
2410```
2411
2412This feature was originally implemented in PR [#45039].
2413
2414See also its documentation in [the rustdoc book][rustdoc-book-notable_trait].
2415
2416[#45040]: https://github.com/rust-lang/rust/issues/45040
2417[#45039]: https://github.com/rust-lang/rust/pull/45039
2418[rustdoc-book-notable_trait]: ../../rustdoc/unstable-features.html#adding-your-trait-to-the-notable-traits-dialog
2419"##,
2420 },
2421 Lint {
2422 label: "external_doc",
2423 description: r##"# `external_doc`
2424
2425The tracking issue for this feature is: [#44732]
2426
2427The `external_doc` feature allows the use of the `include` parameter to the `#[doc]` attribute, to
2428include external files in documentation. Use the attribute in place of, or in addition to, regular
2429doc comments and `#[doc]` attributes, and `rustdoc` will load the given file when it renders
2430documentation for your crate.
2431
2432With the following files in the same directory:
2433
2434`external-doc.md`:
2435
2436```markdown
2437# My Awesome Type
2438
2439This is the documentation for this spectacular type.
2440```
2441
2442`lib.rs`:
2443
2444```no_run (needs-external-files)
2445#![feature(external_doc)]
2446
2447#[doc(include = "external-doc.md")]
2448pub struct MyAwesomeType;
2449```
2450
2451`rustdoc` will load the file `external-doc.md` and use it as the documentation for the `MyAwesomeType`
2452struct.
2453
2454When locating files, `rustdoc` will base paths in the `src/` directory, as if they were alongside the
2455`lib.rs` for your crate. So if you want a `docs/` folder to live alongside the `src/` directory,
2456start your paths with `../docs/` for `rustdoc` to properly find the file.
2457
2458This feature was proposed in [RFC #1990] and initially implemented in PR [#44781].
2459
2460[#44732]: https://github.com/rust-lang/rust/issues/44732
2461[RFC #1990]: https://github.com/rust-lang/rfcs/pull/1990
2462[#44781]: https://github.com/rust-lang/rust/pull/44781
2463"##,
2464 },
2465 Lint {
2466 label: "fd",
2467 description: r##"# `fd`
3702 2468
3703This feature is internal to the Rust compiler and is not intended for general use. 2469This feature is internal to the Rust compiler and is not intended for general use.
3704 2470
3705------------------------ 2471------------------------
3706"##, 2472"##,
3707 }, 2473 },
3708 LintCompletion { 2474 Lint {
3709 label: "concat_idents", 2475 label: "fd_read",
3710 description: r##"# `concat_idents` 2476 description: r##"# `fd_read`
3711 2477
3712The tracking issue for this feature is: [#29599] 2478This feature is internal to the Rust compiler and is not intended for general use.
3713 2479
3714[#29599]: https://github.com/rust-lang/rust/issues/29599 2480------------------------
2481"##,
2482 },
2483 Lint {
2484 label: "ffi_const",
2485 description: r##"# `ffi_const`
2486
2487The tracking issue for this feature is: [#58328]
2488
2489------
2490
2491The `#[ffi_const]` attribute applies clang's `const` attribute to foreign
2492functions declarations.
2493
2494That is, `#[ffi_const]` functions shall have no effects except for its return
2495value, which can only depend on the values of the function parameters, and is
2496not affected by changes to the observable state of the program.
2497
2498Applying the `#[ffi_const]` attribute to a function that violates these
2499requirements is undefined behaviour.
2500
2501This attribute enables Rust to perform common optimizations, like sub-expression
2502elimination, and it can avoid emitting some calls in repeated invocations of the
2503function with the same argument values regardless of other operations being
2504performed in between these functions calls (as opposed to `#[ffi_pure]`
2505functions).
2506
2507## Pitfalls
2508
2509A `#[ffi_const]` function can only read global memory that would not affect
2510its return value for the whole execution of the program (e.g. immutable global
2511memory). `#[ffi_const]` functions are referentially-transparent and therefore
2512more strict than `#[ffi_pure]` functions.
2513
2514A common pitfall involves applying the `#[ffi_const]` attribute to a
2515function that reads memory through pointer arguments which do not necessarily
2516point to immutable global memory.
2517
2518A `#[ffi_const]` function that returns unit has no effect on the abstract
2519machine's state, and a `#[ffi_const]` function cannot be `#[ffi_pure]`.
2520
2521A `#[ffi_const]` function must not diverge, neither via a side effect (e.g. a
2522call to `abort`) nor by infinite loops.
2523
2524When translating C headers to Rust FFI, it is worth verifying for which targets
2525the `const` attribute is enabled in those headers, and using the appropriate
2526`cfg` macros in the Rust side to match those definitions. While the semantics of
2527`const` are implemented identically by many C and C++ compilers, e.g., clang,
2528[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily
2529implemented in this way on all of them. It is therefore also worth verifying
2530that the semantics of the C toolchain used to compile the binary being linked
2531against are compatible with those of the `#[ffi_const]`.
2532
2533[#58328]: https://github.com/rust-lang/rust/issues/58328
2534[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacgigch.html
2535[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute
2536[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_const.htm
2537"##,
2538 },
2539 Lint {
2540 label: "ffi_pure",
2541 description: r##"# `ffi_pure`
2542
2543The tracking issue for this feature is: [#58329]
2544
2545------
2546
2547The `#[ffi_pure]` attribute applies clang's `pure` attribute to foreign
2548functions declarations.
2549
2550That is, `#[ffi_pure]` functions shall have no effects except for its return
2551value, which shall not change across two consecutive function calls with
2552the same parameters.
2553
2554Applying the `#[ffi_pure]` attribute to a function that violates these
2555requirements is undefined behavior.
2556
2557This attribute enables Rust to perform common optimizations, like sub-expression
2558elimination and loop optimizations. Some common examples of pure functions are
2559`strlen` or `memcmp`.
2560
2561These optimizations are only applicable when the compiler can prove that no
2562program state observable by the `#[ffi_pure]` function has changed between calls
2563of the function, which could alter the result. See also the `#[ffi_const]`
2564attribute, which provides stronger guarantees regarding the allowable behavior
2565of a function, enabling further optimization.
2566
2567## Pitfalls
2568
2569A `#[ffi_pure]` function can read global memory through the function
2570parameters (e.g. pointers), globals, etc. `#[ffi_pure]` functions are not
2571referentially-transparent, and are therefore more relaxed than `#[ffi_const]`
2572functions.
2573
2574However, accessing global memory through volatile or atomic reads can violate the
2575requirement that two consecutive function calls shall return the same value.
2576
2577A `pure` function that returns unit has no effect on the abstract machine's
2578state.
2579
2580A `#[ffi_pure]` function must not diverge, neither via a side effect (e.g. a
2581call to `abort`) nor by infinite loops.
2582
2583When translating C headers to Rust FFI, it is worth verifying for which targets
2584the `pure` attribute is enabled in those headers, and using the appropriate
2585`cfg` macros in the Rust side to match those definitions. While the semantics of
2586`pure` are implemented identically by many C and C++ compilers, e.g., clang,
2587[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily
2588implemented in this way on all of them. It is therefore also worth verifying
2589that the semantics of the C toolchain used to compile the binary being linked
2590against are compatible with those of the `#[ffi_pure]`.
2591
2592
2593[#58329]: https://github.com/rust-lang/rust/issues/58329
2594[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacigdac.html
2595[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
2596[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_pure.htm
2597"##,
2598 },
2599 Lint {
2600 label: "flt2dec",
2601 description: r##"# `flt2dec`
2602
2603This feature is internal to the Rust compiler and is not intended for general use.
3715 2604
3716------------------------ 2605------------------------
2606"##,
2607 },
2608 Lint {
2609 label: "fmt_internals",
2610 description: r##"# `fmt_internals`
3717 2611
3718The `concat_idents` feature adds a macro for concatenating multiple identifiers 2612This feature is internal to the Rust compiler and is not intended for general use.
3719into one identifier.
3720 2613
3721## Examples 2614------------------------
2615"##,
2616 },
2617 Lint {
2618 label: "fn_traits",
2619 description: r##"# `fn_traits`
2620
2621The tracking issue for this feature is [#29625]
2622
2623See Also: [`unboxed_closures`](../language-features/unboxed-closures.md)
2624
2625[#29625]: https://github.com/rust-lang/rust/issues/29625
2626
2627----
2628
2629The `fn_traits` feature allows for implementation of the [`Fn*`] traits
2630for creating custom closure-like types.
2631
2632[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html
3722 2633
3723```rust 2634```rust
3724#![feature(concat_idents)] 2635#![feature(unboxed_closures)]
2636#![feature(fn_traits)]
2637
2638struct Adder {
2639 a: u32
2640}
2641
2642impl FnOnce<(u32, )> for Adder {
2643 type Output = u32;
2644 extern "rust-call" fn call_once(self, b: (u32, )) -> Self::Output {
2645 self.a + b.0
2646 }
2647}
3725 2648
3726fn main() { 2649fn main() {
3727 fn foobar() -> u32 { 23 } 2650 let adder = Adder { a: 3 };
3728 let f = concat_idents!(foo, bar); 2651 assert_eq!(adder(2), 5);
3729 assert_eq!(f(), 23);
3730} 2652}
3731``` 2653```
3732"##, 2654"##,
3733 }, 2655 },
3734 LintCompletion { 2656 Lint {
3735 label: "format_args_capture", 2657 label: "format_args_capture",
3736 description: r##"# `format_args_capture` 2658 description: r##"# `format_args_capture`
3737 2659
@@ -3782,16 +2704,914 @@ A non-exhaustive list of macros which benefit from this functionality include:
3782- macros in many thirdparty crates, such as `log` 2704- macros in many thirdparty crates, such as `log`
3783"##, 2705"##,
3784 }, 2706 },
3785 LintCompletion { 2707 Lint {
3786 label: "print_internals", 2708 label: "generators",
3787 description: r##"# `print_internals` 2709 description: r##"# `generators`
2710
2711The tracking issue for this feature is: [#43122]
2712
2713[#43122]: https://github.com/rust-lang/rust/issues/43122
2714
2715------------------------
2716
2717The `generators` feature gate in Rust allows you to define generator or
2718coroutine literals. A generator is a "resumable function" that syntactically
2719resembles a closure but compiles to much different semantics in the compiler
2720itself. The primary feature of a generator is that it can be suspended during
2721execution to be resumed at a later date. Generators use the `yield` keyword to
2722"return", and then the caller can `resume` a generator to resume execution just
2723after the `yield` keyword.
2724
2725Generators are an extra-unstable feature in the compiler right now. Added in
2726[RFC 2033] they're mostly intended right now as a information/constraint
2727gathering phase. The intent is that experimentation can happen on the nightly
2728compiler before actual stabilization. A further RFC will be required to
2729stabilize generators/coroutines and will likely contain at least a few small
2730tweaks to the overall design.
2731
2732[RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033
2733
2734A syntactical example of a generator is:
2735
2736```rust
2737#![feature(generators, generator_trait)]
2738
2739use std::ops::{Generator, GeneratorState};
2740use std::pin::Pin;
2741
2742fn main() {
2743 let mut generator = || {
2744 yield 1;
2745 return "foo"
2746 };
2747
2748 match Pin::new(&mut generator).resume(()) {
2749 GeneratorState::Yielded(1) => {}
2750 _ => panic!("unexpected value from resume"),
2751 }
2752 match Pin::new(&mut generator).resume(()) {
2753 GeneratorState::Complete("foo") => {}
2754 _ => panic!("unexpected value from resume"),
2755 }
2756}
2757```
2758
2759Generators are closure-like literals which can contain a `yield` statement. The
2760`yield` statement takes an optional expression of a value to yield out of the
2761generator. All generator literals implement the `Generator` trait in the
2762`std::ops` module. The `Generator` trait has one main method, `resume`, which
2763resumes execution of the generator at the previous suspension point.
2764
2765An example of the control flow of generators is that the following example
2766prints all numbers in order:
2767
2768```rust
2769#![feature(generators, generator_trait)]
2770
2771use std::ops::Generator;
2772use std::pin::Pin;
2773
2774fn main() {
2775 let mut generator = || {
2776 println!("2");
2777 yield;
2778 println!("4");
2779 };
2780
2781 println!("1");
2782 Pin::new(&mut generator).resume(());
2783 println!("3");
2784 Pin::new(&mut generator).resume(());
2785 println!("5");
2786}
2787```
2788
2789At this time the main intended use case of generators is an implementation
2790primitive for async/await syntax, but generators will likely be extended to
2791ergonomic implementations of iterators and other primitives in the future.
2792Feedback on the design and usage is always appreciated!
2793
2794### The `Generator` trait
2795
2796The `Generator` trait in `std::ops` currently looks like:
2797
2798```rust
2799# #![feature(arbitrary_self_types, generator_trait)]
2800# use std::ops::GeneratorState;
2801# use std::pin::Pin;
2802
2803pub trait Generator<R = ()> {
2804 type Yield;
2805 type Return;
2806 fn resume(self: Pin<&mut Self>, resume: R) -> GeneratorState<Self::Yield, Self::Return>;
2807}
2808```
2809
2810The `Generator::Yield` type is the type of values that can be yielded with the
2811`yield` statement. The `Generator::Return` type is the returned type of the
2812generator. This is typically the last expression in a generator's definition or
2813any value passed to `return` in a generator. The `resume` function is the entry
2814point for executing the `Generator` itself.
2815
2816The return value of `resume`, `GeneratorState`, looks like:
2817
2818```rust
2819pub enum GeneratorState<Y, R> {
2820 Yielded(Y),
2821 Complete(R),
2822}
2823```
2824
2825The `Yielded` variant indicates that the generator can later be resumed. This
2826corresponds to a `yield` point in a generator. The `Complete` variant indicates
2827that the generator is complete and cannot be resumed again. Calling `resume`
2828after a generator has returned `Complete` will likely result in a panic of the
2829program.
2830
2831### Closure-like semantics
2832
2833The closure-like syntax for generators alludes to the fact that they also have
2834closure-like semantics. Namely:
2835
2836* When created, a generator executes no code. A closure literal does not
2837 actually execute any of the closure's code on construction, and similarly a
2838 generator literal does not execute any code inside the generator when
2839 constructed.
2840
2841* Generators can capture outer variables by reference or by move, and this can
2842 be tweaked with the `move` keyword at the beginning of the closure. Like
2843 closures all generators will have an implicit environment which is inferred by
2844 the compiler. Outer variables can be moved into a generator for use as the
2845 generator progresses.
2846
2847* Generator literals produce a value with a unique type which implements the
2848 `std::ops::Generator` trait. This allows actual execution of the generator
2849 through the `Generator::resume` method as well as also naming it in return
2850 types and such.
2851
2852* Traits like `Send` and `Sync` are automatically implemented for a `Generator`
2853 depending on the captured variables of the environment. Unlike closures,
2854 generators also depend on variables live across suspension points. This means
2855 that although the ambient environment may be `Send` or `Sync`, the generator
2856 itself may not be due to internal variables live across `yield` points being
2857 not-`Send` or not-`Sync`. Note that generators do
2858 not implement traits like `Copy` or `Clone` automatically.
2859
2860* Whenever a generator is dropped it will drop all captured environment
2861 variables.
2862
2863### Generators as state machines
2864
2865In the compiler, generators are currently compiled as state machines. Each
2866`yield` expression will correspond to a different state that stores all live
2867variables over that suspension point. Resumption of a generator will dispatch on
2868the current state and then execute internally until a `yield` is reached, at
2869which point all state is saved off in the generator and a value is returned.
2870
2871Let's take a look at an example to see what's going on here:
2872
2873```rust
2874#![feature(generators, generator_trait)]
2875
2876use std::ops::Generator;
2877use std::pin::Pin;
2878
2879fn main() {
2880 let ret = "foo";
2881 let mut generator = move || {
2882 yield 1;
2883 return ret
2884 };
2885
2886 Pin::new(&mut generator).resume(());
2887 Pin::new(&mut generator).resume(());
2888}
2889```
2890
2891This generator literal will compile down to something similar to:
2892
2893```rust
2894#![feature(arbitrary_self_types, generators, generator_trait)]
2895
2896use std::ops::{Generator, GeneratorState};
2897use std::pin::Pin;
2898
2899fn main() {
2900 let ret = "foo";
2901 let mut generator = {
2902 enum __Generator {
2903 Start(&'static str),
2904 Yield1(&'static str),
2905 Done,
2906 }
2907
2908 impl Generator for __Generator {
2909 type Yield = i32;
2910 type Return = &'static str;
2911
2912 fn resume(mut self: Pin<&mut Self>, resume: ()) -> GeneratorState<i32, &'static str> {
2913 use std::mem;
2914 match mem::replace(&mut *self, __Generator::Done) {
2915 __Generator::Start(s) => {
2916 *self = __Generator::Yield1(s);
2917 GeneratorState::Yielded(1)
2918 }
2919
2920 __Generator::Yield1(s) => {
2921 *self = __Generator::Done;
2922 GeneratorState::Complete(s)
2923 }
2924
2925 __Generator::Done => {
2926 panic!("generator resumed after completion")
2927 }
2928 }
2929 }
2930 }
2931
2932 __Generator::Start(ret)
2933 };
2934
2935 Pin::new(&mut generator).resume(());
2936 Pin::new(&mut generator).resume(());
2937}
2938```
2939
2940Notably here we can see that the compiler is generating a fresh type,
2941`__Generator` in this case. This type has a number of states (represented here
2942as an `enum`) corresponding to each of the conceptual states of the generator.
2943At the beginning we're closing over our outer variable `foo` and then that
2944variable is also live over the `yield` point, so it's stored in both states.
2945
2946When the generator starts it'll immediately yield 1, but it saves off its state
2947just before it does so indicating that it has reached the yield point. Upon
2948resuming again we'll execute the `return ret` which returns the `Complete`
2949state.
2950
2951Here we can also note that the `Done` state, if resumed, panics immediately as
2952it's invalid to resume a completed generator. It's also worth noting that this
2953is just a rough desugaring, not a normative specification for what the compiler
2954does.
2955"##,
2956 },
2957 Lint {
2958 label: "global_asm",
2959 description: r##"# `global_asm`
2960
2961The tracking issue for this feature is: [#35119]
2962
2963[#35119]: https://github.com/rust-lang/rust/issues/35119
2964
2965------------------------
2966
2967The `global_asm!` macro allows the programmer to write arbitrary
2968assembly outside the scope of a function body, passing it through
2969`rustc` and `llvm` to the assembler. That is to say, `global_asm!` is
2970equivalent to assembling the asm with an external assembler and then
2971linking the resulting object file with the current crate.
2972
2973`global_asm!` fills a role not currently satisfied by either `asm!`
2974or `#[naked]` functions. The programmer has _all_ features of the
2975assembler at their disposal. The linker will expect to resolve any
2976symbols defined in the inline assembly, modulo any symbols marked as
2977external. It also means syntax for directives and assembly follow the
2978conventions of the assembler in your toolchain.
2979
2980A simple usage looks like this:
2981
2982```rust,ignore (requires-external-file)
2983#![feature(global_asm)]
2984# // you also need relevant target_arch cfgs
2985global_asm!(include_str!("something_neato.s"));
2986```
2987
2988And a more complicated usage looks like this:
2989
2990```rust,no_run
2991#![feature(global_asm)]
2992# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
2993# mod x86 {
2994
2995pub mod sally {
2996 global_asm!(
2997 ".global foo",
2998 "foo:",
2999 "jmp baz",
3000 );
3001
3002 #[no_mangle]
3003 pub unsafe extern "C" fn baz() {}
3004}
3005
3006// the symbols `foo` and `bar` are global, no matter where
3007// `global_asm!` was used.
3008extern "C" {
3009 fn foo();
3010 fn bar();
3011}
3012
3013pub mod harry {
3014 global_asm!(
3015 ".global bar",
3016 "bar:",
3017 "jmp quux",
3018 );
3019
3020 #[no_mangle]
3021 pub unsafe extern "C" fn quux() {}
3022}
3023# }
3024```
3025
3026You may use `global_asm!` multiple times, anywhere in your crate, in
3027whatever way suits you. However, you should not rely on assembler state
3028(e.g. assembler macros) defined in one `global_asm!` to be available in
3029another one. It is implementation-defined whether the multiple usages
3030are concatenated into one or assembled separately.
3031
3032`global_asm!` also supports `const` operands like `asm!`, which allows
3033constants defined in Rust to be used in assembly code:
3034
3035```rust,no_run
3036#![feature(global_asm)]
3037# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
3038# mod x86 {
3039const C: i32 = 1234;
3040global_asm!(
3041 ".global bar",
3042 "bar: .word {c}",
3043 c = const C,
3044);
3045# }
3046```
3047
3048The syntax for passing operands is the same as `asm!` except that only
3049`const` operands are allowed. Refer to the [asm](asm.md) documentation
3050for more details.
3051
3052On x86, the assembly code will use intel syntax by default. You can
3053override this by adding `options(att_syntax)` at the end of the macro
3054arguments list:
3055
3056```rust,no_run
3057#![feature(global_asm)]
3058# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
3059# mod x86 {
3060global_asm!("movl ${}, %ecx", const 5, options(att_syntax));
3061// is equivalent to
3062global_asm!("mov ecx, {}", const 5);
3063# }
3064```
3065
3066------------------------
3067
3068If you don't need quite as much power and flexibility as
3069`global_asm!` provides, and you don't mind restricting your inline
3070assembly to `fn` bodies only, you might try the
3071[asm](asm.md) feature instead.
3072"##,
3073 },
3074 Lint {
3075 label: "impl_trait_in_bindings",
3076 description: r##"# `impl_trait_in_bindings`
3077
3078The tracking issue for this feature is: [#63065]
3079
3080[#63065]: https://github.com/rust-lang/rust/issues/63065
3081
3082------------------------
3083
3084The `impl_trait_in_bindings` feature gate lets you use `impl Trait` syntax in
3085`let`, `static`, and `const` bindings.
3086
3087A simple example is:
3088
3089```rust
3090#![feature(impl_trait_in_bindings)]
3091
3092use std::fmt::Debug;
3093
3094fn main() {
3095 let a: impl Debug + Clone = 42;
3096 let b = a.clone();
3097 println!("{:?}", b); // prints `42`
3098}
3099```
3100
3101Note however that because the types of `a` and `b` are opaque in the above
3102example, calling inherent methods or methods outside of the specified traits
3103(e.g., `a.abs()` or `b.abs()`) is not allowed, and yields an error.
3104"##,
3105 },
3106 Lint {
3107 label: "infer_static_outlives_requirements",
3108 description: r##"# `infer_static_outlives_requirements`
3109
3110The tracking issue for this feature is: [#54185]
3111
3112[#54185]: https://github.com/rust-lang/rust/issues/54185
3113
3114------------------------
3115The `infer_static_outlives_requirements` feature indicates that certain
3116`'static` outlives requirements can be inferred by the compiler rather than
3117stating them explicitly.
3118
3119Note: It is an accompanying feature to `infer_outlives_requirements`,
3120which must be enabled to infer outlives requirements.
3121
3122For example, currently generic struct definitions that contain
3123references, require where-clauses of the form T: 'static. By using
3124this feature the outlives predicates will be inferred, although
3125they may still be written explicitly.
3126
3127```rust,ignore (pseudo-Rust)
3128struct Foo<U> where U: 'static { // <-- currently required
3129 bar: Bar<U>
3130}
3131struct Bar<T: 'static> {
3132 x: T,
3133}
3134```
3135
3136
3137## Examples:
3138
3139```rust,ignore (pseudo-Rust)
3140#![feature(infer_outlives_requirements)]
3141#![feature(infer_static_outlives_requirements)]
3142
3143#[rustc_outlives]
3144// Implicitly infer U: 'static
3145struct Foo<U> {
3146 bar: Bar<U>
3147}
3148struct Bar<T: 'static> {
3149 x: T,
3150}
3151```
3152"##,
3153 },
3154 Lint {
3155 label: "inline_const",
3156 description: r##"# `inline_const`
3157
3158The tracking issue for this feature is: [#76001]
3159
3160------
3161
3162This feature allows you to use inline constant expressions. For example, you can
3163turn this code:
3164
3165```rust
3166# fn add_one(x: i32) -> i32 { x + 1 }
3167const MY_COMPUTATION: i32 = 1 + 2 * 3 / 4;
3168
3169fn main() {
3170 let x = add_one(MY_COMPUTATION);
3171}
3172```
3173
3174into this code:
3175
3176```rust
3177#![feature(inline_const)]
3178
3179# fn add_one(x: i32) -> i32 { x + 1 }
3180fn main() {
3181 let x = add_one(const { 1 + 2 * 3 / 4 });
3182}
3183```
3184
3185You can also use inline constant expressions in patterns:
3186
3187```rust
3188#![feature(inline_const)]
3189
3190const fn one() -> i32 { 1 }
3191
3192let some_int = 3;
3193match some_int {
3194 const { 1 + 2 } => println!("Matched 1 + 2"),
3195 const { one() } => println!("Matched const fn returning 1"),
3196 _ => println!("Didn't match anything :("),
3197}
3198```
3199
3200[#76001]: https://github.com/rust-lang/rust/issues/76001
3201"##,
3202 },
3203 Lint {
3204 label: "int_error_internals",
3205 description: r##"# `int_error_internals`
3206
3207This feature is internal to the Rust compiler and is not intended for general use.
3208
3209------------------------
3210"##,
3211 },
3212 Lint {
3213 label: "internal_output_capture",
3214 description: r##"# `internal_output_capture`
3215
3216This feature is internal to the Rust compiler and is not intended for general use.
3217
3218------------------------
3219"##,
3220 },
3221 Lint {
3222 label: "intra_doc_pointers",
3223 description: r##"# `intra-doc-pointers`
3224
3225The tracking issue for this feature is: [#80896]
3226
3227[#80896]: https://github.com/rust-lang/rust/issues/80896
3228
3229------------------------
3230
3231Rustdoc does not currently allow disambiguating between `*const` and `*mut`, and
3232raw pointers in intra-doc links are unstable until it does.
3233
3234```rust
3235#![feature(intra_doc_pointers)]
3236//! [pointer::add]
3237```
3238"##,
3239 },
3240 Lint {
3241 label: "intrinsics",
3242 description: r##"# `intrinsics`
3243
3244The tracking issue for this feature is: None.
3245
3246Intrinsics are never intended to be stable directly, but intrinsics are often
3247exported in some sort of stable manner. Prefer using the stable interfaces to
3248the intrinsic directly when you can.
3249
3250------------------------
3251
3252
3253These are imported as if they were FFI functions, with the special
3254`rust-intrinsic` ABI. For example, if one was in a freestanding
3255context, but wished to be able to `transmute` between types, and
3256perform efficient pointer arithmetic, one would import those functions
3257via a declaration like
3258
3259```rust
3260#![feature(intrinsics)]
3261# fn main() {}
3262
3263extern "rust-intrinsic" {
3264 fn transmute<T, U>(x: T) -> U;
3265
3266 fn offset<T>(dst: *const T, offset: isize) -> *const T;
3267}
3268```
3269
3270As with any other FFI functions, these are always `unsafe` to call.
3271"##,
3272 },
3273 Lint {
3274 label: "is_sorted",
3275 description: r##"# `is_sorted`
3276
3277The tracking issue for this feature is: [#53485]
3278
3279[#53485]: https://github.com/rust-lang/rust/issues/53485
3280
3281------------------------
3282
3283Add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to `[T]`;
3284add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to
3285`Iterator`.
3286"##,
3287 },
3288 Lint {
3289 label: "lang_items",
3290 description: r##"# `lang_items`
3291
3292The tracking issue for this feature is: None.
3293
3294------------------------
3295
3296The `rustc` compiler has certain pluggable operations, that is,
3297functionality that isn't hard-coded into the language, but is
3298implemented in libraries, with a special marker to tell the compiler
3299it exists. The marker is the attribute `#[lang = "..."]` and there are
3300various different values of `...`, i.e. various different 'lang
3301items'.
3302
3303For example, `Box` pointers require two lang items, one for allocation
3304and one for deallocation. A freestanding program that uses the `Box`
3305sugar for dynamic allocations via `malloc` and `free`:
3306
3307```rust,ignore (libc-is-finicky)
3308#![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)]
3309#![no_std]
3310use core::intrinsics;
3311use core::panic::PanicInfo;
3312
3313extern crate libc;
3314
3315#[lang = "owned_box"]
3316pub struct Box<T>(*mut T);
3317
3318#[lang = "exchange_malloc"]
3319unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
3320 let p = libc::malloc(size as libc::size_t) as *mut u8;
3321
3322 // Check if `malloc` failed:
3323 if p as usize == 0 {
3324 intrinsics::abort();
3325 }
3326
3327 p
3328}
3329
3330#[lang = "box_free"]
3331unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
3332 libc::free(ptr as *mut libc::c_void)
3333}
3334
3335#[start]
3336fn main(_argc: isize, _argv: *const *const u8) -> isize {
3337 let _x = box 1;
3338
3339 0
3340}
3341
3342#[lang = "eh_personality"] extern fn rust_eh_personality() {}
3343#[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
3344#[no_mangle] pub extern fn rust_eh_register_frames () {}
3345#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
3346```
3347
3348Note the use of `abort`: the `exchange_malloc` lang item is assumed to
3349return a valid pointer, and so needs to do the check internally.
3350
3351Other features provided by lang items include:
3352
3353- overloadable operators via traits: the traits corresponding to the
3354 `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all
3355 marked with lang items; those specific four are `eq`, `ord`,
3356 `deref`, and `add` respectively.
3357- stack unwinding and general failure; the `eh_personality`,
3358 `panic` and `panic_bounds_check` lang items.
3359- the traits in `std::marker` used to indicate types of
3360 various kinds; lang items `send`, `sync` and `copy`.
3361- the marker types and variance indicators found in
3362 `std::marker`; lang items `covariant_type`,
3363 `contravariant_lifetime`, etc.
3364
3365Lang items are loaded lazily by the compiler; e.g. if one never uses
3366`Box` then there is no need to define functions for `exchange_malloc`
3367and `box_free`. `rustc` will emit an error when an item is needed
3368but not found in the current crate or any that it depends on.
3369
3370Most lang items are defined by `libcore`, but if you're trying to build
3371an executable without the standard library, you'll run into the need
3372for lang items. The rest of this page focuses on this use-case, even though
3373lang items are a bit broader than that.
3374
3375### Using libc
3376
3377In order to build a `#[no_std]` executable we will need libc as a dependency.
3378We can specify this using our `Cargo.toml` file:
3379
3380```toml
3381[dependencies]
3382libc = { version = "0.2.14", default-features = false }
3383```
3384
3385Note that the default features have been disabled. This is a critical step -
3386**the default features of libc include the standard library and so must be
3387disabled.**
3388
3389### Writing an executable without stdlib
3390
3391Controlling the entry point is possible in two ways: the `#[start]` attribute,
3392or overriding the default shim for the C `main` function with your own.
3393
3394The function marked `#[start]` is passed the command line parameters
3395in the same format as C:
3396
3397```rust,ignore (libc-is-finicky)
3398#![feature(lang_items, core_intrinsics, rustc_private)]
3399#![feature(start)]
3400#![no_std]
3401use core::intrinsics;
3402use core::panic::PanicInfo;
3403
3404// Pull in the system libc library for what crt0.o likely requires.
3405extern crate libc;
3406
3407// Entry point for this program.
3408#[start]
3409fn start(_argc: isize, _argv: *const *const u8) -> isize {
3410 0
3411}
3412
3413// These functions are used by the compiler, but not
3414// for a bare-bones hello world. These are normally
3415// provided by libstd.
3416#[lang = "eh_personality"]
3417#[no_mangle]
3418pub extern fn rust_eh_personality() {
3419}
3420
3421#[lang = "panic_impl"]
3422#[no_mangle]
3423pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
3424 unsafe { intrinsics::abort() }
3425}
3426```
3427
3428To override the compiler-inserted `main` shim, one has to disable it
3429with `#![no_main]` and then create the appropriate symbol with the
3430correct ABI and the correct name, which requires overriding the
3431compiler's name mangling too:
3432
3433```rust,ignore (libc-is-finicky)
3434#![feature(lang_items, core_intrinsics, rustc_private)]
3435#![feature(start)]
3436#![no_std]
3437#![no_main]
3438use core::intrinsics;
3439use core::panic::PanicInfo;
3440
3441// Pull in the system libc library for what crt0.o likely requires.
3442extern crate libc;
3443
3444// Entry point for this program.
3445#[no_mangle] // ensure that this symbol is called `main` in the output
3446pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
3447 0
3448}
3449
3450// These functions are used by the compiler, but not
3451// for a bare-bones hello world. These are normally
3452// provided by libstd.
3453#[lang = "eh_personality"]
3454#[no_mangle]
3455pub extern fn rust_eh_personality() {
3456}
3457
3458#[lang = "panic_impl"]
3459#[no_mangle]
3460pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
3461 unsafe { intrinsics::abort() }
3462}
3463```
3464
3465In many cases, you may need to manually link to the `compiler_builtins` crate
3466when building a `no_std` binary. You may observe this via linker error messages
3467such as "```undefined reference to `__rust_probestack'```".
3468
3469## More about the language items
3470
3471The compiler currently makes a few assumptions about symbols which are
3472available in the executable to call. Normally these functions are provided by
3473the standard library, but without it you must define your own. These symbols
3474are called "language items", and they each have an internal name, and then a
3475signature that an implementation must conform to.
3476
3477The first of these functions, `rust_eh_personality`, is used by the failure
3478mechanisms of the compiler. This is often mapped to GCC's personality function
3479(see the [libstd implementation][unwind] for more information), but crates
3480which do not trigger a panic can be assured that this function is never
3481called. The language item's name is `eh_personality`.
3482
3483[unwind]: https://github.com/rust-lang/rust/blob/master/library/panic_unwind/src/gcc.rs
3484
3485The second function, `rust_begin_panic`, is also used by the failure mechanisms of the
3486compiler. When a panic happens, this controls the message that's displayed on
3487the screen. While the language item's name is `panic_impl`, the symbol name is
3488`rust_begin_panic`.
3489
3490Finally, a `eh_catch_typeinfo` static is needed for certain targets which
3491implement Rust panics on top of C++ exceptions.
3492
3493## List of all language items
3494
3495This is a list of all language items in Rust along with where they are located in
3496the source code.
3497
3498- Primitives
3499 - `i8`: `libcore/num/mod.rs`
3500 - `i16`: `libcore/num/mod.rs`
3501 - `i32`: `libcore/num/mod.rs`
3502 - `i64`: `libcore/num/mod.rs`
3503 - `i128`: `libcore/num/mod.rs`
3504 - `isize`: `libcore/num/mod.rs`
3505 - `u8`: `libcore/num/mod.rs`
3506 - `u16`: `libcore/num/mod.rs`
3507 - `u32`: `libcore/num/mod.rs`
3508 - `u64`: `libcore/num/mod.rs`
3509 - `u128`: `libcore/num/mod.rs`
3510 - `usize`: `libcore/num/mod.rs`
3511 - `f32`: `libstd/f32.rs`
3512 - `f64`: `libstd/f64.rs`
3513 - `char`: `libcore/char.rs`
3514 - `slice`: `liballoc/slice.rs`
3515 - `str`: `liballoc/str.rs`
3516 - `const_ptr`: `libcore/ptr.rs`
3517 - `mut_ptr`: `libcore/ptr.rs`
3518 - `unsafe_cell`: `libcore/cell.rs`
3519- Runtime
3520 - `start`: `libstd/rt.rs`
3521 - `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)
3522 - `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)
3523 - `eh_personality`: `libpanic_unwind/seh.rs` (SEH)
3524 - `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)
3525 - `panic`: `libcore/panicking.rs`
3526 - `panic_bounds_check`: `libcore/panicking.rs`
3527 - `panic_impl`: `libcore/panicking.rs`
3528 - `panic_impl`: `libstd/panicking.rs`
3529- Allocations
3530 - `owned_box`: `liballoc/boxed.rs`
3531 - `exchange_malloc`: `liballoc/heap.rs`
3532 - `box_free`: `liballoc/heap.rs`
3533- Operands
3534 - `not`: `libcore/ops/bit.rs`
3535 - `bitand`: `libcore/ops/bit.rs`
3536 - `bitor`: `libcore/ops/bit.rs`
3537 - `bitxor`: `libcore/ops/bit.rs`
3538 - `shl`: `libcore/ops/bit.rs`
3539 - `shr`: `libcore/ops/bit.rs`
3540 - `bitand_assign`: `libcore/ops/bit.rs`
3541 - `bitor_assign`: `libcore/ops/bit.rs`
3542 - `bitxor_assign`: `libcore/ops/bit.rs`
3543 - `shl_assign`: `libcore/ops/bit.rs`
3544 - `shr_assign`: `libcore/ops/bit.rs`
3545 - `deref`: `libcore/ops/deref.rs`
3546 - `deref_mut`: `libcore/ops/deref.rs`
3547 - `index`: `libcore/ops/index.rs`
3548 - `index_mut`: `libcore/ops/index.rs`
3549 - `add`: `libcore/ops/arith.rs`
3550 - `sub`: `libcore/ops/arith.rs`
3551 - `mul`: `libcore/ops/arith.rs`
3552 - `div`: `libcore/ops/arith.rs`
3553 - `rem`: `libcore/ops/arith.rs`
3554 - `neg`: `libcore/ops/arith.rs`
3555 - `add_assign`: `libcore/ops/arith.rs`
3556 - `sub_assign`: `libcore/ops/arith.rs`
3557 - `mul_assign`: `libcore/ops/arith.rs`
3558 - `div_assign`: `libcore/ops/arith.rs`
3559 - `rem_assign`: `libcore/ops/arith.rs`
3560 - `eq`: `libcore/cmp.rs`
3561 - `ord`: `libcore/cmp.rs`
3562- Functions
3563 - `fn`: `libcore/ops/function.rs`
3564 - `fn_mut`: `libcore/ops/function.rs`
3565 - `fn_once`: `libcore/ops/function.rs`
3566 - `generator_state`: `libcore/ops/generator.rs`
3567 - `generator`: `libcore/ops/generator.rs`
3568- Other
3569 - `coerce_unsized`: `libcore/ops/unsize.rs`
3570 - `drop`: `libcore/ops/drop.rs`
3571 - `drop_in_place`: `libcore/ptr.rs`
3572 - `clone`: `libcore/clone.rs`
3573 - `copy`: `libcore/marker.rs`
3574 - `send`: `libcore/marker.rs`
3575 - `sized`: `libcore/marker.rs`
3576 - `unsize`: `libcore/marker.rs`
3577 - `sync`: `libcore/marker.rs`
3578 - `phantom_data`: `libcore/marker.rs`
3579 - `discriminant_kind`: `libcore/marker.rs`
3580 - `freeze`: `libcore/marker.rs`
3581 - `debug_trait`: `libcore/fmt/mod.rs`
3582 - `non_zero`: `libcore/nonzero.rs`
3583 - `arc`: `liballoc/sync.rs`
3584 - `rc`: `liballoc/rc.rs`
3585"##,
3586 },
3587 Lint {
3588 label: "libstd_sys_internals",
3589 description: r##"# `libstd_sys_internals`
3788 3590
3789This feature is internal to the Rust compiler and is not intended for general use. 3591This feature is internal to the Rust compiler and is not intended for general use.
3790 3592
3791------------------------ 3593------------------------
3792"##, 3594"##,
3793 }, 3595 },
3794 LintCompletion { 3596 Lint {
3597 label: "libstd_thread_internals",
3598 description: r##"# `libstd_thread_internals`
3599
3600This feature is internal to the Rust compiler and is not intended for general use.
3601
3602------------------------
3603"##,
3604 },
3605 Lint {
3606 label: "link_cfg",
3607 description: r##"# `link_cfg`
3608
3609This feature is internal to the Rust compiler and is not intended for general use.
3610
3611------------------------
3612"##,
3613 },
3614 Lint {
3795 label: "llvm_asm", 3615 label: "llvm_asm",
3796 description: r##"# `llvm_asm` 3616 description: r##"# `llvm_asm`
3797 3617
@@ -3988,188 +3808,544 @@ If you need more power and don't mind losing some of the niceties of
3988`llvm_asm!`, check out [global_asm](global-asm.md). 3808`llvm_asm!`, check out [global_asm](global-asm.md).
3989"##, 3809"##,
3990 }, 3810 },
3991 LintCompletion { 3811 Lint {
3992 label: "core_intrinsics", 3812 label: "marker_trait_attr",
3993 description: r##"# `core_intrinsics` 3813 description: r##"# `marker_trait_attr`
3994 3814
3995This feature is internal to the Rust compiler and is not intended for general use. 3815The tracking issue for this feature is: [#29864]
3816
3817[#29864]: https://github.com/rust-lang/rust/issues/29864
3996 3818
3997------------------------ 3819------------------------
3820
3821Normally, Rust keeps you from adding trait implementations that could
3822overlap with each other, as it would be ambiguous which to use. This
3823feature, however, carves out an exception to that rule: a trait can
3824opt-in to having overlapping implementations, at the cost that those
3825implementations are not allowed to override anything (and thus the
3826trait itself cannot have any associated items, as they're pointless
3827when they'd need to do the same thing for every type anyway).
3828
3829```rust
3830#![feature(marker_trait_attr)]
3831
3832#[marker] trait CheapToClone: Clone {}
3833
3834impl<T: Copy> CheapToClone for T {}
3835
3836// These could potentially overlap with the blanket implementation above,
3837// so are only allowed because CheapToClone is a marker trait.
3838impl<T: CheapToClone, U: CheapToClone> CheapToClone for (T, U) {}
3839impl<T: CheapToClone> CheapToClone for std::ops::Range<T> {}
3840
3841fn cheap_clone<T: CheapToClone>(t: T) -> T {
3842 t.clone()
3843}
3844```
3845
3846This is expected to replace the unstable `overlapping_marker_traits`
3847feature, which applied to all empty traits (without needing an opt-in).
3998"##, 3848"##,
3999 }, 3849 },
4000 LintCompletion { 3850 Lint {
4001 label: "trace_macros", 3851 label: "native_link_modifiers",
4002 description: r##"# `trace_macros` 3852 description: r##"# `native_link_modifiers`
4003 3853
4004The tracking issue for this feature is [#29598]. 3854The tracking issue for this feature is: [#81490]
4005 3855
4006[#29598]: https://github.com/rust-lang/rust/issues/29598 3856[#81490]: https://github.com/rust-lang/rust/issues/81490
4007 3857
4008------------------------ 3858------------------------
4009 3859
4010With `trace_macros` you can trace the expansion of macros in your code. 3860The `native_link_modifiers` feature allows you to use the `modifiers` syntax with the `#[link(..)]` attribute.
4011 3861
4012## Examples 3862Modifiers 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.
3863"##,
3864 },
3865 Lint {
3866 label: "native_link_modifiers_as_needed",
3867 description: r##"# `native_link_modifiers_as_needed`
4013 3868
4014```rust 3869The tracking issue for this feature is: [#81490]
4015#![feature(trace_macros)]
4016 3870
4017fn main() { 3871[#81490]: https://github.com/rust-lang/rust/issues/81490
4018 trace_macros!(true);
4019 println!("Hello, Rust!");
4020 trace_macros!(false);
4021}
4022```
4023 3872
4024The `cargo build` output: 3873------------------------
4025 3874
4026```txt 3875The `native_link_modifiers_as_needed` feature allows you to use the `as-needed` modifier.
4027note: trace_macro
4028 --> src/main.rs:5:5
4029 |
40305 | println!("Hello, Rust!");
4031 | ^^^^^^^^^^^^^^^^^^^^^^^^^
4032 |
4033 = note: expanding `println! { "Hello, Rust!" }`
4034 = note: to `print ! ( concat ! ( "Hello, Rust!" , "\n" ) )`
4035 = note: expanding `print! { concat ! ( "Hello, Rust!" , "\n" ) }`
4036 = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, Rust!" , "\n" ) )
4037 )`
4038 3876
4039 Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs 3877`as-needed` is only compatible with the `dynamic` and `framework` linking kinds. Using any other kind will result in a compiler error.
4040``` 3878
3879`+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.
3880
3881This modifier translates to `--as-needed` for ld-like linkers, and to `-dead_strip_dylibs` / `-needed_library` / `-needed_framework` for ld64.
3882The modifier does nothing for linkers that don't support it (e.g. `link.exe`).
3883
3884The 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.
4041"##, 3885"##,
4042 }, 3886 },
4043 LintCompletion { 3887 Lint {
4044 label: "update_panic_count", 3888 label: "native_link_modifiers_bundle",
4045 description: r##"# `update_panic_count` 3889 description: r##"# `native_link_modifiers_bundle`
4046 3890
4047This feature is internal to the Rust compiler and is not intended for general use. 3891The tracking issue for this feature is: [#81490]
3892
3893[#81490]: https://github.com/rust-lang/rust/issues/81490
4048 3894
4049------------------------ 3895------------------------
3896
3897The `native_link_modifiers_bundle` feature allows you to use the `bundle` modifier.
3898
3899Only compatible with the `static` linking kind. Using any other kind will result in a compiler error.
3900
3901`+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.
3902
3903`-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.
3904
3905This modifier is supposed to supersede the `static-nobundle` linking kind defined by [RFC 1717](https://github.com/rust-lang/rfcs/pull/1717).
3906
3907The default for this modifier is currently `+bundle`, but it could be changed later on some future edition boundary.
4050"##, 3908"##,
4051 }, 3909 },
4052 LintCompletion { 3910 Lint {
4053 label: "core_private_bignum", 3911 label: "native_link_modifiers_verbatim",
4054 description: r##"# `core_private_bignum` 3912 description: r##"# `native_link_modifiers_verbatim`
4055 3913
4056This feature is internal to the Rust compiler and is not intended for general use. 3914The tracking issue for this feature is: [#81490]
3915
3916[#81490]: https://github.com/rust-lang/rust/issues/81490
4057 3917
4058------------------------ 3918------------------------
3919
3920The `native_link_modifiers_verbatim` feature allows you to use the `verbatim` modifier.
3921
3922`+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.
3923
3924For `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.
3925See [`-l namespec`](https://sourceware.org/binutils/docs/ld/Options.html) in ld documentation for more details.
3926For linkers not supporting any verbatim modifiers (e.g. `link.exe` or `ld64`) the library name will be passed as is.
3927
3928The default for this modifier is `-verbatim`.
3929
3930This 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.
3931If your DLL doesn't have the `.dll` suffix, it can be specified with `+verbatim`.
4059"##, 3932"##,
4060 }, 3933 },
4061 LintCompletion { 3934 Lint {
4062 label: "sort_internals", 3935 label: "native_link_modifiers_whole_archive",
4063 description: r##"# `sort_internals` 3936 description: r##"# `native_link_modifiers_whole_archive`
4064 3937
4065This feature is internal to the Rust compiler and is not intended for general use. 3938The tracking issue for this feature is: [#81490]
3939
3940[#81490]: https://github.com/rust-lang/rust/issues/81490
4066 3941
4067------------------------ 3942------------------------
3943
3944The `native_link_modifiers_whole_archive` feature allows you to use the `whole-archive` modifier.
3945
3946Only compatible with the `static` linking kind. Using any other kind will result in a compiler error.
3947
3948`+whole-archive` means that the static library is linked as a whole archive without throwing any object files away.
3949
3950This modifier translates to `--whole-archive` for `ld`-like linkers, to `/WHOLEARCHIVE` for `link.exe`, and to `-force_load` for `ld64`.
3951The modifier does nothing for linkers that don't support it.
3952
3953The default for this modifier is `-whole-archive`.
4068"##, 3954"##,
4069 }, 3955 },
4070 LintCompletion { 3956 Lint {
4071 label: "windows_net", 3957 label: "negative_impls",
4072 description: r##"# `windows_net` 3958 description: r##"# `negative_impls`
4073 3959
4074This feature is internal to the Rust compiler and is not intended for general use. 3960The tracking issue for this feature is [#68318].
4075 3961
4076------------------------ 3962[#68318]: https://github.com/rust-lang/rust/issues/68318
3963
3964----
3965
3966With the feature gate `negative_impls`, you can write negative impls as well as positive ones:
3967
3968```rust
3969#![feature(negative_impls)]
3970trait DerefMut { }
3971impl<T: ?Sized> !DerefMut for &T { }
3972```
3973
3974Negative 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.
3975
3976Negative impls have the following characteristics:
3977
3978* They do not have any items.
3979* They must obey the orphan rules as if they were a positive impl.
3980* They cannot "overlap" with any positive impls.
3981
3982## Semver interaction
3983
3984It is a breaking change to remove a negative impl. Negative impls are a commitment not to implement the given trait for the named types.
3985
3986## Orphan and overlap rules
3987
3988Negative 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.
3989
3990Similarly, 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.)
3991
3992## Interaction with auto traits
3993
3994Declaring a negative impl `impl !SomeAutoTrait for SomeType` for an
3995auto-trait serves two purposes:
3996
3997* as with any trait, it declares that `SomeType` will never implement `SomeAutoTrait`;
3998* it disables the automatic `SomeType: SomeAutoTrait` impl that would otherwise have been generated.
3999
4000Note that, at present, there is no way to indicate that a given type
4001does not implement an auto trait *but that it may do so in the
4002future*. For ordinary types, this is done by simply not declaring any
4003impl at all, but that is not an option for auto traits. A workaround
4004is that one could embed a marker type as one of the fields, where the
4005marker type is `!AutoTrait`.
4006
4007## Immediate uses
4008
4009Negative 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).
4010
4011This serves two purposes:
4012
4013* For proving the correctness of unsafe code, we can use that impl as evidence that no `DerefMut` or `Clone` impl exists.
4014* It prevents downstream crates from creating such impls.
4077"##, 4015"##,
4078 }, 4016 },
4079 LintCompletion { 4017 Lint {
4080 label: "c_variadic", 4018 label: "no_coverage",
4081 description: r##"# `c_variadic` 4019 description: r##"# `no_coverage`
4082 4020
4083The tracking issue for this feature is: [#44930] 4021The tracking issue for this feature is: [#84605]
4084 4022
4085[#44930]: https://github.com/rust-lang/rust/issues/44930 4023[#84605]: https://github.com/rust-lang/rust/issues/84605
4024
4025---
4026
4027The `no_coverage` attribute can be used to selectively disable coverage
4028instrumentation in an annotated function. This might be useful to:
4029
4030- Avoid instrumentation overhead in a performance critical function
4031- Avoid generating coverage for a function that is not meant to be executed,
4032 but still target 100% coverage for the rest of the program.
4033
4034## Example
4035
4036```rust
4037#![feature(no_coverage)]
4038
4039// `foo()` will get coverage instrumentation (by default)
4040fn foo() {
4041 // ...
4042}
4043
4044#[no_coverage]
4045fn bar() {
4046 // ...
4047}
4048```
4049"##,
4050 },
4051 Lint {
4052 label: "no_sanitize",
4053 description: r##"# `no_sanitize`
4054
4055The tracking issue for this feature is: [#39699]
4056
4057[#39699]: https://github.com/rust-lang/rust/issues/39699
4086 4058
4087------------------------ 4059------------------------
4088 4060
4089The `c_variadic` library feature exposes the `VaList` structure, 4061The `no_sanitize` attribute can be used to selectively disable sanitizer
4090Rust's analogue of C's `va_list` type. 4062instrumentation in an annotated function. This might be useful to: avoid
4063instrumentation overhead in a performance critical function, or avoid
4064instrumenting code that contains constructs unsupported by given sanitizer.
4065
4066The precise effect of this annotation depends on particular sanitizer in use.
4067For example, with `no_sanitize(thread)`, the thread sanitizer will no longer
4068instrument non-atomic store / load operations, but it will instrument atomic
4069operations to avoid reporting false positives and provide meaning full stack
4070traces.
4091 4071
4092## Examples 4072## Examples
4093 4073
4094```rust 4074``` rust
4095#![feature(c_variadic)] 4075#![feature(no_sanitize)]
4096 4076
4097use std::ffi::VaList; 4077#[no_sanitize(address)]
4078fn foo() {
4079 // ...
4080}
4081```
4082"##,
4083 },
4084 Lint {
4085 label: "plugin",
4086 description: r##"# `plugin`
4098 4087
4099pub unsafe extern "C" fn vadd(n: usize, mut args: VaList) -> usize { 4088The tracking issue for this feature is: [#29597]
4100 let mut sum = 0; 4089
4101 for _ in 0..n { 4090[#29597]: https://github.com/rust-lang/rust/issues/29597
4102 sum += args.arg::<usize>(); 4091
4092
4093This feature is part of "compiler plugins." It will often be used with the
4094[`plugin_registrar`] and `rustc_private` features.
4095
4096[`plugin_registrar`]: plugin-registrar.md
4097
4098------------------------
4099
4100`rustc` can load compiler plugins, which are user-provided libraries that
4101extend the compiler's behavior with new lint checks, etc.
4102
4103A plugin is a dynamic library crate with a designated *registrar* function that
4104registers extensions with `rustc`. Other crates can load these extensions using
4105the crate attribute `#![plugin(...)]`. See the
4106`rustc_driver::plugin` documentation for more about the
4107mechanics of defining and loading a plugin.
4108
4109In the vast majority of cases, a plugin should *only* be used through
4110`#![plugin]` and not through an `extern crate` item. Linking a plugin would
4111pull in all of librustc_ast and librustc as dependencies of your crate. This is
4112generally unwanted unless you are building another plugin.
4113
4114The usual practice is to put compiler plugins in their own crate, separate from
4115any `macro_rules!` macros or ordinary Rust code meant to be used by consumers
4116of a library.
4117
4118# Lint plugins
4119
4120Plugins can extend [Rust's lint
4121infrastructure](../../reference/attributes/diagnostics.md#lint-check-attributes) with
4122additional checks for code style, safety, etc. Now let's write a plugin
4123[`lint-plugin-test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs)
4124that warns about any item named `lintme`.
4125
4126```rust,ignore (requires-stage-2)
4127#![feature(plugin_registrar)]
4128#![feature(box_syntax, rustc_private)]
4129
4130extern crate rustc_ast;
4131
4132// Load rustc as a plugin to get macros
4133extern crate rustc_driver;
4134#[macro_use]
4135extern crate rustc_lint;
4136#[macro_use]
4137extern crate rustc_session;
4138
4139use rustc_driver::plugin::Registry;
4140use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
4141use rustc_ast::ast;
4142declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
4143
4144declare_lint_pass!(Pass => [TEST_LINT]);
4145
4146impl EarlyLintPass for Pass {
4147 fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
4148 if it.ident.name.as_str() == "lintme" {
4149 cx.lint(TEST_LINT, |lint| {
4150 lint.build("item is named 'lintme'").set_span(it.span).emit()
4151 });
4152 }
4103 } 4153 }
4104 sum
4105} 4154}
4155
4156#[plugin_registrar]
4157pub fn plugin_registrar(reg: &mut Registry) {
4158 reg.lint_store.register_lints(&[&TEST_LINT]);
4159 reg.lint_store.register_early_pass(|| box Pass);
4160}
4161```
4162
4163Then code like
4164
4165```rust,ignore (requires-plugin)
4166#![feature(plugin)]
4167#![plugin(lint_plugin_test)]
4168
4169fn lintme() { }
4170```
4171
4172will produce a compiler warning:
4173
4174```txt
4175foo.rs:4:1: 4:16 warning: item is named 'lintme', #[warn(test_lint)] on by default
4176foo.rs:4 fn lintme() { }
4177 ^~~~~~~~~~~~~~~
4106``` 4178```
4179
4180The components of a lint plugin are:
4181
4182* one or more `declare_lint!` invocations, which define static `Lint` structs;
4183
4184* a struct holding any state needed by the lint pass (here, none);
4185
4186* a `LintPass`
4187 implementation defining how to check each syntax element. A single
4188 `LintPass` may call `span_lint` for several different `Lint`s, but should
4189 register them all through the `get_lints` method.
4190
4191Lint passes are syntax traversals, but they run at a late stage of compilation
4192where type information is available. `rustc`'s [built-in
4193lints](https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs)
4194mostly use the same infrastructure as lint plugins, and provide examples of how
4195to access type information.
4196
4197Lints defined by plugins are controlled by the usual [attributes and compiler
4198flags](../../reference/attributes/diagnostics.md#lint-check-attributes), e.g.
4199`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the
4200first argument to `declare_lint!`, with appropriate case and punctuation
4201conversion.
4202
4203You can run `rustc -W help foo.rs` to see a list of lints known to `rustc`,
4204including those provided by plugins loaded by `foo.rs`.
4107"##, 4205"##,
4108 }, 4206 },
4109 LintCompletion { 4207 Lint {
4110 label: "core_private_diy_float", 4208 label: "plugin_registrar",
4111 description: r##"# `core_private_diy_float` 4209 description: r##"# `plugin_registrar`
4112 4210
4113This feature is internal to the Rust compiler and is not intended for general use. 4211The tracking issue for this feature is: [#29597]
4212
4213[#29597]: https://github.com/rust-lang/rust/issues/29597
4214
4215This feature is part of "compiler plugins." It will often be used with the
4216[`plugin`] and `rustc_private` features as well. For more details, see
4217their docs.
4218
4219[`plugin`]: plugin.md
4114 4220
4115------------------------ 4221------------------------
4116"##, 4222"##,
4117 }, 4223 },
4118 LintCompletion { 4224 Lint {
4119 label: "profiler_runtime_lib", 4225 label: "print_internals",
4120 description: r##"# `profiler_runtime_lib` 4226 description: r##"# `print_internals`
4121 4227
4122This feature is internal to the Rust compiler and is not intended for general use. 4228This feature is internal to the Rust compiler and is not intended for general use.
4123 4229
4124------------------------ 4230------------------------
4125"##, 4231"##,
4126 }, 4232 },
4127 LintCompletion { 4233 Lint {
4128 label: "thread_local_internals", 4234 label: "profiler_runtime",
4129 description: r##"# `thread_local_internals` 4235 description: r##"# `profiler_runtime`
4130 4236
4131This feature is internal to the Rust compiler and is not intended for general use. 4237The tracking issue for this feature is: [#42524](https://github.com/rust-lang/rust/issues/42524).
4132 4238
4133------------------------ 4239------------------------
4134"##, 4240"##,
4135 }, 4241 },
4136 LintCompletion { 4242 Lint {
4137 label: "int_error_internals", 4243 label: "profiler_runtime_lib",
4138 description: r##"# `int_error_internals` 4244 description: r##"# `profiler_runtime_lib`
4139 4245
4140This feature is internal to the Rust compiler and is not intended for general use. 4246This feature is internal to the Rust compiler and is not intended for general use.
4141 4247
4142------------------------ 4248------------------------
4143"##, 4249"##,
4144 }, 4250 },
4145 LintCompletion { 4251 Lint {
4146 label: "windows_stdio", 4252 label: "repr128",
4147 description: r##"# `windows_stdio` 4253 description: r##"# `repr128`
4148 4254
4149This feature is internal to the Rust compiler and is not intended for general use. 4255The tracking issue for this feature is: [#56071]
4256
4257[#56071]: https://github.com/rust-lang/rust/issues/56071
4150 4258
4151------------------------ 4259------------------------
4260
4261The `repr128` feature adds support for `#[repr(u128)]` on `enum`s.
4262
4263```rust
4264#![feature(repr128)]
4265
4266#[repr(u128)]
4267enum Foo {
4268 Bar(u64),
4269}
4270```
4152"##, 4271"##,
4153 }, 4272 },
4154 LintCompletion { 4273 Lint {
4155 label: "fmt_internals", 4274 label: "rt",
4156 description: r##"# `fmt_internals` 4275 description: r##"# `rt`
4157 4276
4158This feature is internal to the Rust compiler and is not intended for general use. 4277This feature is internal to the Rust compiler and is not intended for general use.
4159 4278
4160------------------------ 4279------------------------
4161"##, 4280"##,
4162 }, 4281 },
4163 LintCompletion { 4282 Lint {
4164 label: "fd_read", 4283 label: "rustc_attrs",
4165 description: r##"# `fd_read` 4284 description: r##"# `rustc_attrs`
4285
4286This feature has no tracking issue, and is therefore internal to
4287the compiler, not being intended for general use.
4288
4289Note: `rustc_attrs` enables many rustc-internal attributes and this page
4290only discuss a few of them.
4291
4292------------------------
4293
4294The `rustc_attrs` feature allows debugging rustc type layouts by using
4295`#[rustc_layout(...)]` to debug layout at compile time (it even works
4296with `cargo check`) as an alternative to `rustc -Z print-type-sizes`
4297that is way more verbose.
4298
4299Options provided by `#[rustc_layout(...)]` are `debug`, `size`, `align`,
4300`abi`. Note that it only works on sized types without generics.
4301
4302## Examples
4303
4304```rust,compile_fail
4305#![feature(rustc_attrs)]
4306
4307#[rustc_layout(abi, size)]
4308pub enum X {
4309 Y(u8, u8, u8),
4310 Z(isize),
4311}
4312```
4313
4314When that is compiled, the compiler will error with something like
4315
4316```text
4317error: abi: Aggregate { sized: true }
4318 --> src/lib.rs:4:1
4319 |
43204 | / pub enum T {
43215 | | Y(u8, u8, u8),
43226 | | Z(isize),
43237 | | }
4324 | |_^
4325
4326error: size: Size { raw: 16 }
4327 --> src/lib.rs:4:1
4328 |
43294 | / pub enum T {
43305 | | Y(u8, u8, u8),
43316 | | Z(isize),
43327 | | }
4333 | |_^
4334
4335error: aborting due to 2 previous errors
4336```
4337"##,
4338 },
4339 Lint {
4340 label: "sort_internals",
4341 description: r##"# `sort_internals`
4166 4342
4167This feature is internal to the Rust compiler and is not intended for general use. 4343This feature is internal to the Rust compiler and is not intended for general use.
4168 4344
4169------------------------ 4345------------------------
4170"##, 4346"##,
4171 }, 4347 },
4172 LintCompletion { 4348 Lint {
4173 label: "str_internals", 4349 label: "str_internals",
4174 description: r##"# `str_internals` 4350 description: r##"# `str_internals`
4175 4351
@@ -4178,7 +4354,7 @@ This feature is internal to the Rust compiler and is not intended for general us
4178------------------------ 4354------------------------
4179"##, 4355"##,
4180 }, 4356 },
4181 LintCompletion { 4357 Lint {
4182 label: "test", 4358 label: "test",
4183 description: r##"# `test` 4359 description: r##"# `test`
4184 4360
@@ -4340,101 +4516,218 @@ However, the optimizer can still modify a testcase in an undesirable manner
4340even when using either of the above. 4516even when using either of the above.
4341"##, 4517"##,
4342 }, 4518 },
4343 LintCompletion { 4519 Lint {
4344 label: "windows_c", 4520 label: "thread_local_internals",
4345 description: r##"# `windows_c` 4521 description: r##"# `thread_local_internals`
4346 4522
4347This feature is internal to the Rust compiler and is not intended for general use. 4523This feature is internal to the Rust compiler and is not intended for general use.
4348 4524
4349------------------------ 4525------------------------
4350"##, 4526"##,
4351 }, 4527 },
4352 LintCompletion { 4528 Lint {
4353 label: "dec2flt", 4529 label: "trace_macros",
4354 description: r##"# `dec2flt` 4530 description: r##"# `trace_macros`
4355 4531
4356This feature is internal to the Rust compiler and is not intended for general use. 4532The tracking issue for this feature is [#29598].
4533
4534[#29598]: https://github.com/rust-lang/rust/issues/29598
4357 4535
4358------------------------ 4536------------------------
4359"##,
4360 },
4361 LintCompletion {
4362 label: "derive_clone_copy",
4363 description: r##"# `derive_clone_copy`
4364 4537
4365This feature is internal to the Rust compiler and is not intended for general use. 4538With `trace_macros` you can trace the expansion of macros in your code.
4366 4539
4367------------------------ 4540## Examples
4368"##,
4369 },
4370 LintCompletion {
4371 label: "allocator_api",
4372 description: r##"# `allocator_api`
4373 4541
4374The tracking issue for this feature is [#32838] 4542```rust
4543#![feature(trace_macros)]
4375 4544
4376[#32838]: https://github.com/rust-lang/rust/issues/32838 4545fn main() {
4546 trace_macros!(true);
4547 println!("Hello, Rust!");
4548 trace_macros!(false);
4549}
4550```
4377 4551
4378------------------------ 4552The `cargo build` output:
4379 4553
4380Sometimes you want the memory for one collection to use a different 4554```txt
4381allocator than the memory for another collection. In this case, 4555note: trace_macro
4382replacing the global allocator is not a workable option. Instead, 4556 --> src/main.rs:5:5
4383you need to pass in an instance of an `AllocRef` to each collection 4557 |
4384for which you want a custom allocator. 45585 | println!("Hello, Rust!");
4559 | ^^^^^^^^^^^^^^^^^^^^^^^^^
4560 |
4561 = note: expanding `println! { "Hello, Rust!" }`
4562 = note: to `print ! ( concat ! ( "Hello, Rust!" , "\n" ) )`
4563 = note: expanding `print! { concat ! ( "Hello, Rust!" , "\n" ) }`
4564 = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, Rust!" , "\n" ) )
4565 )`
4385 4566
4386TBD 4567 Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs
4568```
4387"##, 4569"##,
4388 }, 4570 },
4389 LintCompletion { 4571 Lint {
4390 label: "core_panic", 4572 label: "trait_alias",
4391 description: r##"# `core_panic` 4573 description: r##"# `trait_alias`
4392 4574
4393This feature is internal to the Rust compiler and is not intended for general use. 4575The tracking issue for this feature is: [#41517]
4576
4577[#41517]: https://github.com/rust-lang/rust/issues/41517
4394 4578
4395------------------------ 4579------------------------
4580
4581The `trait_alias` feature adds support for trait aliases. These allow aliases
4582to be created for one or more traits (currently just a single regular trait plus
4583any number of auto-traits), and used wherever traits would normally be used as
4584either bounds or trait objects.
4585
4586```rust
4587#![feature(trait_alias)]
4588
4589trait Foo = std::fmt::Debug + Send;
4590trait Bar = Foo + Sync;
4591
4592// Use trait alias as bound on type parameter.
4593fn foo<T: Foo>(v: &T) {
4594 println!("{:?}", v);
4595}
4596
4597pub fn main() {
4598 foo(&1);
4599
4600 // Use trait alias for trait objects.
4601 let a: &Bar = &123;
4602 println!("{:?}", a);
4603 let b = Box::new(456) as Box<dyn Foo>;
4604 println!("{:?}", b);
4605}
4606```
4396"##, 4607"##,
4397 }, 4608 },
4398 LintCompletion { 4609 Lint {
4399 label: "fn_traits", 4610 label: "transparent_unions",
4400 description: r##"# `fn_traits` 4611 description: r##"# `transparent_unions`
4401
4402The tracking issue for this feature is [#29625]
4403 4612
4404See Also: [`unboxed_closures`](../language-features/unboxed-closures.md) 4613The tracking issue for this feature is [#60405]
4405 4614
4406[#29625]: https://github.com/rust-lang/rust/issues/29625 4615[#60405]: https://github.com/rust-lang/rust/issues/60405
4407 4616
4408---- 4617----
4409 4618
4410The `fn_traits` feature allows for implementation of the [`Fn*`] traits 4619The `transparent_unions` feature allows you mark `union`s as
4411for creating custom closure-like types. 4620`#[repr(transparent)]`. A `union` may be `#[repr(transparent)]` in exactly the
4412 4621same conditions in which a `struct` may be `#[repr(transparent)]` (generally,
4413[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html 4622this means the `union` must have exactly one non-zero-sized field). Some
4623concrete illustrations follow.
4414 4624
4415```rust 4625```rust
4416#![feature(unboxed_closures)] 4626#![feature(transparent_unions)]
4417#![feature(fn_traits)]
4418 4627
4419struct Adder { 4628// This union has the same representation as `f32`.
4420 a: u32 4629#[repr(transparent)]
4630union SingleFieldUnion {
4631 field: f32,
4421} 4632}
4422 4633
4423impl FnOnce<(u32, )> for Adder { 4634// This union has the same representation as `usize`.
4424 type Output = u32; 4635#[repr(transparent)]
4425 extern "rust-call" fn call_once(self, b: (u32, )) -> Self::Output { 4636union MultiFieldUnion {
4426 self.a + b.0 4637 field: usize,
4427 } 4638 nothing: (),
4428} 4639}
4640```
4429 4641
4430fn main() { 4642For consistency with transparent `struct`s, `union`s must have exactly one
4431 let adder = Adder { a: 3 }; 4643non-zero-sized field. If all fields are zero-sized, the `union` must not be
4432 assert_eq!(adder(2), 5); 4644`#[repr(transparent)]`:
4645
4646```rust
4647#![feature(transparent_unions)]
4648
4649// This (non-transparent) union is already valid in stable Rust:
4650pub union GoodUnion {
4651 pub nothing: (),
4652}
4653
4654// Error: transparent union needs exactly one non-zero-sized field, but has 0
4655// #[repr(transparent)]
4656// pub union BadUnion {
4657// pub nothing: (),
4658// }
4659```
4660
4661The one exception is if the `union` is generic over `T` and has a field of type
4662`T`, it may be `#[repr(transparent)]` even if `T` is a zero-sized type:
4663
4664```rust
4665#![feature(transparent_unions)]
4666
4667// This union has the same representation as `T`.
4668#[repr(transparent)]
4669pub union GenericUnion<T: Copy> { // Unions with non-`Copy` fields are unstable.
4670 pub field: T,
4671 pub nothing: (),
4433} 4672}
4673
4674// This is okay even though `()` is a zero-sized type.
4675pub const THIS_IS_OKAY: GenericUnion<()> = GenericUnion { field: () };
4434``` 4676```
4677
4678Like transarent `struct`s, a transparent `union` of type `U` has the same
4679layout, size, and ABI as its single non-ZST field. If it is generic over a type
4680`T`, and all its fields are ZSTs except for exactly one field of type `T`, then
4681it has the same layout and ABI as `T` (even if `T` is a ZST when monomorphized).
4682
4683Like transparent `struct`s, transparent `union`s are FFI-safe if and only if
4684their underlying representation type is also FFI-safe.
4685
4686A `union` may not be eligible for the same nonnull-style optimizations that a
4687`struct` or `enum` (with the same fields) are eligible for. Adding
4688`#[repr(transparent)]` to `union` does not change this. To give a more concrete
4689example, it is unspecified whether `size_of::<T>()` is equal to
4690`size_of::<Option<T>>()`, where `T` is a `union` (regardless of whether or not
4691it is transparent). The Rust compiler is free to perform this optimization if
4692possible, but is not required to, and different compiler versions may differ in
4693their application of these optimizations.
4435"##, 4694"##,
4436 }, 4695 },
4437 LintCompletion { 4696 Lint {
4697 label: "try_blocks",
4698 description: r##"# `try_blocks`
4699
4700The tracking issue for this feature is: [#31436]
4701
4702[#31436]: https://github.com/rust-lang/rust/issues/31436
4703
4704------------------------
4705
4706The `try_blocks` feature adds support for `try` blocks. A `try`
4707block creates a new scope one can use the `?` operator in.
4708
4709```rust,edition2018
4710#![feature(try_blocks)]
4711
4712use std::num::ParseIntError;
4713
4714let result: Result<i32, ParseIntError> = try {
4715 "1".parse::<i32>()?
4716 + "2".parse::<i32>()?
4717 + "3".parse::<i32>()?
4718};
4719assert_eq!(result, Ok(6));
4720
4721let result: Result<i32, ParseIntError> = try {
4722 "1".parse::<i32>()?
4723 + "foo".parse::<i32>()?
4724 + "3".parse::<i32>()?
4725};
4726assert!(result.is_err());
4727```
4728"##,
4729 },
4730 Lint {
4438 label: "try_trait", 4731 label: "try_trait",
4439 description: r##"# `try_trait` 4732 description: r##"# `try_trait`
4440 4733
@@ -4488,27 +4781,284 @@ function (or catch block). Having a distinct error type (as opposed to
4488just `()`, or similar) restricts this to where it's semantically meaningful. 4781just `()`, or similar) restricts this to where it's semantically meaningful.
4489"##, 4782"##,
4490 }, 4783 },
4491 LintCompletion { 4784 Lint {
4492 label: "rt", 4785 label: "unboxed_closures",
4493 description: r##"# `rt` 4786 description: r##"# `unboxed_closures`
4787
4788The tracking issue for this feature is [#29625]
4789
4790See Also: [`fn_traits`](../library-features/fn-traits.md)
4791
4792[#29625]: https://github.com/rust-lang/rust/issues/29625
4793
4794----
4795
4796The `unboxed_closures` feature allows you to write functions using the `"rust-call"` ABI,
4797required for implementing the [`Fn*`] family of traits. `"rust-call"` functions must have
4798exactly one (non self) argument, a tuple representing the argument list.
4799
4800[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html
4801
4802```rust
4803#![feature(unboxed_closures)]
4804
4805extern "rust-call" fn add_args(args: (u32, u32)) -> u32 {
4806 args.0 + args.1
4807}
4808
4809fn main() {}
4810```
4811"##,
4812 },
4813 Lint {
4814 label: "unsized_locals",
4815 description: r##"# `unsized_locals`
4816
4817The tracking issue for this feature is: [#48055]
4818
4819[#48055]: https://github.com/rust-lang/rust/issues/48055
4820
4821------------------------
4822
4823This implements [RFC1909]. When turned on, you can have unsized arguments and locals:
4824
4825[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md
4826
4827```rust
4828#![allow(incomplete_features)]
4829#![feature(unsized_locals, unsized_fn_params)]
4830
4831use std::any::Any;
4832
4833fn main() {
4834 let x: Box<dyn Any> = Box::new(42);
4835 let x: dyn Any = *x;
4836 // ^ unsized local variable
4837 // ^^ unsized temporary
4838 foo(x);
4839}
4840
4841fn foo(_: dyn Any) {}
4842// ^^^^^^ unsized argument
4843```
4844
4845The RFC still forbids the following unsized expressions:
4846
4847```rust,compile_fail
4848#![feature(unsized_locals)]
4849
4850use std::any::Any;
4851
4852struct MyStruct<T: ?Sized> {
4853 content: T,
4854}
4855
4856struct MyTupleStruct<T: ?Sized>(T);
4857
4858fn answer() -> Box<dyn Any> {
4859 Box::new(42)
4860}
4861
4862fn main() {
4863 // You CANNOT have unsized statics.
4864 static X: dyn Any = *answer(); // ERROR
4865 const Y: dyn Any = *answer(); // ERROR
4866
4867 // You CANNOT have struct initialized unsized.
4868 MyStruct { content: *answer() }; // ERROR
4869 MyTupleStruct(*answer()); // ERROR
4870 (42, *answer()); // ERROR
4871
4872 // You CANNOT have unsized return types.
4873 fn my_function() -> dyn Any { *answer() } // ERROR
4874
4875 // You CAN have unsized local variables...
4876 let mut x: dyn Any = *answer(); // OK
4877 // ...but you CANNOT reassign to them.
4878 x = *answer(); // ERROR
4879
4880 // You CANNOT even initialize them separately.
4881 let y: dyn Any; // OK
4882 y = *answer(); // ERROR
4883
4884 // Not mentioned in the RFC, but by-move captured variables are also Sized.
4885 let x: dyn Any = *answer();
4886 (move || { // ERROR
4887 let y = x;
4888 })();
4889
4890 // You CAN create a closure with unsized arguments,
4891 // but you CANNOT call it.
4892 // This is an implementation detail and may be changed in the future.
4893 let f = |x: dyn Any| {};
4894 f(*answer()); // ERROR
4895}
4896```
4897
4898## By-value trait objects
4899
4900With this feature, you can have by-value `self` arguments without `Self: Sized` bounds.
4901
4902```rust
4903#![feature(unsized_fn_params)]
4904
4905trait Foo {
4906 fn foo(self) {}
4907}
4908
4909impl<T: ?Sized> Foo for T {}
4910
4911fn main() {
4912 let slice: Box<[i32]> = Box::new([1, 2, 3]);
4913 <[i32] as Foo>::foo(*slice);
4914}
4915```
4916
4917And `Foo` will also be object-safe.
4918
4919```rust
4920#![feature(unsized_fn_params)]
4921
4922trait Foo {
4923 fn foo(self) {}
4924}
4925
4926impl<T: ?Sized> Foo for T {}
4927
4928fn main () {
4929 let slice: Box<dyn Foo> = Box::new([1, 2, 3]);
4930 // doesn't compile yet
4931 <dyn Foo as Foo>::foo(*slice);
4932}
4933```
4934
4935One of the objectives of this feature is to allow `Box<dyn FnOnce>`.
4936
4937## Variable length arrays
4938
4939The 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]`.
4940
4941```rust,ignore (not-yet-implemented)
4942#![feature(unsized_locals)]
4943
4944fn mergesort<T: Ord>(a: &mut [T]) {
4945 let mut tmp = [T; dyn a.len()];
4946 // ...
4947}
4948
4949fn main() {
4950 let mut a = [3, 1, 5, 6];
4951 mergesort(&mut a);
4952 assert_eq!(a, [1, 3, 5, 6]);
4953}
4954```
4955
4956VLAs 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]`.
4957
4958## Advisory on stack usage
4959
4960It's advised not to casually use the `#![feature(unsized_locals)]` feature. Typical use-cases are:
4961
4962- When you need a by-value trait objects.
4963- When you really need a fast allocation of small temporary arrays.
4964
4965Another 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
4966
4967```rust
4968#![feature(unsized_locals)]
4969
4970fn main() {
4971 let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);
4972 let _x = {{{{{{{{{{*x}}}}}}}}}};
4973}
4974```
4975
4976and the code
4977
4978```rust
4979#![feature(unsized_locals)]
4980
4981fn main() {
4982 for _ in 0..10 {
4983 let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);
4984 let _x = *x;
4985 }
4986}
4987```
4988
4989will unnecessarily extend the stack frame.
4990"##,
4991 },
4992 Lint {
4993 label: "unsized_tuple_coercion",
4994 description: r##"# `unsized_tuple_coercion`
4995
4996The tracking issue for this feature is: [#42877]
4997
4998[#42877]: https://github.com/rust-lang/rust/issues/42877
4999
5000------------------------
5001
5002This is a part of [RFC0401]. According to the RFC, there should be an implementation like this:
5003
5004```rust,ignore (partial-example)
5005impl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized<U> {}
5006```
5007
5008This implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this:
5009
5010```rust
5011#![feature(unsized_tuple_coercion)]
5012
5013fn main() {
5014 let x : ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]);
5015 let y : &([i32; 3], [i32]) = &x;
5016 assert_eq!(y.1[0], 4);
5017}
5018```
5019
5020[RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
5021"##,
5022 },
5023 Lint {
5024 label: "update_panic_count",
5025 description: r##"# `update_panic_count`
4494 5026
4495This feature is internal to the Rust compiler and is not intended for general use. 5027This feature is internal to the Rust compiler and is not intended for general use.
4496 5028
4497------------------------ 5029------------------------
4498"##, 5030"##,
4499 }, 5031 },
4500 LintCompletion { 5032 Lint {
4501 label: "fd", 5033 label: "windows_c",
4502 description: r##"# `fd` 5034 description: r##"# `windows_c`
4503 5035
4504This feature is internal to the Rust compiler and is not intended for general use. 5036This feature is internal to the Rust compiler and is not intended for general use.
4505 5037
4506------------------------ 5038------------------------
4507"##, 5039"##,
4508 }, 5040 },
4509 LintCompletion { 5041 Lint {
4510 label: "libstd_thread_internals", 5042 label: "windows_handle",
4511 description: r##"# `libstd_thread_internals` 5043 description: r##"# `windows_handle`
5044
5045This feature is internal to the Rust compiler and is not intended for general use.
5046
5047------------------------
5048"##,
5049 },
5050 Lint {
5051 label: "windows_net",
5052 description: r##"# `windows_net`
5053
5054This feature is internal to the Rust compiler and is not intended for general use.
5055
5056------------------------
5057"##,
5058 },
5059 Lint {
5060 label: "windows_stdio",
5061 description: r##"# `windows_stdio`
4512 5062
4513This feature is internal to the Rust compiler and is not intended for general use. 5063This feature is internal to the Rust compiler and is not intended for general use.
4514 5064
@@ -4517,1863 +5067,1851 @@ This feature is internal to the Rust compiler and is not intended for general us
4517 }, 5067 },
4518]; 5068];
4519 5069
4520pub(super) const CLIPPY_LINTS: &[LintCompletion] = &[ 5070pub const CLIPPY_LINTS: &[Lint] = &[
4521 LintCompletion { 5071 Lint {
4522 label: "clippy::absurd_extreme_comparisons", 5072 label: "clippy::absurd_extreme_comparisons",
4523 description: r##"Checks for comparisons where one side of the relation is\neither the minimum or maximum value for its type and warns if it involves a\ncase that is always true or always false. Only integer and boolean types are\nchecked."##, 5073 description: r##"Checks for comparisons where one side of the relation is\neither the minimum or maximum value for its type and warns if it involves a\ncase that is always true or always false. Only integer and boolean types are\nchecked."##,
4524 }, 5074 },
4525 LintCompletion { 5075 Lint {
4526 label: "clippy::almost_swapped", 5076 label: "clippy::almost_swapped",
4527 description: r##"Checks for `foo = bar; bar = foo` sequences."##, 5077 description: r##"Checks for `foo = bar; bar = foo` sequences."##,
4528 }, 5078 },
4529 LintCompletion { 5079 Lint {
4530 label: "clippy::approx_constant", 5080 label: "clippy::approx_constant",
4531 description: r##"Checks for floating point literals that approximate\nconstants which are defined in\n[`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)\nor\n[`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),\nrespectively, suggesting to use the predefined constant."##, 5081 description: r##"Checks for floating point literals that approximate\nconstants which are defined in\n[`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)\nor\n[`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),\nrespectively, suggesting to use the predefined constant."##,
4532 }, 5082 },
4533 LintCompletion { 5083 Lint {
4534 label: "clippy::as_conversions", 5084 label: "clippy::as_conversions",
4535 description: r##"Checks for usage of `as` conversions.\n\nNote that this lint is specialized in linting *every single* use of `as`\nregardless of whether good alternatives exist or not.\nIf you want more precise lints for `as`, please consider using these separate lints:\n`unnecessary_cast`, `cast_lossless/possible_truncation/possible_wrap/precision_loss/sign_loss`,\n`fn_to_numeric_cast(_with_truncation)`, `char_lit_as_u8`, `ref_to_mut` and `ptr_as_ptr`.\nThere is a good explanation the reason why this lint should work in this way and how it is useful\n[in this issue](https://github.com/rust-lang/rust-clippy/issues/5122)."##, 5085 description: r##"Checks for usage of `as` conversions.\n\nNote that this lint is specialized in linting *every single* use of `as`\nregardless of whether good alternatives exist or not.\nIf you want more precise lints for `as`, please consider using these separate lints:\n`unnecessary_cast`, `cast_lossless/possible_truncation/possible_wrap/precision_loss/sign_loss`,\n`fn_to_numeric_cast(_with_truncation)`, `char_lit_as_u8`, `ref_to_mut` and `ptr_as_ptr`.\nThere is a good explanation the reason why this lint should work in this way and how it is useful\n[in this issue](https://github.com/rust-lang/rust-clippy/issues/5122)."##,
4536 }, 5086 },
4537 LintCompletion { 5087 Lint {
4538 label: "clippy::assertions_on_constants", 5088 label: "clippy::assertions_on_constants",
4539 description: r##"Checks for `assert!(true)` and `assert!(false)` calls."##, 5089 description: r##"Checks for `assert!(true)` and `assert!(false)` calls."##,
4540 }, 5090 },
4541 LintCompletion { 5091 Lint {
4542 label: "clippy::assign_op_pattern", 5092 label: "clippy::assign_op_pattern",
4543 description: r##"Checks for `a = a op b` or `a = b commutative_op a`\npatterns."##, 5093 description: r##"Checks for `a = a op b` or `a = b commutative_op a`\npatterns."##,
4544 }, 5094 },
4545 LintCompletion { 5095 Lint {
4546 label: "clippy::assign_ops", 5096 label: "clippy::assign_ops",
4547 description: r##"Nothing. This lint has been deprecated."##, 5097 description: r##"Nothing. This lint has been deprecated."##,
4548 }, 5098 },
4549 LintCompletion { 5099 Lint {
4550 label: "clippy::async_yields_async", 5100 label: "clippy::async_yields_async",
4551 description: r##"Checks for async blocks that yield values of types\nthat can themselves be awaited."##, 5101 description: r##"Checks for async blocks that yield values of types\nthat can themselves be awaited."##,
4552 }, 5102 },
4553 LintCompletion { 5103 Lint {
4554 label: "clippy::await_holding_lock", 5104 label: "clippy::await_holding_lock",
4555 description: r##"Checks for calls to await while holding a\nnon-async-aware MutexGuard."##, 5105 description: r##"Checks for calls to await while holding a\nnon-async-aware MutexGuard."##,
4556 }, 5106 },
4557 LintCompletion { 5107 Lint {
4558 label: "clippy::await_holding_refcell_ref", 5108 label: "clippy::await_holding_refcell_ref",
4559 description: r##"Checks for calls to await while holding a\n`RefCell` `Ref` or `RefMut`."##, 5109 description: r##"Checks for calls to await while holding a\n`RefCell` `Ref` or `RefMut`."##,
4560 }, 5110 },
4561 LintCompletion { 5111 Lint {
4562 label: "clippy::bad_bit_mask", 5112 label: "clippy::bad_bit_mask",
4563 description: r##"Checks for incompatible bit masks in comparisons.\n\nThe formula for detecting if an expression of the type `_ <bit_op> m\n<cmp_op> c` (where `<bit_op>` is one of {`&`, `|`} and `<cmp_op>` is one of\n{`!=`, `>=`, `>`, `!=`, `>=`, `>`}) can be determined from the following\ntable:\n\n|Comparison |Bit Op|Example |is always|Formula |\n|------------|------|------------|---------|----------------------|\n|`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` |\n|`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` |\n|`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` |\n|`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` |\n|`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` |\n|`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` |"##, 5113 description: r##"Checks for incompatible bit masks in comparisons.\n\nThe formula for detecting if an expression of the type `_ <bit_op> m\n<cmp_op> c` (where `<bit_op>` is one of {`&`, `|`} and `<cmp_op>` is one of\n{`!=`, `>=`, `>`, `!=`, `>=`, `>`}) can be determined from the following\ntable:\n\n|Comparison |Bit Op|Example |is always|Formula |\n|------------|------|------------|---------|----------------------|\n|`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` |\n|`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` |\n|`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` |\n|`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` |\n|`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` |\n|`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` |"##,
4564 }, 5114 },
4565 LintCompletion { 5115 Lint {
4566 label: "clippy::bind_instead_of_map", 5116 label: "clippy::bind_instead_of_map",
4567 description: r##"Checks for usage of `_.and_then(|x| Some(y))`, `_.and_then(|x| Ok(y))` or\n`_.or_else(|x| Err(y))`."##, 5117 description: r##"Checks for usage of `_.and_then(|x| Some(y))`, `_.and_then(|x| Ok(y))` or\n`_.or_else(|x| Err(y))`."##,
4568 }, 5118 },
4569 LintCompletion { 5119 Lint {
4570 label: "clippy::blacklisted_name", 5120 label: "clippy::blacklisted_name",
4571 description: r##"Checks for usage of blacklisted names for variables, such\nas `foo`."##, 5121 description: r##"Checks for usage of blacklisted names for variables, such\nas `foo`."##,
4572 }, 5122 },
4573 LintCompletion { 5123 Lint {
4574 label: "clippy::blanket_clippy_restriction_lints", 5124 label: "clippy::blanket_clippy_restriction_lints",
4575 description: r##"Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category."##, 5125 description: r##"Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category."##,
4576 }, 5126 },
4577 LintCompletion { 5127 Lint {
4578 label: "clippy::blocks_in_if_conditions", 5128 label: "clippy::blocks_in_if_conditions",
4579 description: r##"Checks for `if` conditions that use blocks containing an\nexpression, statements or conditions that use closures with blocks."##, 5129 description: r##"Checks for `if` conditions that use blocks containing an\nexpression, statements or conditions that use closures with blocks."##,
4580 }, 5130 },
4581 LintCompletion { 5131 Lint {
5132 label: "clippy::bool_assert_comparison",
5133 description: r##"This lint warns about boolean comparisons in assert-like macros."##,
5134 },
5135 Lint {
4582 label: "clippy::bool_comparison", 5136 label: "clippy::bool_comparison",
4583 description: r##"Checks for expressions of the form `x == true`,\n`x != true` and order comparisons such as `x < true` (or vice versa) and\nsuggest using the variable directly."##, 5137 description: r##"Checks for expressions of the form `x == true`,\n`x != true` and order comparisons such as `x < true` (or vice versa) and\nsuggest using the variable directly."##,
4584 }, 5138 },
4585 LintCompletion { 5139 Lint {
4586 label: "clippy::borrow_interior_mutable_const", 5140 label: "clippy::borrow_interior_mutable_const",
4587 description: r##"Checks if `const` items which is interior mutable (e.g.,\ncontains a `Cell`, `Mutex`, `AtomicXxxx`, etc.) has been borrowed directly."##, 5141 description: r##"Checks if `const` items which is interior mutable (e.g.,\ncontains a `Cell`, `Mutex`, `AtomicXxxx`, etc.) has been borrowed directly."##,
4588 }, 5142 },
4589 LintCompletion { 5143 Lint {
4590 label: "clippy::borrowed_box", 5144 label: "clippy::borrowed_box",
4591 description: r##"Checks for use of `&Box<T>` anywhere in the code.\nCheck the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##, 5145 description: r##"Checks for use of `&Box<T>` anywhere in the code.\nCheck the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##,
4592 }, 5146 },
4593 LintCompletion { 5147 Lint {
4594 label: "clippy::box_vec", 5148 label: "clippy::box_vec",
4595 description: r##"Checks for use of `Box<Vec<_>>` anywhere in the code.\nCheck the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##, 5149 description: r##"Checks for use of `Box<Vec<_>>` anywhere in the code.\nCheck the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##,
4596 }, 5150 },
4597 LintCompletion { 5151 Lint {
4598 label: "clippy::boxed_local", 5152 label: "clippy::boxed_local",
4599 description: r##"Checks for usage of `Box<T>` where an unboxed `T` would\nwork fine."##, 5153 description: r##"Checks for usage of `Box<T>` where an unboxed `T` would\nwork fine."##,
4600 }, 5154 },
4601 LintCompletion { 5155 Lint {
5156 label: "clippy::branches_sharing_code",
5157 description: r##"Checks if the `if` and `else` block contain shared code that can be\nmoved out of the blocks."##,
5158 },
5159 Lint {
4602 label: "clippy::builtin_type_shadow", 5160 label: "clippy::builtin_type_shadow",
4603 description: r##"Warns if a generic shadows a built-in type."##, 5161 description: r##"Warns if a generic shadows a built-in type."##,
4604 }, 5162 },
4605 LintCompletion { 5163 Lint {
4606 label: "clippy::bytes_nth", 5164 label: "clippy::bytes_nth",
4607 description: r##"Checks for the use of `.bytes().nth()`."##, 5165 description: r##"Checks for the use of `.bytes().nth()`."##,
4608 }, 5166 },
4609 LintCompletion { 5167 Lint {
4610 label: "clippy::cargo_common_metadata", 5168 label: "clippy::cargo_common_metadata",
4611 description: r##"Checks to see if all common metadata is defined in\n`Cargo.toml`. See: https://rust-lang-nursery.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata"##, 5169 description: r##"Checks to see if all common metadata is defined in\n`Cargo.toml`. See: https://rust-lang-nursery.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata"##,
4612 }, 5170 },
4613 LintCompletion { 5171 Lint {
4614 label: "clippy::case_sensitive_file_extension_comparisons", 5172 label: "clippy::case_sensitive_file_extension_comparisons",
4615 description: r##"Checks for calls to `ends_with` with possible file extensions\nand suggests to use a case-insensitive approach instead."##, 5173 description: r##"Checks for calls to `ends_with` with possible file extensions\nand suggests to use a case-insensitive approach instead."##,
4616 }, 5174 },
4617 LintCompletion { 5175 Lint {
4618 label: "clippy::cast_lossless", 5176 label: "clippy::cast_lossless",
4619 description: r##"Checks for casts between numerical types that may\nbe replaced by safe conversion functions."##, 5177 description: r##"Checks for casts between numerical types that may\nbe replaced by safe conversion functions."##,
4620 }, 5178 },
4621 LintCompletion { 5179 Lint {
4622 label: "clippy::cast_possible_truncation", 5180 label: "clippy::cast_possible_truncation",
4623 description: r##"Checks for casts between numerical types that may\ntruncate large values. This is expected behavior, so the cast is `Allow` by\ndefault."##, 5181 description: r##"Checks for casts between numerical types that may\ntruncate large values. This is expected behavior, so the cast is `Allow` by\ndefault."##,
4624 }, 5182 },
4625 LintCompletion { 5183 Lint {
4626 label: "clippy::cast_possible_wrap", 5184 label: "clippy::cast_possible_wrap",
4627 description: r##"Checks for casts from an unsigned type to a signed type of\nthe same size. Performing such a cast is a 'no-op' for the compiler,\ni.e., nothing is changed at the bit level, and the binary representation of\nthe value is reinterpreted. This can cause wrapping if the value is too big\nfor the target signed type. However, the cast works as defined, so this lint\nis `Allow` by default."##, 5185 description: r##"Checks for casts from an unsigned type to a signed type of\nthe same size. Performing such a cast is a 'no-op' for the compiler,\ni.e., nothing is changed at the bit level, and the binary representation of\nthe value is reinterpreted. This can cause wrapping if the value is too big\nfor the target signed type. However, the cast works as defined, so this lint\nis `Allow` by default."##,
4628 }, 5186 },
4629 LintCompletion { 5187 Lint {
4630 label: "clippy::cast_precision_loss", 5188 label: "clippy::cast_precision_loss",
4631 description: r##"Checks for casts from any numerical to a float type where\nthe receiving type cannot store all values from the original type without\nrounding errors. This possible rounding is to be expected, so this lint is\n`Allow` by default.\n\nBasically, this warns on casting any integer with 32 or more bits to `f32`\nor any 64-bit integer to `f64`."##, 5189 description: r##"Checks for casts from any numerical to a float type where\nthe receiving type cannot store all values from the original type without\nrounding errors. This possible rounding is to be expected, so this lint is\n`Allow` by default.\n\nBasically, this warns on casting any integer with 32 or more bits to `f32`\nor any 64-bit integer to `f64`."##,
4632 }, 5190 },
4633 LintCompletion { 5191 Lint {
4634 label: "clippy::cast_ptr_alignment", 5192 label: "clippy::cast_ptr_alignment",
4635 description: r##"Checks for casts, using `as` or `pointer::cast`,\nfrom a less-strictly-aligned pointer to a more-strictly-aligned pointer"##, 5193 description: r##"Checks for casts, using `as` or `pointer::cast`,\nfrom a less-strictly-aligned pointer to a more-strictly-aligned pointer"##,
4636 }, 5194 },
4637 LintCompletion { 5195 Lint {
4638 label: "clippy::cast_ref_to_mut", 5196 label: "clippy::cast_ref_to_mut",
4639 description: r##"Checks for casts of `&T` to `&mut T` anywhere in the code."##, 5197 description: r##"Checks for casts of `&T` to `&mut T` anywhere in the code."##,
4640 }, 5198 },
4641 LintCompletion { 5199 Lint {
4642 label: "clippy::cast_sign_loss", 5200 label: "clippy::cast_sign_loss",
4643 description: r##"Checks for casts from a signed to an unsigned numerical\ntype. In this case, negative values wrap around to large positive values,\nwhich can be quite surprising in practice. However, as the cast works as\ndefined, this lint is `Allow` by default."##, 5201 description: r##"Checks for casts from a signed to an unsigned numerical\ntype. In this case, negative values wrap around to large positive values,\nwhich can be quite surprising in practice. However, as the cast works as\ndefined, this lint is `Allow` by default."##,
4644 }, 5202 },
4645 LintCompletion { 5203 Lint {
4646 label: "clippy::char_lit_as_u8", 5204 label: "clippy::char_lit_as_u8",
4647 description: r##"Checks for expressions where a character literal is cast\nto `u8` and suggests using a byte literal instead."##, 5205 description: r##"Checks for expressions where a character literal is cast\nto `u8` and suggests using a byte literal instead."##,
4648 }, 5206 },
4649 LintCompletion { 5207 Lint {
4650 label: "clippy::chars_last_cmp", 5208 label: "clippy::chars_last_cmp",
4651 description: r##"Checks for usage of `_.chars().last()` or\n`_.chars().next_back()` on a `str` to check if it ends with a given char."##, 5209 description: r##"Checks for usage of `_.chars().last()` or\n`_.chars().next_back()` on a `str` to check if it ends with a given char."##,
4652 }, 5210 },
4653 LintCompletion { 5211 Lint {
4654 label: "clippy::chars_next_cmp", 5212 label: "clippy::chars_next_cmp",
4655 description: r##"Checks for usage of `.chars().next()` on a `str` to check\nif it starts with a given char."##, 5213 description: r##"Checks for usage of `.chars().next()` on a `str` to check\nif it starts with a given char."##,
4656 }, 5214 },
4657 LintCompletion { 5215 Lint {
4658 label: "clippy::checked_conversions", 5216 label: "clippy::checked_conversions",
4659 description: r##"Checks for explicit bounds checking when casting."##, 5217 description: r##"Checks for explicit bounds checking when casting."##,
4660 }, 5218 },
4661 LintCompletion { 5219 Lint {
4662 label: "clippy::clone_double_ref", 5220 label: "clippy::clone_double_ref",
4663 description: r##"Checks for usage of `.clone()` on an `&&T`."##, 5221 description: r##"Checks for usage of `.clone()` on an `&&T`."##,
4664 }, 5222 },
4665 LintCompletion { 5223 Lint {
4666 label: "clippy::clone_on_copy", 5224 label: "clippy::clone_on_copy",
4667 description: r##"Checks for usage of `.clone()` on a `Copy` type."##, 5225 description: r##"Checks for usage of `.clone()` on a `Copy` type."##,
4668 }, 5226 },
4669 LintCompletion { 5227 Lint {
4670 label: "clippy::clone_on_ref_ptr", 5228 label: "clippy::clone_on_ref_ptr",
4671 description: r##"Checks for usage of `.clone()` on a ref-counted pointer,\n(`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified\nfunction syntax instead (e.g., `Rc::clone(foo)`)."##, 5229 description: r##"Checks for usage of `.clone()` on a ref-counted pointer,\n(`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified\nfunction syntax instead (e.g., `Rc::clone(foo)`)."##,
4672 }, 5230 },
4673 LintCompletion { label: "clippy::cmp_nan", description: r##"Checks for comparisons to NaN."## }, 5231 Lint {
4674 LintCompletion { 5232 label: "clippy::cloned_instead_of_copied",
5233 description: r##"Checks for usages of `cloned()` on an `Iterator` or `Option` where\n`copied()` could be used instead."##,
5234 },
5235 Lint { label: "clippy::cmp_nan", description: r##"Checks for comparisons to NaN."## },
5236 Lint {
4675 label: "clippy::cmp_null", 5237 label: "clippy::cmp_null",
4676 description: r##"This lint checks for equality comparisons with `ptr::null`"##, 5238 description: r##"This lint checks for equality comparisons with `ptr::null`"##,
4677 }, 5239 },
4678 LintCompletion { 5240 Lint {
4679 label: "clippy::cmp_owned", 5241 label: "clippy::cmp_owned",
4680 description: r##"Checks for conversions to owned values just for the sake\nof a comparison."##, 5242 description: r##"Checks for conversions to owned values just for the sake\nof a comparison."##,
4681 }, 5243 },
4682 LintCompletion { 5244 Lint {
4683 label: "clippy::cognitive_complexity", 5245 label: "clippy::cognitive_complexity",
4684 description: r##"Checks for methods with high cognitive complexity."##, 5246 description: r##"Checks for methods with high cognitive complexity."##,
4685 }, 5247 },
4686 LintCompletion { 5248 Lint {
4687 label: "clippy::collapsible_else_if", 5249 label: "clippy::collapsible_else_if",
4688 description: r##"Checks for collapsible `else { if ... }` expressions\nthat can be collapsed to `else if ...`."##, 5250 description: r##"Checks for collapsible `else { if ... }` expressions\nthat can be collapsed to `else if ...`."##,
4689 }, 5251 },
4690 LintCompletion { 5252 Lint {
4691 label: "clippy::collapsible_if", 5253 label: "clippy::collapsible_if",
4692 description: r##"Checks for nested `if` statements which can be collapsed\nby `&&`-combining their conditions."##, 5254 description: r##"Checks for nested `if` statements which can be collapsed\nby `&&`-combining their conditions."##,
4693 }, 5255 },
4694 LintCompletion { 5256 Lint {
4695 label: "clippy::collapsible_match", 5257 label: "clippy::collapsible_match",
4696 description: r##"Finds nested `match` or `if let` expressions where the patterns may be \"collapsed\" together\nwithout adding any branches.\n\nNote that this lint is not intended to find _all_ cases where nested match patterns can be merged, but only\ncases where merging would most likely make the code more readable."##, 5258 description: r##"Finds nested `match` or `if let` expressions where the patterns may be \"collapsed\" together\nwithout adding any branches.\n\nNote that this lint is not intended to find _all_ cases where nested match patterns can be merged, but only\ncases where merging would most likely make the code more readable."##,
4697 }, 5259 },
4698 LintCompletion { 5260 Lint {
4699 label: "clippy::comparison_chain", 5261 label: "clippy::comparison_chain",
4700 description: r##"Checks comparison chains written with `if` that can be\nrewritten with `match` and `cmp`."##, 5262 description: r##"Checks comparison chains written with `if` that can be\nrewritten with `match` and `cmp`."##,
4701 }, 5263 },
4702 LintCompletion { 5264 Lint {
4703 label: "clippy::comparison_to_empty", 5265 label: "clippy::comparison_to_empty",
4704 description: r##"Checks for comparing to an empty slice such as `\"\"` or `[]`,\nand suggests using `.is_empty()` where applicable."##, 5266 description: r##"Checks for comparing to an empty slice such as `\"\"` or `[]`,\nand suggests using `.is_empty()` where applicable."##,
4705 }, 5267 },
4706 LintCompletion { 5268 Lint {
4707 label: "clippy::copy_iterator", 5269 label: "clippy::copy_iterator",
4708 description: r##"Checks for types that implement `Copy` as well as\n`Iterator`."##, 5270 description: r##"Checks for types that implement `Copy` as well as\n`Iterator`."##,
4709 }, 5271 },
4710 LintCompletion { 5272 Lint {
4711 label: "clippy::create_dir", 5273 label: "clippy::create_dir",
4712 description: r##"Checks usage of `std::fs::create_dir` and suggest using `std::fs::create_dir_all` instead."##, 5274 description: r##"Checks usage of `std::fs::create_dir` and suggest using `std::fs::create_dir_all` instead."##,
4713 }, 5275 },
4714 LintCompletion { 5276 Lint {
4715 label: "clippy::crosspointer_transmute", 5277 label: "clippy::crosspointer_transmute",
4716 description: r##"Checks for transmutes between a type `T` and `*T`."##, 5278 description: r##"Checks for transmutes between a type `T` and `*T`."##,
4717 }, 5279 },
4718 LintCompletion { 5280 Lint { label: "clippy::dbg_macro", description: r##"Checks for usage of dbg!() macro."## },
4719 label: "clippy::dbg_macro", 5281 Lint {
4720 description: r##"Checks for usage of dbg!() macro."##,
4721 },
4722 LintCompletion {
4723 label: "clippy::debug_assert_with_mut_call", 5282 label: "clippy::debug_assert_with_mut_call",
4724 description: r##"Checks for function/method calls with a mutable\nparameter in `debug_assert!`, `debug_assert_eq!` and `debug_assert_ne!` macros."##, 5283 description: r##"Checks for function/method calls with a mutable\nparameter in `debug_assert!`, `debug_assert_eq!` and `debug_assert_ne!` macros."##,
4725 }, 5284 },
4726 LintCompletion { 5285 Lint {
4727 label: "clippy::decimal_literal_representation", 5286 label: "clippy::decimal_literal_representation",
4728 description: r##"Warns if there is a better representation for a numeric literal."##, 5287 description: r##"Warns if there is a better representation for a numeric literal."##,
4729 }, 5288 },
4730 LintCompletion { 5289 Lint {
4731 label: "clippy::declare_interior_mutable_const", 5290 label: "clippy::declare_interior_mutable_const",
4732 description: r##"Checks for declaration of `const` items which is interior\nmutable (e.g., contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.)."##, 5291 description: r##"Checks for declaration of `const` items which is interior\nmutable (e.g., contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.)."##,
4733 }, 5292 },
4734 LintCompletion { 5293 Lint {
4735 label: "clippy::default_numeric_fallback", 5294 label: "clippy::default_numeric_fallback",
4736 description: r##"Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type\ninference.\n\nDefault numeric fallback means that if numeric types have not yet been bound to concrete\ntypes at the end of type inference, then integer type is bound to `i32`, and similarly\nfloating type is bound to `f64`.\n\nSee [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback."##, 5295 description: r##"Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type\ninference.\n\nDefault numeric fallback means that if numeric types have not yet been bound to concrete\ntypes at the end of type inference, then integer type is bound to `i32`, and similarly\nfloating type is bound to `f64`.\n\nSee [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback."##,
4737 }, 5296 },
4738 LintCompletion { 5297 Lint {
4739 label: "clippy::default_trait_access", 5298 label: "clippy::default_trait_access",
4740 description: r##"Checks for literal calls to `Default::default()`."##, 5299 description: r##"Checks for literal calls to `Default::default()`."##,
4741 }, 5300 },
4742 LintCompletion { 5301 Lint {
4743 label: "clippy::deprecated_cfg_attr", 5302 label: "clippy::deprecated_cfg_attr",
4744 description: r##"Checks for `#[cfg_attr(rustfmt, rustfmt_skip)]` and suggests to replace it\nwith `#[rustfmt::skip]`."##, 5303 description: r##"Checks for `#[cfg_attr(rustfmt, rustfmt_skip)]` and suggests to replace it\nwith `#[rustfmt::skip]`."##,
4745 }, 5304 },
4746 LintCompletion { 5305 Lint {
4747 label: "clippy::deprecated_semver", 5306 label: "clippy::deprecated_semver",
4748 description: r##"Checks for `#[deprecated]` annotations with a `since`\nfield that is not a valid semantic version."##, 5307 description: r##"Checks for `#[deprecated]` annotations with a `since`\nfield that is not a valid semantic version."##,
4749 }, 5308 },
4750 LintCompletion { 5309 Lint {
4751 label: "clippy::deref_addrof", 5310 label: "clippy::deref_addrof",
4752 description: r##"Checks for usage of `*&` and `*&mut` in expressions."##, 5311 description: r##"Checks for usage of `*&` and `*&mut` in expressions."##,
4753 }, 5312 },
4754 LintCompletion { 5313 Lint {
4755 label: "clippy::derive_hash_xor_eq", 5314 label: "clippy::derive_hash_xor_eq",
4756 description: r##"Checks for deriving `Hash` but implementing `PartialEq`\nexplicitly or vice versa."##, 5315 description: r##"Checks for deriving `Hash` but implementing `PartialEq`\nexplicitly or vice versa."##,
4757 }, 5316 },
4758 LintCompletion { 5317 Lint {
4759 label: "clippy::derive_ord_xor_partial_ord", 5318 label: "clippy::derive_ord_xor_partial_ord",
4760 description: r##"Checks for deriving `Ord` but implementing `PartialOrd`\nexplicitly or vice versa."##, 5319 description: r##"Checks for deriving `Ord` but implementing `PartialOrd`\nexplicitly or vice versa."##,
4761 }, 5320 },
4762 LintCompletion { 5321 Lint {
4763 label: "clippy::disallowed_method", 5322 label: "clippy::disallowed_method",
4764 description: r##"Denies the configured methods and functions in clippy.toml"##, 5323 description: r##"Denies the configured methods and functions in clippy.toml"##,
4765 }, 5324 },
4766 LintCompletion { 5325 Lint {
4767 label: "clippy::diverging_sub_expression", 5326 label: "clippy::diverging_sub_expression",
4768 description: r##"Checks for diverging calls that are not match arms or\nstatements."##, 5327 description: r##"Checks for diverging calls that are not match arms or\nstatements."##,
4769 }, 5328 },
4770 LintCompletion { 5329 Lint {
4771 label: "clippy::doc_markdown", 5330 label: "clippy::doc_markdown",
4772 description: r##"Checks for the presence of `_`, `::` or camel-case words\noutside ticks in documentation."##, 5331 description: r##"Checks for the presence of `_`, `::` or camel-case words\noutside ticks in documentation."##,
4773 }, 5332 },
4774 LintCompletion { 5333 Lint {
4775 label: "clippy::double_comparisons", 5334 label: "clippy::double_comparisons",
4776 description: r##"Checks for double comparisons that could be simplified to a single expression."##, 5335 description: r##"Checks for double comparisons that could be simplified to a single expression."##,
4777 }, 5336 },
4778 LintCompletion { 5337 Lint {
4779 label: "clippy::double_must_use", 5338 label: "clippy::double_must_use",
4780 description: r##"Checks for a [`#[must_use]`] attribute without\nfurther information on functions and methods that return a type already\nmarked as `#[must_use]`.\n\n[`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"##, 5339 description: r##"Checks for a [`#[must_use]`] attribute without\nfurther information on functions and methods that return a type already\nmarked as `#[must_use]`.\n\n[`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"##,
4781 }, 5340 },
4782 LintCompletion { 5341 Lint {
4783 label: "clippy::double_neg", 5342 label: "clippy::double_neg",
4784 description: r##"Detects expressions of the form `--x`."##, 5343 description: r##"Detects expressions of the form `--x`."##,
4785 }, 5344 },
4786 LintCompletion { 5345 Lint {
4787 label: "clippy::double_parens", 5346 label: "clippy::double_parens",
4788 description: r##"Checks for unnecessary double parentheses."##, 5347 description: r##"Checks for unnecessary double parentheses."##,
4789 }, 5348 },
4790 LintCompletion { 5349 Lint {
4791 label: "clippy::drop_bounds",
4792 description: r##"Nothing. This lint has been deprecated."##,
4793 },
4794 LintCompletion {
4795 label: "clippy::drop_copy", 5350 label: "clippy::drop_copy",
4796 description: r##"Checks for calls to `std::mem::drop` with a value\nthat derives the Copy trait"##, 5351 description: r##"Checks for calls to `std::mem::drop` with a value\nthat derives the Copy trait"##,
4797 }, 5352 },
4798 LintCompletion { 5353 Lint {
4799 label: "clippy::drop_ref", 5354 label: "clippy::drop_ref",
4800 description: r##"Checks for calls to `std::mem::drop` with a reference\ninstead of an owned value."##, 5355 description: r##"Checks for calls to `std::mem::drop` with a reference\ninstead of an owned value."##,
4801 }, 5356 },
4802 LintCompletion { 5357 Lint {
4803 label: "clippy::duplicate_underscore_argument", 5358 label: "clippy::duplicate_underscore_argument",
4804 description: r##"Checks for function arguments having the similar names\ndiffering by an underscore."##, 5359 description: r##"Checks for function arguments having the similar names\ndiffering by an underscore."##,
4805 }, 5360 },
4806 LintCompletion { 5361 Lint {
4807 label: "clippy::duration_subsec", 5362 label: "clippy::duration_subsec",
4808 description: r##"Checks for calculation of subsecond microseconds or milliseconds\nfrom other `Duration` methods."##, 5363 description: r##"Checks for calculation of subsecond microseconds or milliseconds\nfrom other `Duration` methods."##,
4809 }, 5364 },
4810 LintCompletion { 5365 Lint {
4811 label: "clippy::else_if_without_else", 5366 label: "clippy::else_if_without_else",
4812 description: r##"Checks for usage of if expressions with an `else if` branch,\nbut without a final `else` branch."##, 5367 description: r##"Checks for usage of if expressions with an `else if` branch,\nbut without a final `else` branch."##,
4813 }, 5368 },
4814 LintCompletion { 5369 Lint {
4815 label: "clippy::empty_enum", 5370 label: "clippy::empty_enum",
4816 description: r##"Checks for `enum`s with no variants.\n\nAs of this writing, the `never_type` is still a\nnightly-only experimental API. Therefore, this lint is only triggered\nif the `never_type` is enabled."##, 5371 description: r##"Checks for `enum`s with no variants.\n\nAs of this writing, the `never_type` is still a\nnightly-only experimental API. Therefore, this lint is only triggered\nif the `never_type` is enabled."##,
4817 }, 5372 },
4818 LintCompletion { 5373 Lint {
4819 label: "clippy::empty_line_after_outer_attr", 5374 label: "clippy::empty_line_after_outer_attr",
4820 description: r##"Checks for empty lines after outer attributes"##, 5375 description: r##"Checks for empty lines after outer attributes"##,
4821 }, 5376 },
4822 LintCompletion { 5377 Lint { label: "clippy::empty_loop", description: r##"Checks for empty `loop` expressions."## },
4823 label: "clippy::empty_loop", 5378 Lint {
4824 description: r##"Checks for empty `loop` expressions."##,
4825 },
4826 LintCompletion {
4827 label: "clippy::enum_clike_unportable_variant", 5379 label: "clippy::enum_clike_unportable_variant",
4828 description: r##"Checks for C-like enumerations that are\n`repr(isize/usize)` and have values that don't fit into an `i32`."##, 5380 description: r##"Checks for C-like enumerations that are\n`repr(isize/usize)` and have values that don't fit into an `i32`."##,
4829 }, 5381 },
4830 LintCompletion { 5382 Lint { label: "clippy::enum_glob_use", description: r##"Checks for `use Enum::*`."## },
4831 label: "clippy::enum_glob_use", 5383 Lint {
4832 description: r##"Checks for `use Enum::*`."##,
4833 },
4834 LintCompletion {
4835 label: "clippy::enum_variant_names", 5384 label: "clippy::enum_variant_names",
4836 description: r##"Detects enumeration variants that are prefixed or suffixed\nby the same characters."##, 5385 description: r##"Detects enumeration variants that are prefixed or suffixed\nby the same characters."##,
4837 }, 5386 },
4838 LintCompletion { 5387 Lint {
4839 label: "clippy::eq_op", 5388 label: "clippy::eq_op",
4840 description: r##"Checks for equal operands to comparison, logical and\nbitwise, difference and division binary operators (`==`, `>`, etc., `&&`,\n`||`, `&`, `|`, `^`, `-` and `/`)."##, 5389 description: r##"Checks for equal operands to comparison, logical and\nbitwise, difference and division binary operators (`==`, `>`, etc., `&&`,\n`||`, `&`, `|`, `^`, `-` and `/`)."##,
4841 }, 5390 },
4842 LintCompletion { 5391 Lint {
4843 label: "clippy::erasing_op", 5392 label: "clippy::erasing_op",
4844 description: r##"Checks for erasing operations, e.g., `x * 0`."##, 5393 description: r##"Checks for erasing operations, e.g., `x * 0`."##,
4845 }, 5394 },
4846 LintCompletion { 5395 Lint {
4847 label: "clippy::eval_order_dependence", 5396 label: "clippy::eval_order_dependence",
4848 description: r##"Checks for a read and a write to the same variable where\nwhether the read occurs before or after the write depends on the evaluation\norder of sub-expressions."##, 5397 description: r##"Checks for a read and a write to the same variable where\nwhether the read occurs before or after the write depends on the evaluation\norder of sub-expressions."##,
4849 }, 5398 },
4850 LintCompletion { 5399 Lint {
4851 label: "clippy::excessive_precision", 5400 label: "clippy::excessive_precision",
4852 description: r##"Checks for float literals with a precision greater\nthan that supported by the underlying type."##, 5401 description: r##"Checks for float literals with a precision greater\nthan that supported by the underlying type."##,
4853 }, 5402 },
4854 LintCompletion { 5403 Lint {
4855 label: "clippy::exhaustive_enums", 5404 label: "clippy::exhaustive_enums",
4856 description: r##"Warns on any exported `enum`s that are not tagged `#[non_exhaustive]`"##, 5405 description: r##"Warns on any exported `enum`s that are not tagged `#[non_exhaustive]`"##,
4857 }, 5406 },
4858 LintCompletion { 5407 Lint {
4859 label: "clippy::exhaustive_structs", 5408 label: "clippy::exhaustive_structs",
4860 description: r##"Warns on any exported `structs`s that are not tagged `#[non_exhaustive]`"##, 5409 description: r##"Warns on any exported `structs`s that are not tagged `#[non_exhaustive]`"##,
4861 }, 5410 },
4862 LintCompletion { 5411 Lint {
4863 label: "clippy::exit", 5412 label: "clippy::exit",
4864 description: r##"`exit()` terminates the program and doesn't provide a\nstack trace."##, 5413 description: r##"`exit()` terminates the program and doesn't provide a\nstack trace."##,
4865 }, 5414 },
4866 LintCompletion { 5415 Lint {
4867 label: "clippy::expect_fun_call", 5416 label: "clippy::expect_fun_call",
4868 description: r##"Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`,\netc., and suggests to use `unwrap_or_else` instead"##, 5417 description: r##"Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`,\netc., and suggests to use `unwrap_or_else` instead"##,
4869 }, 5418 },
4870 LintCompletion { 5419 Lint {
4871 label: "clippy::expect_used", 5420 label: "clippy::expect_used",
4872 description: r##"Checks for `.expect()` calls on `Option`s and `Result`s."##, 5421 description: r##"Checks for `.expect()` calls on `Option`s and `Result`s."##,
4873 }, 5422 },
4874 LintCompletion { 5423 Lint {
4875 label: "clippy::expl_impl_clone_on_copy", 5424 label: "clippy::expl_impl_clone_on_copy",
4876 description: r##"Checks for explicit `Clone` implementations for `Copy`\ntypes."##, 5425 description: r##"Checks for explicit `Clone` implementations for `Copy`\ntypes."##,
4877 }, 5426 },
4878 LintCompletion { 5427 Lint {
4879 label: "clippy::explicit_counter_loop", 5428 label: "clippy::explicit_counter_loop",
4880 description: r##"Checks `for` loops over slices with an explicit counter\nand suggests the use of `.enumerate()`."##, 5429 description: r##"Checks `for` loops over slices with an explicit counter\nand suggests the use of `.enumerate()`."##,
4881 }, 5430 },
4882 LintCompletion { 5431 Lint {
4883 label: "clippy::explicit_deref_methods", 5432 label: "clippy::explicit_deref_methods",
4884 description: r##"Checks for explicit `deref()` or `deref_mut()` method calls."##, 5433 description: r##"Checks for explicit `deref()` or `deref_mut()` method calls."##,
4885 }, 5434 },
4886 LintCompletion { 5435 Lint {
4887 label: "clippy::explicit_into_iter_loop", 5436 label: "clippy::explicit_into_iter_loop",
4888 description: r##"Checks for loops on `y.into_iter()` where `y` will do, and\nsuggests the latter."##, 5437 description: r##"Checks for loops on `y.into_iter()` where `y` will do, and\nsuggests the latter."##,
4889 }, 5438 },
4890 LintCompletion { 5439 Lint {
4891 label: "clippy::explicit_iter_loop", 5440 label: "clippy::explicit_iter_loop",
4892 description: r##"Checks for loops on `x.iter()` where `&x` will do, and\nsuggests the latter."##, 5441 description: r##"Checks for loops on `x.iter()` where `&x` will do, and\nsuggests the latter."##,
4893 }, 5442 },
4894 LintCompletion { 5443 Lint {
4895 label: "clippy::explicit_write", 5444 label: "clippy::explicit_write",
4896 description: r##"Checks for usage of `write!()` / `writeln()!` which can be\nreplaced with `(e)print!()` / `(e)println!()`"##, 5445 description: r##"Checks for usage of `write!()` / `writeln()!` which can be\nreplaced with `(e)print!()` / `(e)println!()`"##,
4897 }, 5446 },
4898 LintCompletion { 5447 Lint {
4899 label: "clippy::extend_from_slice", 5448 label: "clippy::extend_from_slice",
4900 description: r##"Nothing. This lint has been deprecated."##, 5449 description: r##"Nothing. This lint has been deprecated."##,
4901 }, 5450 },
4902 LintCompletion { 5451 Lint {
4903 label: "clippy::extra_unused_lifetimes", 5452 label: "clippy::extra_unused_lifetimes",
4904 description: r##"Checks for lifetimes in generics that are never used\nanywhere else."##, 5453 description: r##"Checks for lifetimes in generics that are never used\nanywhere else."##,
4905 }, 5454 },
4906 LintCompletion { 5455 Lint {
4907 label: "clippy::fallible_impl_from", 5456 label: "clippy::fallible_impl_from",
4908 description: r##"Checks for impls of `From<..>` that contain `panic!()` or `unwrap()`"##, 5457 description: r##"Checks for impls of `From<..>` that contain `panic!()` or `unwrap()`"##,
4909 }, 5458 },
4910 LintCompletion { 5459 Lint {
4911 label: "clippy::field_reassign_with_default", 5460 label: "clippy::field_reassign_with_default",
4912 description: r##"Checks for immediate reassignment of fields initialized\nwith Default::default()."##, 5461 description: r##"Checks for immediate reassignment of fields initialized\nwith Default::default()."##,
4913 }, 5462 },
4914 LintCompletion { 5463 Lint {
4915 label: "clippy::filetype_is_file", 5464 label: "clippy::filetype_is_file",
4916 description: r##"Checks for `FileType::is_file()`."##, 5465 description: r##"Checks for `FileType::is_file()`."##,
4917 }, 5466 },
4918 LintCompletion { 5467 Lint {
4919 label: "clippy::filter_map", 5468 label: "clippy::filter_map",
4920 description: r##"Checks for usage of `_.filter(_).map(_)`,\n`_.filter(_).flat_map(_)`, `_.filter_map(_).flat_map(_)` and similar."##, 5469 description: r##"Nothing. This lint has been deprecated."##,
4921 }, 5470 },
4922 LintCompletion { 5471 Lint {
4923 label: "clippy::filter_map_identity", 5472 label: "clippy::filter_map_identity",
4924 description: r##"Checks for usage of `filter_map(|x| x)`."##, 5473 description: r##"Checks for usage of `filter_map(|x| x)`."##,
4925 }, 5474 },
4926 LintCompletion { 5475 Lint {
4927 label: "clippy::filter_map_next", 5476 label: "clippy::filter_map_next",
4928 description: r##"Checks for usage of `_.filter_map(_).next()`."##, 5477 description: r##"Checks for usage of `_.filter_map(_).next()`."##,
4929 }, 5478 },
4930 LintCompletion { 5479 Lint {
4931 label: "clippy::filter_next", 5480 label: "clippy::filter_next",
4932 description: r##"Checks for usage of `_.filter(_).next()`."##, 5481 description: r##"Checks for usage of `_.filter(_).next()`."##,
4933 }, 5482 },
4934 LintCompletion { 5483 Lint { label: "clippy::find_map", description: r##"Nothing. This lint has been deprecated."## },
4935 label: "clippy::find_map", 5484 Lint {
4936 description: r##"Nothing. This lint has been deprecated."##,
4937 },
4938 LintCompletion {
4939 label: "clippy::flat_map_identity", 5485 label: "clippy::flat_map_identity",
4940 description: r##"Checks for usage of `flat_map(|x| x)`."##, 5486 description: r##"Checks for usage of `flat_map(|x| x)`."##,
4941 }, 5487 },
4942 LintCompletion { 5488 Lint {
4943 label: "clippy::float_arithmetic", 5489 label: "clippy::flat_map_option",
4944 description: r##"Checks for float arithmetic."##, 5490 description: r##"Checks for usages of `Iterator::flat_map()` where `filter_map()` could be\nused instead."##,
4945 }, 5491 },
4946 LintCompletion { 5492 Lint { label: "clippy::float_arithmetic", description: r##"Checks for float arithmetic."## },
5493 Lint {
4947 label: "clippy::float_cmp", 5494 label: "clippy::float_cmp",
4948 description: r##"Checks for (in-)equality comparisons on floating-point\nvalues (apart from zero), except in functions called `*eq*` (which probably\nimplement equality for a type involving floats)."##, 5495 description: r##"Checks for (in-)equality comparisons on floating-point\nvalues (apart from zero), except in functions called `*eq*` (which probably\nimplement equality for a type involving floats)."##,
4949 }, 5496 },
4950 LintCompletion { 5497 Lint {
4951 label: "clippy::float_cmp_const", 5498 label: "clippy::float_cmp_const",
4952 description: r##"Checks for (in-)equality comparisons on floating-point\nvalue and constant, except in functions called `*eq*` (which probably\nimplement equality for a type involving floats)."##, 5499 description: r##"Checks for (in-)equality comparisons on floating-point\nvalue and constant, except in functions called `*eq*` (which probably\nimplement equality for a type involving floats)."##,
4953 }, 5500 },
4954 LintCompletion { 5501 Lint {
4955 label: "clippy::float_equality_without_abs", 5502 label: "clippy::float_equality_without_abs",
4956 description: r##"Checks for statements of the form `(a - b) < f32::EPSILON` or\n`(a - b) < f64::EPSILON`. Notes the missing `.abs()`."##, 5503 description: r##"Checks for statements of the form `(a - b) < f32::EPSILON` or\n`(a - b) < f64::EPSILON`. Notes the missing `.abs()`."##,
4957 }, 5504 },
4958 LintCompletion { 5505 Lint {
4959 label: "clippy::fn_address_comparisons", 5506 label: "clippy::fn_address_comparisons",
4960 description: r##"Checks for comparisons with an address of a function item."##, 5507 description: r##"Checks for comparisons with an address of a function item."##,
4961 }, 5508 },
4962 LintCompletion { 5509 Lint {
4963 label: "clippy::fn_params_excessive_bools", 5510 label: "clippy::fn_params_excessive_bools",
4964 description: r##"Checks for excessive use of\nbools in function definitions."##, 5511 description: r##"Checks for excessive use of\nbools in function definitions."##,
4965 }, 5512 },
4966 LintCompletion { 5513 Lint {
4967 label: "clippy::fn_to_numeric_cast", 5514 label: "clippy::fn_to_numeric_cast",
4968 description: r##"Checks for casts of function pointers to something other than usize"##, 5515 description: r##"Checks for casts of function pointers to something other than usize"##,
4969 }, 5516 },
4970 LintCompletion { 5517 Lint {
4971 label: "clippy::fn_to_numeric_cast_with_truncation", 5518 label: "clippy::fn_to_numeric_cast_with_truncation",
4972 description: r##"Checks for casts of a function pointer to a numeric type not wide enough to\nstore address."##, 5519 description: r##"Checks for casts of a function pointer to a numeric type not wide enough to\nstore address."##,
4973 }, 5520 },
4974 LintCompletion { 5521 Lint {
4975 label: "clippy::for_kv_map", 5522 label: "clippy::for_kv_map",
4976 description: r##"Checks for iterating a map (`HashMap` or `BTreeMap`) and\nignoring either the keys or values."##, 5523 description: r##"Checks for iterating a map (`HashMap` or `BTreeMap`) and\nignoring either the keys or values."##,
4977 }, 5524 },
4978 LintCompletion { 5525 Lint {
4979 label: "clippy::for_loops_over_fallibles", 5526 label: "clippy::for_loops_over_fallibles",
4980 description: r##"Checks for `for` loops over `Option` or `Result` values."##, 5527 description: r##"Checks for `for` loops over `Option` or `Result` values."##,
4981 }, 5528 },
4982 LintCompletion { 5529 Lint {
4983 label: "clippy::forget_copy", 5530 label: "clippy::forget_copy",
4984 description: r##"Checks for calls to `std::mem::forget` with a value that\nderives the Copy trait"##, 5531 description: r##"Checks for calls to `std::mem::forget` with a value that\nderives the Copy trait"##,
4985 }, 5532 },
4986 LintCompletion { 5533 Lint {
4987 label: "clippy::forget_ref", 5534 label: "clippy::forget_ref",
4988 description: r##"Checks for calls to `std::mem::forget` with a reference\ninstead of an owned value."##, 5535 description: r##"Checks for calls to `std::mem::forget` with a reference\ninstead of an owned value."##,
4989 }, 5536 },
4990 LintCompletion { 5537 Lint {
4991 label: "clippy::from_iter_instead_of_collect", 5538 label: "clippy::from_iter_instead_of_collect",
4992 description: r##"Checks for `from_iter()` function calls on types that implement the `FromIterator`\ntrait."##, 5539 description: r##"Checks for `from_iter()` function calls on types that implement the `FromIterator`\ntrait."##,
4993 }, 5540 },
4994 LintCompletion { 5541 Lint {
4995 label: "clippy::from_over_into", 5542 label: "clippy::from_over_into",
4996 description: r##"Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead."##, 5543 description: r##"Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead."##,
4997 }, 5544 },
4998 LintCompletion { 5545 Lint {
4999 label: "clippy::from_str_radix_10", 5546 label: "clippy::from_str_radix_10",
5000 description: r##"Checks for function invocations of the form `primitive::from_str_radix(s, 10)`"##, 5547 description: r##"Checks for function invocations of the form `primitive::from_str_radix(s, 10)`"##,
5001 }, 5548 },
5002 LintCompletion { 5549 Lint {
5003 label: "clippy::future_not_send", 5550 label: "clippy::future_not_send",
5004 description: r##"This lint requires Future implementations returned from\nfunctions and methods to implement the `Send` marker trait. It is mostly\nused by library authors (public and internal) that target an audience where\nmultithreaded executors are likely to be used for running these Futures."##, 5551 description: r##"This lint requires Future implementations returned from\nfunctions and methods to implement the `Send` marker trait. It is mostly\nused by library authors (public and internal) that target an audience where\nmultithreaded executors are likely to be used for running these Futures."##,
5005 }, 5552 },
5006 LintCompletion { 5553 Lint {
5007 label: "clippy::get_last_with_len", 5554 label: "clippy::get_last_with_len",
5008 description: r##"Checks for using `x.get(x.len() - 1)` instead of\n`x.last()`."##, 5555 description: r##"Checks for using `x.get(x.len() - 1)` instead of\n`x.last()`."##,
5009 }, 5556 },
5010 LintCompletion { 5557 Lint {
5011 label: "clippy::get_unwrap", 5558 label: "clippy::get_unwrap",
5012 description: r##"Checks for use of `.get().unwrap()` (or\n`.get_mut().unwrap`) on a standard library type which implements `Index`"##, 5559 description: r##"Checks for use of `.get().unwrap()` (or\n`.get_mut().unwrap`) on a standard library type which implements `Index`"##,
5013 }, 5560 },
5014 LintCompletion { 5561 Lint {
5015 label: "clippy::identity_op", 5562 label: "clippy::identity_op",
5016 description: r##"Checks for identity operations, e.g., `x + 0`."##, 5563 description: r##"Checks for identity operations, e.g., `x + 0`."##,
5017 }, 5564 },
5018 LintCompletion { 5565 Lint {
5019 label: "clippy::if_let_mutex", 5566 label: "clippy::if_let_mutex",
5020 description: r##"Checks for `Mutex::lock` calls in `if let` expression\nwith lock calls in any of the else blocks."##, 5567 description: r##"Checks for `Mutex::lock` calls in `if let` expression\nwith lock calls in any of the else blocks."##,
5021 }, 5568 },
5022 LintCompletion { 5569 Lint {
5023 label: "clippy::if_let_redundant_pattern_matching", 5570 label: "clippy::if_let_redundant_pattern_matching",
5024 description: r##"Nothing. This lint has been deprecated."##, 5571 description: r##"Nothing. This lint has been deprecated."##,
5025 }, 5572 },
5026 LintCompletion { 5573 Lint {
5027 label: "clippy::if_let_some_result", 5574 label: "clippy::if_let_some_result",
5028 description: r##"* Checks for unnecessary `ok()` in if let."##, 5575 description: r##"* Checks for unnecessary `ok()` in if let."##,
5029 }, 5576 },
5030 LintCompletion { 5577 Lint {
5031 label: "clippy::if_not_else", 5578 label: "clippy::if_not_else",
5032 description: r##"Checks for usage of `!` or `!=` in an if condition with an\nelse branch."##, 5579 description: r##"Checks for usage of `!` or `!=` in an if condition with an\nelse branch."##,
5033 }, 5580 },
5034 LintCompletion { 5581 Lint {
5035 label: "clippy::if_same_then_else", 5582 label: "clippy::if_same_then_else",
5036 description: r##"Checks for `if/else` with the same body as the *then* part\nand the *else* part."##, 5583 description: r##"Checks for `if/else` with the same body as the *then* part\nand the *else* part."##,
5037 }, 5584 },
5038 LintCompletion { 5585 Lint {
5586 label: "clippy::if_then_some_else_none",
5587 description: r##"Checks for if-else that could be written to `bool::then`."##,
5588 },
5589 Lint {
5039 label: "clippy::ifs_same_cond", 5590 label: "clippy::ifs_same_cond",
5040 description: r##"Checks for consecutive `if`s with the same condition."##, 5591 description: r##"Checks for consecutive `if`s with the same condition."##,
5041 }, 5592 },
5042 LintCompletion { 5593 Lint {
5043 label: "clippy::implicit_clone", 5594 label: "clippy::implicit_clone",
5044 description: r##"Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer."##, 5595 description: r##"Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer."##,
5045 }, 5596 },
5046 LintCompletion { 5597 Lint {
5047 label: "clippy::implicit_hasher", 5598 label: "clippy::implicit_hasher",
5048 description: r##"Checks for public `impl` or `fn` missing generalization\nover different hashers and implicitly defaulting to the default hashing\nalgorithm (`SipHash`)."##, 5599 description: r##"Checks for public `impl` or `fn` missing generalization\nover different hashers and implicitly defaulting to the default hashing\nalgorithm (`SipHash`)."##,
5049 }, 5600 },
5050 LintCompletion { 5601 Lint {
5051 label: "clippy::implicit_return", 5602 label: "clippy::implicit_return",
5052 description: r##"Checks for missing return statements at the end of a block."##, 5603 description: r##"Checks for missing return statements at the end of a block."##,
5053 }, 5604 },
5054 LintCompletion { 5605 Lint {
5055 label: "clippy::implicit_saturating_sub", 5606 label: "clippy::implicit_saturating_sub",
5056 description: r##"Checks for implicit saturating subtraction."##, 5607 description: r##"Checks for implicit saturating subtraction."##,
5057 }, 5608 },
5058 LintCompletion { 5609 Lint {
5059 label: "clippy::imprecise_flops", 5610 label: "clippy::imprecise_flops",
5060 description: r##"Looks for floating-point expressions that\ncan be expressed using built-in methods to improve accuracy\nat the cost of performance."##, 5611 description: r##"Looks for floating-point expressions that\ncan be expressed using built-in methods to improve accuracy\nat the cost of performance."##,
5061 }, 5612 },
5062 LintCompletion { 5613 Lint {
5063 label: "clippy::inconsistent_digit_grouping", 5614 label: "clippy::inconsistent_digit_grouping",
5064 description: r##"Warns if an integral or floating-point constant is\ngrouped inconsistently with underscores."##, 5615 description: r##"Warns if an integral or floating-point constant is\ngrouped inconsistently with underscores."##,
5065 }, 5616 },
5066 LintCompletion { 5617 Lint {
5067 label: "clippy::inconsistent_struct_constructor", 5618 label: "clippy::inconsistent_struct_constructor",
5068 description: r##"Checks for struct constructors where the order of the field init\nshorthand in the constructor is inconsistent with the order in the struct definition."##, 5619 description: r##"Checks for struct constructors where all fields are shorthand and\nthe order of the field init shorthand in the constructor is inconsistent\nwith the order in the struct definition."##,
5069 }, 5620 },
5070 LintCompletion { 5621 Lint {
5071 label: "clippy::indexing_slicing", 5622 label: "clippy::indexing_slicing",
5072 description: r##"Checks for usage of indexing or slicing. Arrays are special cases, this lint\ndoes report on arrays if we can tell that slicing operations are in bounds and does not\nlint on constant `usize` indexing on arrays because that is handled by rustc's `const_err` lint."##, 5623 description: r##"Checks for usage of indexing or slicing. Arrays are special cases, this lint\ndoes report on arrays if we can tell that slicing operations are in bounds and does not\nlint on constant `usize` indexing on arrays because that is handled by rustc's `const_err` lint."##,
5073 }, 5624 },
5074 LintCompletion { 5625 Lint {
5075 label: "clippy::ineffective_bit_mask", 5626 label: "clippy::ineffective_bit_mask",
5076 description: r##"Checks for bit masks in comparisons which can be removed\nwithout changing the outcome. The basic structure can be seen in the\nfollowing table:\n\n|Comparison| Bit Op |Example |equals |\n|----------|---------|-----------|-------|\n|`>` / `<=`|`|` / `^`|`x | 2 > 3`|`x > 3`|\n|`<` / `>=`|`|` / `^`|`x ^ 1 < 4`|`x < 4`|"##, 5627 description: r##"Checks for bit masks in comparisons which can be removed\nwithout changing the outcome. The basic structure can be seen in the\nfollowing table:\n\n|Comparison| Bit Op |Example |equals |\n|----------|---------|-----------|-------|\n|`>` / `<=`|`|` / `^`|`x | 2 > 3`|`x > 3`|\n|`<` / `>=`|`|` / `^`|`x ^ 1 < 4`|`x < 4`|"##,
5077 }, 5628 },
5078 LintCompletion { 5629 Lint {
5079 label: "clippy::inefficient_to_string", 5630 label: "clippy::inefficient_to_string",
5080 description: r##"Checks for usage of `.to_string()` on an `&&T` where\n`T` implements `ToString` directly (like `&&str` or `&&String`)."##, 5631 description: r##"Checks for usage of `.to_string()` on an `&&T` where\n`T` implements `ToString` directly (like `&&str` or `&&String`)."##,
5081 }, 5632 },
5082 LintCompletion { 5633 Lint {
5083 label: "clippy::infallible_destructuring_match", 5634 label: "clippy::infallible_destructuring_match",
5084 description: r##"Checks for matches being used to destructure a single-variant enum\nor tuple struct where a `let` will suffice."##, 5635 description: r##"Checks for matches being used to destructure a single-variant enum\nor tuple struct where a `let` will suffice."##,
5085 }, 5636 },
5086 LintCompletion { 5637 Lint {
5087 label: "clippy::infinite_iter", 5638 label: "clippy::infinite_iter",
5088 description: r##"Checks for iteration that is guaranteed to be infinite."##, 5639 description: r##"Checks for iteration that is guaranteed to be infinite."##,
5089 }, 5640 },
5090 LintCompletion { 5641 Lint {
5091 label: "clippy::inherent_to_string", 5642 label: "clippy::inherent_to_string",
5092 description: r##"Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`."##, 5643 description: r##"Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`."##,
5093 }, 5644 },
5094 LintCompletion { 5645 Lint {
5095 label: "clippy::inherent_to_string_shadow_display", 5646 label: "clippy::inherent_to_string_shadow_display",
5096 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."##, 5647 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."##,
5097 }, 5648 },
5098 LintCompletion { 5649 Lint {
5099 label: "clippy::inline_always", 5650 label: "clippy::inline_always",
5100 description: r##"Checks for items annotated with `#[inline(always)]`,\nunless the annotated function is empty or simply panics."##, 5651 description: r##"Checks for items annotated with `#[inline(always)]`,\nunless the annotated function is empty or simply panics."##,
5101 }, 5652 },
5102 LintCompletion { 5653 Lint {
5103 label: "clippy::inline_asm_x86_att_syntax", 5654 label: "clippy::inline_asm_x86_att_syntax",
5104 description: r##"Checks for usage of AT&T x86 assembly syntax."##, 5655 description: r##"Checks for usage of AT&T x86 assembly syntax."##,
5105 }, 5656 },
5106 LintCompletion { 5657 Lint {
5107 label: "clippy::inline_asm_x86_intel_syntax", 5658 label: "clippy::inline_asm_x86_intel_syntax",
5108 description: r##"Checks for usage of Intel x86 assembly syntax."##, 5659 description: r##"Checks for usage of Intel x86 assembly syntax."##,
5109 }, 5660 },
5110 LintCompletion { 5661 Lint {
5111 label: "clippy::inline_fn_without_body", 5662 label: "clippy::inline_fn_without_body",
5112 description: r##"Checks for `#[inline]` on trait methods without bodies"##, 5663 description: r##"Checks for `#[inline]` on trait methods without bodies"##,
5113 }, 5664 },
5114 LintCompletion { 5665 Lint {
5115 label: "clippy::inspect_for_each", 5666 label: "clippy::inspect_for_each",
5116 description: r##"Checks for usage of `inspect().for_each()`."##, 5667 description: r##"Checks for usage of `inspect().for_each()`."##,
5117 }, 5668 },
5118 LintCompletion { 5669 Lint {
5119 label: "clippy::int_plus_one", 5670 label: "clippy::int_plus_one",
5120 description: r##"Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block"##, 5671 description: r##"Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block"##,
5121 }, 5672 },
5122 LintCompletion { 5673 Lint {
5123 label: "clippy::integer_arithmetic", 5674 label: "clippy::integer_arithmetic",
5124 description: r##"Checks for integer arithmetic operations which could overflow or panic.\n\nSpecifically, checks for any operators (`+`, `-`, `*`, `<<`, etc) which are capable\nof overflowing according to the [Rust\nReference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow),\nor which can panic (`/`, `%`). No bounds analysis or sophisticated reasoning is\nattempted."##, 5675 description: r##"Checks for integer arithmetic operations which could overflow or panic.\n\nSpecifically, checks for any operators (`+`, `-`, `*`, `<<`, etc) which are capable\nof overflowing according to the [Rust\nReference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow),\nor which can panic (`/`, `%`). No bounds analysis or sophisticated reasoning is\nattempted."##,
5125 }, 5676 },
5126 LintCompletion { 5677 Lint { label: "clippy::integer_division", description: r##"Checks for division of integers"## },
5127 label: "clippy::integer_division", 5678 Lint {
5128 description: r##"Checks for division of integers"##,
5129 },
5130 LintCompletion {
5131 label: "clippy::into_iter_on_array",
5132 description: r##"Nothing. This lint has been deprecated."##,
5133 },
5134 LintCompletion {
5135 label: "clippy::into_iter_on_ref", 5679 label: "clippy::into_iter_on_ref",
5136 description: r##"Checks for `into_iter` calls on references which should be replaced by `iter`\nor `iter_mut`."##, 5680 description: r##"Checks for `into_iter` calls on references which should be replaced by `iter`\nor `iter_mut`."##,
5137 }, 5681 },
5138 LintCompletion { 5682 Lint {
5139 label: "clippy::invalid_atomic_ordering", 5683 label: "clippy::invalid_atomic_ordering",
5140 description: r##"Checks for usage of invalid atomic\nordering in atomic loads/stores/exchanges/updates and\nmemory fences."##, 5684 description: r##"Checks for usage of invalid atomic\nordering in atomic loads/stores/exchanges/updates and\nmemory fences."##,
5141 }, 5685 },
5142 LintCompletion { 5686 Lint {
5143 label: "clippy::invalid_ref", 5687 label: "clippy::invalid_null_ptr_usage",
5144 description: r##"Nothing. This lint has been deprecated."##, 5688 description: r##"This lint checks for invalid usages of `ptr::null`."##,
5145 }, 5689 },
5146 LintCompletion { 5690 Lint {
5147 label: "clippy::invalid_regex", 5691 label: "clippy::invalid_regex",
5148 description: r##"Checks [regex](https://crates.io/crates/regex) creation\n(with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`) for correct\nregex syntax."##, 5692 description: r##"Checks [regex](https://crates.io/crates/regex) creation\n(with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`) for correct\nregex syntax."##,
5149 }, 5693 },
5150 LintCompletion { 5694 Lint {
5151 label: "clippy::invalid_upcast_comparisons", 5695 label: "clippy::invalid_upcast_comparisons",
5152 description: r##"Checks for comparisons where the relation is always either\ntrue or false, but where one side has been upcast so that the comparison is\nnecessary. Only integer types are checked."##, 5696 description: r##"Checks for comparisons where the relation is always either\ntrue or false, but where one side has been upcast so that the comparison is\nnecessary. Only integer types are checked."##,
5153 }, 5697 },
5154 LintCompletion { 5698 Lint {
5155 label: "clippy::invisible_characters", 5699 label: "clippy::invisible_characters",
5156 description: r##"Checks for invisible Unicode characters in the code."##, 5700 description: r##"Checks for invisible Unicode characters in the code."##,
5157 }, 5701 },
5158 LintCompletion { 5702 Lint {
5159 label: "clippy::items_after_statements", 5703 label: "clippy::items_after_statements",
5160 description: r##"Checks for items declared after some statement in a block."##, 5704 description: r##"Checks for items declared after some statement in a block."##,
5161 }, 5705 },
5162 LintCompletion { 5706 Lint {
5163 label: "clippy::iter_cloned_collect", 5707 label: "clippy::iter_cloned_collect",
5164 description: r##"Checks for the use of `.cloned().collect()` on slice to\ncreate a `Vec`."##, 5708 description: r##"Checks for the use of `.cloned().collect()` on slice to\ncreate a `Vec`."##,
5165 }, 5709 },
5166 LintCompletion { 5710 Lint {
5167 label: "clippy::iter_next_loop", 5711 label: "clippy::iter_count",
5168 description: r##"Checks for loops on `x.next()`."##, 5712 description: r##"Checks for the use of `.iter().count()`."##,
5169 }, 5713 },
5170 LintCompletion { 5714 Lint { label: "clippy::iter_next_loop", description: r##"Checks for loops on `x.next()`."## },
5715 Lint {
5171 label: "clippy::iter_next_slice", 5716 label: "clippy::iter_next_slice",
5172 description: r##"Checks for usage of `iter().next()` on a Slice or an Array"##, 5717 description: r##"Checks for usage of `iter().next()` on a Slice or an Array"##,
5173 }, 5718 },
5174 LintCompletion { 5719 Lint {
5175 label: "clippy::iter_nth", 5720 label: "clippy::iter_nth",
5176 description: r##"Checks for use of `.iter().nth()` (and the related\n`.iter_mut().nth()`) on standard library types with O(1) element access."##, 5721 description: r##"Checks for use of `.iter().nth()` (and the related\n`.iter_mut().nth()`) on standard library types with O(1) element access."##,
5177 }, 5722 },
5178 LintCompletion { 5723 Lint {
5179 label: "clippy::iter_nth_zero", 5724 label: "clippy::iter_nth_zero",
5180 description: r##"Checks for the use of `iter.nth(0)`."##, 5725 description: r##"Checks for the use of `iter.nth(0)`."##,
5181 }, 5726 },
5182 LintCompletion { 5727 Lint {
5183 label: "clippy::iter_skip_next", 5728 label: "clippy::iter_skip_next",
5184 description: r##"Checks for use of `.skip(x).next()` on iterators."##, 5729 description: r##"Checks for use of `.skip(x).next()` on iterators."##,
5185 }, 5730 },
5186 LintCompletion { 5731 Lint {
5187 label: "clippy::iterator_step_by_zero", 5732 label: "clippy::iterator_step_by_zero",
5188 description: r##"Checks for calling `.step_by(0)` on iterators which panics."##, 5733 description: r##"Checks for calling `.step_by(0)` on iterators which panics."##,
5189 }, 5734 },
5190 LintCompletion { 5735 Lint {
5191 label: "clippy::just_underscores_and_digits", 5736 label: "clippy::just_underscores_and_digits",
5192 description: r##"Checks if you have variables whose name consists of just\nunderscores and digits."##, 5737 description: r##"Checks if you have variables whose name consists of just\nunderscores and digits."##,
5193 }, 5738 },
5194 LintCompletion { 5739 Lint {
5195 label: "clippy::large_const_arrays", 5740 label: "clippy::large_const_arrays",
5196 description: r##"Checks for large `const` arrays that should\nbe defined as `static` instead."##, 5741 description: r##"Checks for large `const` arrays that should\nbe defined as `static` instead."##,
5197 }, 5742 },
5198 LintCompletion { 5743 Lint {
5199 label: "clippy::large_digit_groups", 5744 label: "clippy::large_digit_groups",
5200 description: r##"Warns if the digits of an integral or floating-point\nconstant are grouped into groups that\nare too large."##, 5745 description: r##"Warns if the digits of an integral or floating-point\nconstant are grouped into groups that\nare too large."##,
5201 }, 5746 },
5202 LintCompletion { 5747 Lint {
5203 label: "clippy::large_enum_variant", 5748 label: "clippy::large_enum_variant",
5204 description: r##"Checks for large size differences between variants on\n`enum`s."##, 5749 description: r##"Checks for large size differences between variants on\n`enum`s."##,
5205 }, 5750 },
5206 LintCompletion { 5751 Lint {
5207 label: "clippy::large_stack_arrays", 5752 label: "clippy::large_stack_arrays",
5208 description: r##"Checks for local arrays that may be too large."##, 5753 description: r##"Checks for local arrays that may be too large."##,
5209 }, 5754 },
5210 LintCompletion { 5755 Lint {
5211 label: "clippy::large_types_passed_by_value", 5756 label: "clippy::large_types_passed_by_value",
5212 description: r##"Checks for functions taking arguments by value, where\nthe argument type is `Copy` and large enough to be worth considering\npassing by reference. Does not trigger if the function is being exported,\nbecause that might induce API breakage, if the parameter is declared as mutable,\nor if the argument is a `self`."##, 5757 description: r##"Checks for functions taking arguments by value, where\nthe argument type is `Copy` and large enough to be worth considering\npassing by reference. Does not trigger if the function is being exported,\nbecause that might induce API breakage, if the parameter is declared as mutable,\nor if the argument is a `self`."##,
5213 }, 5758 },
5214 LintCompletion { 5759 Lint {
5215 label: "clippy::len_without_is_empty", 5760 label: "clippy::len_without_is_empty",
5216 description: r##"Checks for items that implement `.len()` but not\n`.is_empty()`."##, 5761 description: r##"Checks for items that implement `.len()` but not\n`.is_empty()`."##,
5217 }, 5762 },
5218 LintCompletion { 5763 Lint {
5219 label: "clippy::len_zero", 5764 label: "clippy::len_zero",
5220 description: r##"Checks for getting the length of something via `.len()`\njust to compare to zero, and suggests using `.is_empty()` where applicable."##, 5765 description: r##"Checks for getting the length of something via `.len()`\njust to compare to zero, and suggests using `.is_empty()` where applicable."##,
5221 }, 5766 },
5222 LintCompletion { 5767 Lint {
5223 label: "clippy::let_and_return", 5768 label: "clippy::let_and_return",
5224 description: r##"Checks for `let`-bindings, which are subsequently\nreturned."##, 5769 description: r##"Checks for `let`-bindings, which are subsequently\nreturned."##,
5225 }, 5770 },
5226 LintCompletion { 5771 Lint {
5227 label: "clippy::let_underscore_drop", 5772 label: "clippy::let_underscore_drop",
5228 description: r##"Checks for `let _ = <expr>`\nwhere expr has a type that implements `Drop`"##, 5773 description: r##"Checks for `let _ = <expr>`\nwhere expr has a type that implements `Drop`"##,
5229 }, 5774 },
5230 LintCompletion { 5775 Lint {
5231 label: "clippy::let_underscore_lock", 5776 label: "clippy::let_underscore_lock",
5232 description: r##"Checks for `let _ = sync_lock`"##, 5777 description: r##"Checks for `let _ = sync_lock`"##,
5233 }, 5778 },
5234 LintCompletion { 5779 Lint {
5235 label: "clippy::let_underscore_must_use", 5780 label: "clippy::let_underscore_must_use",
5236 description: r##"Checks for `let _ = <expr>`\nwhere expr is #[must_use]"##, 5781 description: r##"Checks for `let _ = <expr>`\nwhere expr is #[must_use]"##,
5237 }, 5782 },
5238 LintCompletion { 5783 Lint { label: "clippy::let_unit_value", description: r##"Checks for binding a unit value."## },
5239 label: "clippy::let_unit_value", 5784 Lint {
5240 description: r##"Checks for binding a unit value."##,
5241 },
5242 LintCompletion {
5243 label: "clippy::linkedlist", 5785 label: "clippy::linkedlist",
5244 description: r##"Checks for usage of any `LinkedList`, suggesting to use a\n`Vec` or a `VecDeque` (formerly called `RingBuf`)."##, 5786 description: r##"Checks for usage of any `LinkedList`, suggesting to use a\n`Vec` or a `VecDeque` (formerly called `RingBuf`)."##,
5245 }, 5787 },
5246 LintCompletion { 5788 Lint {
5247 label: "clippy::logic_bug", 5789 label: "clippy::logic_bug",
5248 description: r##"Checks for boolean expressions that contain terminals that\ncan be eliminated."##, 5790 description: r##"Checks for boolean expressions that contain terminals that\ncan be eliminated."##,
5249 }, 5791 },
5250 LintCompletion { 5792 Lint {
5251 label: "clippy::lossy_float_literal", 5793 label: "clippy::lossy_float_literal",
5252 description: r##"Checks for whole number float literals that\ncannot be represented as the underlying type without loss."##, 5794 description: r##"Checks for whole number float literals that\ncannot be represented as the underlying type without loss."##,
5253 }, 5795 },
5254 LintCompletion { 5796 Lint {
5255 label: "clippy::macro_use_imports", 5797 label: "clippy::macro_use_imports",
5256 description: r##"Checks for `#[macro_use] use...`."##, 5798 description: r##"Checks for `#[macro_use] use...`."##,
5257 }, 5799 },
5258 LintCompletion { 5800 Lint {
5259 label: "clippy::main_recursion", 5801 label: "clippy::main_recursion",
5260 description: r##"Checks for recursion using the entrypoint."##, 5802 description: r##"Checks for recursion using the entrypoint."##,
5261 }, 5803 },
5262 LintCompletion { 5804 Lint {
5263 label: "clippy::manual_async_fn", 5805 label: "clippy::manual_async_fn",
5264 description: r##"It checks for manual implementations of `async` functions."##, 5806 description: r##"It checks for manual implementations of `async` functions."##,
5265 }, 5807 },
5266 LintCompletion { 5808 Lint {
5267 label: "clippy::manual_filter_map", 5809 label: "clippy::manual_filter_map",
5268 description: r##"Checks for usage of `_.filter(_).map(_)` that can be written more simply\nas `filter_map(_)`."##, 5810 description: r##"Checks for usage of `_.filter(_).map(_)` that can be written more simply\nas `filter_map(_)`."##,
5269 }, 5811 },
5270 LintCompletion { 5812 Lint {
5271 label: "clippy::manual_find_map", 5813 label: "clippy::manual_find_map",
5272 description: r##"Checks for usage of `_.find(_).map(_)` that can be written more simply\nas `find_map(_)`."##, 5814 description: r##"Checks for usage of `_.find(_).map(_)` that can be written more simply\nas `find_map(_)`."##,
5273 }, 5815 },
5274 LintCompletion { 5816 Lint {
5275 label: "clippy::manual_flatten", 5817 label: "clippy::manual_flatten",
5276 description: r##"Check for unnecessary `if let` usage in a for loop\nwhere only the `Some` or `Ok` variant of the iterator element is used."##, 5818 description: r##"Check for unnecessary `if let` usage in a for loop\nwhere only the `Some` or `Ok` variant of the iterator element is used."##,
5277 }, 5819 },
5278 LintCompletion { 5820 Lint {
5279 label: "clippy::manual_map", 5821 label: "clippy::manual_map",
5280 description: r##"Checks for usages of `match` which could be implemented using `map`"##, 5822 description: r##"Checks for usages of `match` which could be implemented using `map`"##,
5281 }, 5823 },
5282 LintCompletion { 5824 Lint {
5283 label: "clippy::manual_memcpy", 5825 label: "clippy::manual_memcpy",
5284 description: r##"Checks for for-loops that manually copy items between\nslices that could be optimized by having a memcpy."##, 5826 description: r##"Checks for for-loops that manually copy items between\nslices that could be optimized by having a memcpy."##,
5285 }, 5827 },
5286 LintCompletion { 5828 Lint {
5287 label: "clippy::manual_non_exhaustive", 5829 label: "clippy::manual_non_exhaustive",
5288 description: r##"Checks for manual implementations of the non-exhaustive pattern."##, 5830 description: r##"Checks for manual implementations of the non-exhaustive pattern."##,
5289 }, 5831 },
5290 LintCompletion { 5832 Lint {
5291 label: "clippy::manual_ok_or", 5833 label: "clippy::manual_ok_or",
5292 description: r##"Finds patterns that reimplement `Option::ok_or`."##, 5834 description: r##"Finds patterns that reimplement `Option::ok_or`."##,
5293 }, 5835 },
5294 LintCompletion { 5836 Lint {
5295 label: "clippy::manual_range_contains", 5837 label: "clippy::manual_range_contains",
5296 description: r##"Checks for expressions like `x >= 3 && x < 8` that could\nbe more readably expressed as `(3..8).contains(x)`."##, 5838 description: r##"Checks for expressions like `x >= 3 && x < 8` that could\nbe more readably expressed as `(3..8).contains(x)`."##,
5297 }, 5839 },
5298 LintCompletion { 5840 Lint {
5299 label: "clippy::manual_saturating_arithmetic", 5841 label: "clippy::manual_saturating_arithmetic",
5300 description: r##"Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`."##, 5842 description: r##"Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`."##,
5301 }, 5843 },
5302 LintCompletion { 5844 Lint {
5845 label: "clippy::manual_str_repeat",
5846 description: r##"Checks for manual implementations of `str::repeat`"##,
5847 },
5848 Lint {
5303 label: "clippy::manual_strip", 5849 label: "clippy::manual_strip",
5304 description: r##"Suggests using `strip_{prefix,suffix}` over `str::{starts,ends}_with` and slicing using\nthe pattern's length."##, 5850 description: r##"Suggests using `strip_{prefix,suffix}` over `str::{starts,ends}_with` and slicing using\nthe pattern's length."##,
5305 }, 5851 },
5306 LintCompletion { 5852 Lint { label: "clippy::manual_swap", description: r##"Checks for manual swapping."## },
5307 label: "clippy::manual_swap", 5853 Lint {
5308 description: r##"Checks for manual swapping."##,
5309 },
5310 LintCompletion {
5311 label: "clippy::manual_unwrap_or", 5854 label: "clippy::manual_unwrap_or",
5312 description: r##"Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`."##, 5855 description: r##"Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`."##,
5313 }, 5856 },
5314 LintCompletion { 5857 Lint {
5315 label: "clippy::many_single_char_names", 5858 label: "clippy::many_single_char_names",
5316 description: r##"Checks for too many variables whose name consists of a\nsingle character."##, 5859 description: r##"Checks for too many variables whose name consists of a\nsingle character."##,
5317 }, 5860 },
5318 LintCompletion { 5861 Lint {
5319 label: "clippy::map_clone", 5862 label: "clippy::map_clone",
5320 description: r##"Checks for usage of `map(|x| x.clone())` or\ndereferencing closures for `Copy` types, on `Iterator` or `Option`,\nand suggests `cloned()` or `copied()` instead"##, 5863 description: r##"Checks for usage of `map(|x| x.clone())` or\ndereferencing closures for `Copy` types, on `Iterator` or `Option`,\nand suggests `cloned()` or `copied()` instead"##,
5321 }, 5864 },
5322 LintCompletion { 5865 Lint {
5323 label: "clippy::map_collect_result_unit", 5866 label: "clippy::map_collect_result_unit",
5324 description: r##"Checks for usage of `_.map(_).collect::<Result<(), _>()`."##, 5867 description: r##"Checks for usage of `_.map(_).collect::<Result<(), _>()`."##,
5325 }, 5868 },
5326 LintCompletion { 5869 Lint {
5327 label: "clippy::map_entry", 5870 label: "clippy::map_entry",
5328 description: r##"Checks for uses of `contains_key` + `insert` on `HashMap`\nor `BTreeMap`."##, 5871 description: r##"Checks for uses of `contains_key` + `insert` on `HashMap`\nor `BTreeMap`."##,
5329 }, 5872 },
5330 LintCompletion { 5873 Lint {
5331 label: "clippy::map_err_ignore", 5874 label: "clippy::map_err_ignore",
5332 description: r##"Checks for instances of `map_err(|_| Some::Enum)`"##, 5875 description: r##"Checks for instances of `map_err(|_| Some::Enum)`"##,
5333 }, 5876 },
5334 LintCompletion { 5877 Lint {
5335 label: "clippy::map_flatten", 5878 label: "clippy::map_flatten",
5336 description: r##"Checks for usage of `_.map(_).flatten(_)`,"##, 5879 description: r##"Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option`"##,
5337 }, 5880 },
5338 LintCompletion { 5881 Lint {
5339 label: "clippy::map_identity", 5882 label: "clippy::map_identity",
5340 description: r##"Checks for instances of `map(f)` where `f` is the identity function."##, 5883 description: r##"Checks for instances of `map(f)` where `f` is the identity function."##,
5341 }, 5884 },
5342 LintCompletion { 5885 Lint {
5343 label: "clippy::map_unwrap_or", 5886 label: "clippy::map_unwrap_or",
5344 description: r##"Checks for usage of `option.map(_).unwrap_or(_)` or `option.map(_).unwrap_or_else(_)` or\n`result.map(_).unwrap_or_else(_)`."##, 5887 description: r##"Checks for usage of `option.map(_).unwrap_or(_)` or `option.map(_).unwrap_or_else(_)` or\n`result.map(_).unwrap_or_else(_)`."##,
5345 }, 5888 },
5346 LintCompletion { 5889 Lint {
5347 label: "clippy::match_as_ref", 5890 label: "clippy::match_as_ref",
5348 description: r##"Checks for match which is used to add a reference to an\n`Option` value."##, 5891 description: r##"Checks for match which is used to add a reference to an\n`Option` value."##,
5349 }, 5892 },
5350 LintCompletion { 5893 Lint {
5351 label: "clippy::match_bool", 5894 label: "clippy::match_bool",
5352 description: r##"Checks for matches where match expression is a `bool`. It\nsuggests to replace the expression with an `if...else` block."##, 5895 description: r##"Checks for matches where match expression is a `bool`. It\nsuggests to replace the expression with an `if...else` block."##,
5353 }, 5896 },
5354 LintCompletion { 5897 Lint {
5355 label: "clippy::match_like_matches_macro", 5898 label: "clippy::match_like_matches_macro",
5356 description: r##"Checks for `match` or `if let` expressions producing a\n`bool` that could be written using `matches!`"##, 5899 description: r##"Checks for `match` or `if let` expressions producing a\n`bool` that could be written using `matches!`"##,
5357 }, 5900 },
5358 LintCompletion { 5901 Lint {
5359 label: "clippy::match_on_vec_items", 5902 label: "clippy::match_on_vec_items",
5360 description: r##"Checks for `match vec[idx]` or `match vec[n..m]`."##, 5903 description: r##"Checks for `match vec[idx]` or `match vec[n..m]`."##,
5361 }, 5904 },
5362 LintCompletion { 5905 Lint {
5363 label: "clippy::match_overlapping_arm", 5906 label: "clippy::match_overlapping_arm",
5364 description: r##"Checks for overlapping match arms."##, 5907 description: r##"Checks for overlapping match arms."##,
5365 }, 5908 },
5366 LintCompletion { 5909 Lint {
5367 label: "clippy::match_ref_pats", 5910 label: "clippy::match_ref_pats",
5368 description: r##"Checks for matches where all arms match a reference,\nsuggesting to remove the reference and deref the matched expression\ninstead. It also checks for `if let &foo = bar` blocks."##, 5911 description: r##"Checks for matches where all arms match a reference,\nsuggesting to remove the reference and deref the matched expression\ninstead. It also checks for `if let &foo = bar` blocks."##,
5369 }, 5912 },
5370 LintCompletion { 5913 Lint {
5371 label: "clippy::match_same_arms", 5914 label: "clippy::match_same_arms",
5372 description: r##"Checks for `match` with identical arm bodies."##, 5915 description: r##"Checks for `match` with identical arm bodies."##,
5373 }, 5916 },
5374 LintCompletion { 5917 Lint {
5375 label: "clippy::match_single_binding", 5918 label: "clippy::match_single_binding",
5376 description: r##"Checks for useless match that binds to only one value."##, 5919 description: r##"Checks for useless match that binds to only one value."##,
5377 }, 5920 },
5378 LintCompletion { 5921 Lint {
5379 label: "clippy::match_wild_err_arm", 5922 label: "clippy::match_wild_err_arm",
5380 description: r##"Checks for arm which matches all errors with `Err(_)`\nand take drastic actions like `panic!`."##, 5923 description: r##"Checks for arm which matches all errors with `Err(_)`\nand take drastic actions like `panic!`."##,
5381 }, 5924 },
5382 LintCompletion { 5925 Lint {
5383 label: "clippy::match_wildcard_for_single_variants", 5926 label: "clippy::match_wildcard_for_single_variants",
5384 description: r##"Checks for wildcard enum matches for a single variant."##, 5927 description: r##"Checks for wildcard enum matches for a single variant."##,
5385 }, 5928 },
5386 LintCompletion { 5929 Lint {
5387 label: "clippy::maybe_infinite_iter", 5930 label: "clippy::maybe_infinite_iter",
5388 description: r##"Checks for iteration that may be infinite."##, 5931 description: r##"Checks for iteration that may be infinite."##,
5389 }, 5932 },
5390 LintCompletion { 5933 Lint {
5391 label: "clippy::mem_discriminant_non_enum", 5934 label: "clippy::mem_discriminant_non_enum",
5392 description: r##"Checks for calls of `mem::discriminant()` on a non-enum type."##, 5935 description: r##"Checks for calls of `mem::discriminant()` on a non-enum type."##,
5393 }, 5936 },
5394 LintCompletion { 5937 Lint {
5395 label: "clippy::mem_forget", 5938 label: "clippy::mem_forget",
5396 description: r##"Checks for usage of `std::mem::forget(t)` where `t` is\n`Drop`."##, 5939 description: r##"Checks for usage of `std::mem::forget(t)` where `t` is\n`Drop`."##,
5397 }, 5940 },
5398 LintCompletion { 5941 Lint {
5399 label: "clippy::mem_replace_option_with_none", 5942 label: "clippy::mem_replace_option_with_none",
5400 description: r##"Checks for `mem::replace()` on an `Option` with\n`None`."##, 5943 description: r##"Checks for `mem::replace()` on an `Option` with\n`None`."##,
5401 }, 5944 },
5402 LintCompletion { 5945 Lint {
5403 label: "clippy::mem_replace_with_default", 5946 label: "clippy::mem_replace_with_default",
5404 description: r##"Checks for `std::mem::replace` on a value of type\n`T` with `T::default()`."##, 5947 description: r##"Checks for `std::mem::replace` on a value of type\n`T` with `T::default()`."##,
5405 }, 5948 },
5406 LintCompletion { 5949 Lint {
5407 label: "clippy::mem_replace_with_uninit", 5950 label: "clippy::mem_replace_with_uninit",
5408 description: r##"Checks for `mem::replace(&mut _, mem::uninitialized())`\nand `mem::replace(&mut _, mem::zeroed())`."##, 5951 description: r##"Checks for `mem::replace(&mut _, mem::uninitialized())`\nand `mem::replace(&mut _, mem::zeroed())`."##,
5409 }, 5952 },
5410 LintCompletion { 5953 Lint {
5411 label: "clippy::min_max", 5954 label: "clippy::min_max",
5412 description: r##"Checks for expressions where `std::cmp::min` and `max` are\nused to clamp values, but switched so that the result is constant."##, 5955 description: r##"Checks for expressions where `std::cmp::min` and `max` are\nused to clamp values, but switched so that the result is constant."##,
5413 }, 5956 },
5414 LintCompletion { 5957 Lint {
5415 label: "clippy::misaligned_transmute", 5958 label: "clippy::misaligned_transmute",
5416 description: r##"Nothing. This lint has been deprecated."##, 5959 description: r##"Nothing. This lint has been deprecated."##,
5417 }, 5960 },
5418 LintCompletion { 5961 Lint {
5419 label: "clippy::mismatched_target_os", 5962 label: "clippy::mismatched_target_os",
5420 description: r##"Checks for cfg attributes having operating systems used in target family position."##, 5963 description: r##"Checks for cfg attributes having operating systems used in target family position."##,
5421 }, 5964 },
5422 LintCompletion { 5965 Lint {
5423 label: "clippy::misrefactored_assign_op", 5966 label: "clippy::misrefactored_assign_op",
5424 description: r##"Checks for `a op= a op b` or `a op= b op a` patterns."##, 5967 description: r##"Checks for `a op= a op b` or `a op= b op a` patterns."##,
5425 }, 5968 },
5426 LintCompletion { 5969 Lint {
5427 label: "clippy::missing_const_for_fn", 5970 label: "clippy::missing_const_for_fn",
5428 description: r##"Suggests the use of `const` in functions and methods where possible."##, 5971 description: r##"Suggests the use of `const` in functions and methods where possible."##,
5429 }, 5972 },
5430 LintCompletion { 5973 Lint {
5431 label: "clippy::missing_docs_in_private_items", 5974 label: "clippy::missing_docs_in_private_items",
5432 description: r##"Warns if there is missing doc for any documentable item\n(public or private)."##, 5975 description: r##"Warns if there is missing doc for any documentable item\n(public or private)."##,
5433 }, 5976 },
5434 LintCompletion { 5977 Lint {
5435 label: "clippy::missing_errors_doc", 5978 label: "clippy::missing_errors_doc",
5436 description: r##"Checks the doc comments of publicly visible functions that\nreturn a `Result` type and warns if there is no `# Errors` section."##, 5979 description: r##"Checks the doc comments of publicly visible functions that\nreturn a `Result` type and warns if there is no `# Errors` section."##,
5437 }, 5980 },
5438 LintCompletion { 5981 Lint {
5439 label: "clippy::missing_inline_in_public_items", 5982 label: "clippy::missing_inline_in_public_items",
5440 description: r##"it lints if an exported function, method, trait method with default impl,\nor trait method impl is not `#[inline]`."##, 5983 description: r##"it lints if an exported function, method, trait method with default impl,\nor trait method impl is not `#[inline]`."##,
5441 }, 5984 },
5442 LintCompletion { 5985 Lint {
5443 label: "clippy::missing_panics_doc", 5986 label: "clippy::missing_panics_doc",
5444 description: r##"Checks the doc comments of publicly visible functions that\nmay panic and warns if there is no `# Panics` section."##, 5987 description: r##"Checks the doc comments of publicly visible functions that\nmay panic and warns if there is no `# Panics` section."##,
5445 }, 5988 },
5446 LintCompletion { 5989 Lint {
5447 label: "clippy::missing_safety_doc", 5990 label: "clippy::missing_safety_doc",
5448 description: r##"Checks for the doc comments of publicly visible\nunsafe functions and warns if there is no `# Safety` section."##, 5991 description: r##"Checks for the doc comments of publicly visible\nunsafe functions and warns if there is no `# Safety` section."##,
5449 }, 5992 },
5450 LintCompletion { 5993 Lint {
5451 label: "clippy::mistyped_literal_suffixes", 5994 label: "clippy::mistyped_literal_suffixes",
5452 description: r##"Warns for mistyped suffix in literals"##, 5995 description: r##"Warns for mistyped suffix in literals"##,
5453 }, 5996 },
5454 LintCompletion { 5997 Lint {
5455 label: "clippy::mixed_case_hex_literals", 5998 label: "clippy::mixed_case_hex_literals",
5456 description: r##"Warns on hexadecimal literals with mixed-case letter\ndigits."##, 5999 description: r##"Warns on hexadecimal literals with mixed-case letter\ndigits."##,
5457 }, 6000 },
5458 LintCompletion { 6001 Lint {
5459 label: "clippy::module_inception", 6002 label: "clippy::module_inception",
5460 description: r##"Checks for modules that have the same name as their\nparent module"##, 6003 description: r##"Checks for modules that have the same name as their\nparent module"##,
5461 }, 6004 },
5462 LintCompletion { 6005 Lint {
5463 label: "clippy::module_name_repetitions", 6006 label: "clippy::module_name_repetitions",
5464 description: r##"Detects type names that are prefixed or suffixed by the\ncontaining module's name."##, 6007 description: r##"Detects type names that are prefixed or suffixed by the\ncontaining module's name."##,
5465 }, 6008 },
5466 LintCompletion { 6009 Lint { label: "clippy::modulo_arithmetic", description: r##"Checks for modulo arithmetic."## },
5467 label: "clippy::modulo_arithmetic", 6010 Lint {
5468 description: r##"Checks for modulo arithmetic."##,
5469 },
5470 LintCompletion {
5471 label: "clippy::modulo_one", 6011 label: "clippy::modulo_one",
5472 description: r##"Checks for getting the remainder of a division by one or minus\none."##, 6012 description: r##"Checks for getting the remainder of a division by one or minus\none."##,
5473 }, 6013 },
5474 LintCompletion { 6014 Lint {
5475 label: "clippy::multiple_crate_versions", 6015 label: "clippy::multiple_crate_versions",
5476 description: r##"Checks to see if multiple versions of a crate are being\nused."##, 6016 description: r##"Checks to see if multiple versions of a crate are being\nused."##,
5477 }, 6017 },
5478 LintCompletion { 6018 Lint {
5479 label: "clippy::multiple_inherent_impl", 6019 label: "clippy::multiple_inherent_impl",
5480 description: r##"Checks for multiple inherent implementations of a struct"##, 6020 description: r##"Checks for multiple inherent implementations of a struct"##,
5481 }, 6021 },
5482 LintCompletion { 6022 Lint {
5483 label: "clippy::must_use_candidate", 6023 label: "clippy::must_use_candidate",
5484 description: r##"Checks for public functions that have no\n[`#[must_use]`] attribute, but return something not already marked\nmust-use, have no mutable arg and mutate no statics.\n\n[`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"##, 6024 description: r##"Checks for public functions that have no\n[`#[must_use]`] attribute, but return something not already marked\nmust-use, have no mutable arg and mutate no statics.\n\n[`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"##,
5485 }, 6025 },
5486 LintCompletion { 6026 Lint {
5487 label: "clippy::must_use_unit", 6027 label: "clippy::must_use_unit",
5488 description: r##"Checks for a [`#[must_use]`] attribute on\nunit-returning functions and methods.\n\n[`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"##, 6028 description: r##"Checks for a [`#[must_use]`] attribute on\nunit-returning functions and methods.\n\n[`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"##,
5489 }, 6029 },
5490 LintCompletion { 6030 Lint {
5491 label: "clippy::mut_from_ref", 6031 label: "clippy::mut_from_ref",
5492 description: r##"This lint checks for functions that take immutable\nreferences and return mutable ones."##, 6032 description: r##"This lint checks for functions that take immutable\nreferences and return mutable ones."##,
5493 }, 6033 },
5494 LintCompletion { 6034 Lint {
5495 label: "clippy::mut_mut", 6035 label: "clippy::mut_mut",
5496 description: r##"Checks for instances of `mut mut` references."##, 6036 description: r##"Checks for instances of `mut mut` references."##,
5497 }, 6037 },
5498 LintCompletion { 6038 Lint {
5499 label: "clippy::mut_mutex_lock", 6039 label: "clippy::mut_mutex_lock",
5500 description: r##"Checks for `&mut Mutex::lock` calls"##, 6040 description: r##"Checks for `&mut Mutex::lock` calls"##,
5501 }, 6041 },
5502 LintCompletion { 6042 Lint {
5503 label: "clippy::mut_range_bound", 6043 label: "clippy::mut_range_bound",
5504 description: r##"Checks for loops which have a range bound that is a mutable variable"##, 6044 description: r##"Checks for loops which have a range bound that is a mutable variable"##,
5505 }, 6045 },
5506 LintCompletion { 6046 Lint {
5507 label: "clippy::mutable_key_type", 6047 label: "clippy::mutable_key_type",
5508 description: r##"Checks for sets/maps with mutable key types."##, 6048 description: r##"Checks for sets/maps with mutable key types."##,
5509 }, 6049 },
5510 LintCompletion { 6050 Lint {
5511 label: "clippy::mutex_atomic", 6051 label: "clippy::mutex_atomic",
5512 description: r##"Checks for usages of `Mutex<X>` where an atomic will do."##, 6052 description: r##"Checks for usages of `Mutex<X>` where an atomic will do."##,
5513 }, 6053 },
5514 LintCompletion { 6054 Lint {
5515 label: "clippy::mutex_integer", 6055 label: "clippy::mutex_integer",
5516 description: r##"Checks for usages of `Mutex<X>` where `X` is an integral\ntype."##, 6056 description: r##"Checks for usages of `Mutex<X>` where `X` is an integral\ntype."##,
5517 }, 6057 },
5518 LintCompletion { 6058 Lint { label: "clippy::naive_bytecount", description: r##"Checks for naive byte counts"## },
5519 label: "clippy::naive_bytecount", 6059 Lint {
5520 description: r##"Checks for naive byte counts"##,
5521 },
5522 LintCompletion {
5523 label: "clippy::needless_arbitrary_self_type", 6060 label: "clippy::needless_arbitrary_self_type",
5524 description: r##"The lint checks for `self` in fn parameters that\nspecify the `Self`-type explicitly"##, 6061 description: r##"The lint checks for `self` in fn parameters that\nspecify the `Self`-type explicitly"##,
5525 }, 6062 },
5526 LintCompletion { 6063 Lint {
6064 label: "clippy::needless_bitwise_bool",
6065 description: r##"Checks for uses of bitwise and/or operators between booleans, where performance may be improved by using\na lazy and."##,
6066 },
6067 Lint {
5527 label: "clippy::needless_bool", 6068 label: "clippy::needless_bool",
5528 description: r##"Checks for expressions of the form `if c { true } else {\nfalse }` (or vice versa) and suggests using the condition directly."##, 6069 description: r##"Checks for expressions of the form `if c { true } else {\nfalse }` (or vice versa) and suggests using the condition directly."##,
5529 }, 6070 },
5530 LintCompletion { 6071 Lint {
5531 label: "clippy::needless_borrow", 6072 label: "clippy::needless_borrow",
5532 description: r##"Checks for address of operations (`&`) that are going to\nbe dereferenced immediately by the compiler."##, 6073 description: r##"Checks for address of operations (`&`) that are going to\nbe dereferenced immediately by the compiler."##,
5533 }, 6074 },
5534 LintCompletion { 6075 Lint {
5535 label: "clippy::needless_borrowed_reference", 6076 label: "clippy::needless_borrowed_reference",
5536 description: r##"Checks for useless borrowed references."##, 6077 description: r##"Checks for bindings that destructure a reference and borrow the inner\nvalue with `&ref`."##,
5537 }, 6078 },
5538 LintCompletion { 6079 Lint {
5539 label: "clippy::needless_collect", 6080 label: "clippy::needless_collect",
5540 description: r##"Checks for functions collecting an iterator when collect\nis not needed."##, 6081 description: r##"Checks for functions collecting an iterator when collect\nis not needed."##,
5541 }, 6082 },
5542 LintCompletion { 6083 Lint {
5543 label: "clippy::needless_continue", 6084 label: "clippy::needless_continue",
5544 description: r##"The lint checks for `if`-statements appearing in loops\nthat contain a `continue` statement in either their main blocks or their\n`else`-blocks, when omitting the `else`-block possibly with some\nrearrangement of code can make the code easier to understand."##, 6085 description: r##"The lint checks for `if`-statements appearing in loops\nthat contain a `continue` statement in either their main blocks or their\n`else`-blocks, when omitting the `else`-block possibly with some\nrearrangement of code can make the code easier to understand."##,
5545 }, 6086 },
5546 LintCompletion { 6087 Lint {
5547 label: "clippy::needless_doctest_main", 6088 label: "clippy::needless_doctest_main",
5548 description: r##"Checks for `fn main() { .. }` in doctests"##, 6089 description: r##"Checks for `fn main() { .. }` in doctests"##,
5549 }, 6090 },
5550 LintCompletion { 6091 Lint {
6092 label: "clippy::needless_for_each",
6093 description: r##"Checks for usage of `for_each` that would be more simply written as a\n`for` loop."##,
6094 },
6095 Lint {
5551 label: "clippy::needless_lifetimes", 6096 label: "clippy::needless_lifetimes",
5552 description: r##"Checks for lifetime annotations which can be removed by\nrelying on lifetime elision."##, 6097 description: r##"Checks for lifetime annotations which can be removed by\nrelying on lifetime elision."##,
5553 }, 6098 },
5554 LintCompletion { 6099 Lint {
5555 label: "clippy::needless_pass_by_value", 6100 label: "clippy::needless_pass_by_value",
5556 description: r##"Checks for functions taking arguments by value, but not\nconsuming them in its\nbody."##, 6101 description: r##"Checks for functions taking arguments by value, but not\nconsuming them in its\nbody."##,
5557 }, 6102 },
5558 LintCompletion { 6103 Lint {
5559 label: "clippy::needless_question_mark", 6104 label: "clippy::needless_question_mark",
5560 description: r##"Suggests alternatives for useless applications of `?` in terminating expressions"##, 6105 description: r##"Suggests alternatives for useless applications of `?` in terminating expressions"##,
5561 }, 6106 },
5562 LintCompletion { 6107 Lint {
5563 label: "clippy::needless_range_loop", 6108 label: "clippy::needless_range_loop",
5564 description: r##"Checks for looping over the range of `0..len` of some\ncollection just to get the values by index."##, 6109 description: r##"Checks for looping over the range of `0..len` of some\ncollection just to get the values by index."##,
5565 }, 6110 },
5566 LintCompletion { 6111 Lint {
5567 label: "clippy::needless_return", 6112 label: "clippy::needless_return",
5568 description: r##"Checks for return statements at the end of a block."##, 6113 description: r##"Checks for return statements at the end of a block."##,
5569 }, 6114 },
5570 LintCompletion { 6115 Lint {
5571 label: "clippy::needless_update", 6116 label: "clippy::needless_update",
5572 description: r##"Checks for needlessly including a base struct on update\nwhen all fields are changed anyway.\n\nThis lint is not applied to structs marked with\n[non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html)."##, 6117 description: r##"Checks for needlessly including a base struct on update\nwhen all fields are changed anyway.\n\nThis lint is not applied to structs marked with\n[non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html)."##,
5573 }, 6118 },
5574 LintCompletion { 6119 Lint {
5575 label: "clippy::neg_cmp_op_on_partial_ord", 6120 label: "clippy::neg_cmp_op_on_partial_ord",
5576 description: r##"Checks for the usage of negated comparison operators on types which only implement\n`PartialOrd` (e.g., `f64`)."##, 6121 description: r##"Checks for the usage of negated comparison operators on types which only implement\n`PartialOrd` (e.g., `f64`)."##,
5577 }, 6122 },
5578 LintCompletion { 6123 Lint {
5579 label: "clippy::neg_multiply", 6124 label: "clippy::neg_multiply",
5580 description: r##"Checks for multiplication by -1 as a form of negation."##, 6125 description: r##"Checks for multiplication by -1 as a form of negation."##,
5581 }, 6126 },
5582 LintCompletion { 6127 Lint {
5583 label: "clippy::never_loop", 6128 label: "clippy::never_loop",
5584 description: r##"Checks for loops that will always `break`, `return` or\n`continue` an outer loop."##, 6129 description: r##"Checks for loops that will always `break`, `return` or\n`continue` an outer loop."##,
5585 }, 6130 },
5586 LintCompletion { 6131 Lint {
5587 label: "clippy::new_ret_no_self", 6132 label: "clippy::new_ret_no_self",
5588 description: r##"Checks for `new` not returning a type that contains `Self`."##, 6133 description: r##"Checks for `new` not returning a type that contains `Self`."##,
5589 }, 6134 },
5590 LintCompletion { 6135 Lint {
5591 label: "clippy::new_without_default", 6136 label: "clippy::new_without_default",
5592 description: r##"Checks for types with a `fn new() -> Self` method and no\nimplementation of\n[`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)."##, 6137 description: r##"Checks for types with a `fn new() -> Self` method and no\nimplementation of\n[`Default`](https://doc.rust-lang.org/std/default/trait.Default.html)."##,
5593 }, 6138 },
5594 LintCompletion { 6139 Lint {
5595 label: "clippy::no_effect", 6140 label: "clippy::no_effect",
5596 description: r##"Checks for statements which have no effect."##, 6141 description: r##"Checks for statements which have no effect."##,
5597 }, 6142 },
5598 LintCompletion { 6143 Lint {
5599 label: "clippy::non_ascii_literal", 6144 label: "clippy::non_ascii_literal",
5600 description: r##"Checks for non-ASCII characters in string literals."##, 6145 description: r##"Checks for non-ASCII characters in string literals."##,
5601 }, 6146 },
5602 LintCompletion { 6147 Lint {
6148 label: "clippy::non_octal_unix_permissions",
6149 description: r##"Checks for non-octal values used to set Unix file permissions."##,
6150 },
6151 Lint {
5603 label: "clippy::nonminimal_bool", 6152 label: "clippy::nonminimal_bool",
5604 description: r##"Checks for boolean expressions that can be written more\nconcisely."##, 6153 description: r##"Checks for boolean expressions that can be written more\nconcisely."##,
5605 }, 6154 },
5606 LintCompletion { 6155 Lint {
5607 label: "clippy::nonsensical_open_options", 6156 label: "clippy::nonsensical_open_options",
5608 description: r##"Checks for duplicate open options as well as combinations\nthat make no sense."##, 6157 description: r##"Checks for duplicate open options as well as combinations\nthat make no sense."##,
5609 }, 6158 },
5610 LintCompletion { 6159 Lint {
5611 label: "clippy::not_unsafe_ptr_arg_deref", 6160 label: "clippy::not_unsafe_ptr_arg_deref",
5612 description: r##"Checks for public functions that dereference raw pointer\narguments but are not marked unsafe."##, 6161 description: r##"Checks for public functions that dereference raw pointer\narguments but are not marked `unsafe`."##,
5613 }, 6162 },
5614 LintCompletion { 6163 Lint { label: "clippy::ok_expect", description: r##"Checks for usage of `ok().expect(..)`."## },
5615 label: "clippy::ok_expect", 6164 Lint {
5616 description: r##"Checks for usage of `ok().expect(..)`."##,
5617 },
5618 LintCompletion {
5619 label: "clippy::op_ref", 6165 label: "clippy::op_ref",
5620 description: r##"Checks for arguments to `==` which have their address\ntaken to satisfy a bound\nand suggests to dereference the other argument instead"##, 6166 description: r##"Checks for arguments to `==` which have their address\ntaken to satisfy a bound\nand suggests to dereference the other argument instead"##,
5621 }, 6167 },
5622 LintCompletion { 6168 Lint {
5623 label: "clippy::option_as_ref_deref", 6169 label: "clippy::option_as_ref_deref",
5624 description: r##"Checks for usage of `_.as_ref().map(Deref::deref)` or it's aliases (such as String::as_str)."##, 6170 description: r##"Checks for usage of `_.as_ref().map(Deref::deref)` or it's aliases (such as String::as_str)."##,
5625 }, 6171 },
5626 LintCompletion { 6172 Lint {
5627 label: "clippy::option_env_unwrap", 6173 label: "clippy::option_env_unwrap",
5628 description: r##"Checks for usage of `option_env!(...).unwrap()` and\nsuggests usage of the `env!` macro."##, 6174 description: r##"Checks for usage of `option_env!(...).unwrap()` and\nsuggests usage of the `env!` macro."##,
5629 }, 6175 },
5630 LintCompletion { 6176 Lint {
6177 label: "clippy::option_filter_map",
6178 description: r##"Checks for indirect collection of populated `Option`"##,
6179 },
6180 Lint {
5631 label: "clippy::option_if_let_else", 6181 label: "clippy::option_if_let_else",
5632 description: r##"Lints usage of `if let Some(v) = ... { y } else { x }` which is more\nidiomatically done with `Option::map_or` (if the else bit is a pure\nexpression) or `Option::map_or_else` (if the else bit is an impure\nexpression)."##, 6182 description: r##"Lints usage of `if let Some(v) = ... { y } else { x }` which is more\nidiomatically done with `Option::map_or` (if the else bit is a pure\nexpression) or `Option::map_or_else` (if the else bit is an impure\nexpression)."##,
5633 }, 6183 },
5634 LintCompletion { 6184 Lint {
5635 label: "clippy::option_map_or_none", 6185 label: "clippy::option_map_or_none",
5636 description: r##"Checks for usage of `_.map_or(None, _)`."##, 6186 description: r##"Checks for usage of `_.map_or(None, _)`."##,
5637 }, 6187 },
5638 LintCompletion { 6188 Lint {
5639 label: "clippy::option_map_unit_fn", 6189 label: "clippy::option_map_unit_fn",
5640 description: r##"Checks for usage of `option.map(f)` where f is a function\nor closure that returns the unit type `()`."##, 6190 description: r##"Checks for usage of `option.map(f)` where f is a function\nor closure that returns the unit type `()`."##,
5641 }, 6191 },
5642 LintCompletion { 6192 Lint {
5643 label: "clippy::option_option", 6193 label: "clippy::option_option",
5644 description: r##"Checks for use of `Option<Option<_>>` in function signatures and type\ndefinitions"##, 6194 description: r##"Checks for use of `Option<Option<_>>` in function signatures and type\ndefinitions"##,
5645 }, 6195 },
5646 LintCompletion { 6196 Lint {
5647 label: "clippy::or_fun_call", 6197 label: "clippy::or_fun_call",
5648 description: r##"Checks for calls to `.or(foo(..))`, `.unwrap_or(foo(..))`,\netc., and suggests to use `or_else`, `unwrap_or_else`, etc., or\n`unwrap_or_default` instead."##, 6198 description: r##"Checks for calls to `.or(foo(..))`, `.unwrap_or(foo(..))`,\netc., and suggests to use `or_else`, `unwrap_or_else`, etc., or\n`unwrap_or_default` instead."##,
5649 }, 6199 },
5650 LintCompletion { 6200 Lint {
5651 label: "clippy::out_of_bounds_indexing", 6201 label: "clippy::out_of_bounds_indexing",
5652 description: r##"Checks for out of bounds array indexing with a constant\nindex."##, 6202 description: r##"Checks for out of bounds array indexing with a constant\nindex."##,
5653 }, 6203 },
5654 LintCompletion { 6204 Lint {
5655 label: "clippy::overflow_check_conditional", 6205 label: "clippy::overflow_check_conditional",
5656 description: r##"Detects classic underflow/overflow checks."##, 6206 description: r##"Detects classic underflow/overflow checks."##,
5657 }, 6207 },
5658 LintCompletion { label: "clippy::panic", description: r##"Checks for usage of `panic!`."## }, 6208 Lint { label: "clippy::panic", description: r##"Checks for usage of `panic!`."## },
5659 LintCompletion { 6209 Lint {
5660 label: "clippy::panic_in_result_fn", 6210 label: "clippy::panic_in_result_fn",
5661 description: r##"Checks for usage of `panic!`, `unimplemented!`, `todo!`, `unreachable!` or assertions in a function of type result."##, 6211 description: r##"Checks for usage of `panic!`, `unimplemented!`, `todo!`, `unreachable!` or assertions in a function of type result."##,
5662 }, 6212 },
5663 LintCompletion { 6213 Lint {
5664 label: "clippy::panic_params",
5665 description: r##"Nothing. This lint has been deprecated."##,
5666 },
5667 LintCompletion {
5668 label: "clippy::panicking_unwrap", 6214 label: "clippy::panicking_unwrap",
5669 description: r##"Checks for calls of `unwrap[_err]()` that will always fail."##, 6215 description: r##"Checks for calls of `unwrap[_err]()` that will always fail."##,
5670 }, 6216 },
5671 LintCompletion { 6217 Lint {
5672 label: "clippy::partialeq_ne_impl", 6218 label: "clippy::partialeq_ne_impl",
5673 description: r##"Checks for manual re-implementations of `PartialEq::ne`."##, 6219 description: r##"Checks for manual re-implementations of `PartialEq::ne`."##,
5674 }, 6220 },
5675 LintCompletion { 6221 Lint {
5676 label: "clippy::path_buf_push_overwrite", 6222 label: "clippy::path_buf_push_overwrite",
5677 description: r##"* Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)\ncalls on `PathBuf` that can cause overwrites."##, 6223 description: r##"* Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)\ncalls on `PathBuf` that can cause overwrites."##,
5678 }, 6224 },
5679 LintCompletion { 6225 Lint {
5680 label: "clippy::pattern_type_mismatch", 6226 label: "clippy::pattern_type_mismatch",
5681 description: r##"Checks for patterns that aren't exact representations of the types\nthey are applied to.\n\nTo satisfy this lint, you will have to adjust either the expression that is matched\nagainst or the pattern itself, as well as the bindings that are introduced by the\nadjusted patterns. For matching you will have to either dereference the expression\nwith the `*` operator, or amend the patterns to explicitly match against `&<pattern>`\nor `&mut <pattern>` depending on the reference mutability. For the bindings you need\nto use the inverse. You can leave them as plain bindings if you wish for the value\nto be copied, but you must use `ref mut <variable>` or `ref <variable>` to construct\na reference into the matched structure.\n\nIf you are looking for a way to learn about ownership semantics in more detail, it\nis recommended to look at IDE options available to you to highlight types, lifetimes\nand reference semantics in your code. The available tooling would expose these things\nin a general way even outside of the various pattern matching mechanics. Of course\nthis lint can still be used to highlight areas of interest and ensure a good understanding\nof ownership semantics."##, 6227 description: r##"Checks for patterns that aren't exact representations of the types\nthey are applied to.\n\nTo satisfy this lint, you will have to adjust either the expression that is matched\nagainst or the pattern itself, as well as the bindings that are introduced by the\nadjusted patterns. For matching you will have to either dereference the expression\nwith the `*` operator, or amend the patterns to explicitly match against `&<pattern>`\nor `&mut <pattern>` depending on the reference mutability. For the bindings you need\nto use the inverse. You can leave them as plain bindings if you wish for the value\nto be copied, but you must use `ref mut <variable>` or `ref <variable>` to construct\na reference into the matched structure.\n\nIf you are looking for a way to learn about ownership semantics in more detail, it\nis recommended to look at IDE options available to you to highlight types, lifetimes\nand reference semantics in your code. The available tooling would expose these things\nin a general way even outside of the various pattern matching mechanics. Of course\nthis lint can still be used to highlight areas of interest and ensure a good understanding\nof ownership semantics."##,
5682 }, 6228 },
5683 LintCompletion { 6229 Lint {
5684 label: "clippy::possible_missing_comma", 6230 label: "clippy::possible_missing_comma",
5685 description: r##"Checks for possible missing comma in an array. It lints if\nan array element is a binary operator expression and it lies on two lines."##, 6231 description: r##"Checks for possible missing comma in an array. It lints if\nan array element is a binary operator expression and it lies on two lines."##,
5686 }, 6232 },
5687 LintCompletion { 6233 Lint {
5688 label: "clippy::precedence", 6234 label: "clippy::precedence",
5689 description: r##"Checks for operations where precedence may be unclear\nand suggests to add parentheses. Currently it catches the following:\n* mixed usage of arithmetic and bit shifting/combining operators without\nparentheses\n* a \"negative\" numeric literal (which is really a unary `-` followed by a\nnumeric literal)\n followed by a method call"##, 6235 description: r##"Checks for operations where precedence may be unclear\nand suggests to add parentheses. Currently it catches the following:\n* mixed usage of arithmetic and bit shifting/combining operators without\nparentheses\n* a \"negative\" numeric literal (which is really a unary `-` followed by a\nnumeric literal)\n followed by a method call"##,
5690 }, 6236 },
5691 LintCompletion { 6237 Lint {
5692 label: "clippy::print_literal", 6238 label: "clippy::print_literal",
5693 description: r##"This lint warns about the use of literals as `print!`/`println!` args."##, 6239 description: r##"This lint warns about the use of literals as `print!`/`println!` args."##,
5694 }, 6240 },
5695 LintCompletion { 6241 Lint {
5696 label: "clippy::print_stderr", 6242 label: "clippy::print_stderr",
5697 description: r##"Checks for printing on *stderr*. The purpose of this lint\nis to catch debugging remnants."##, 6243 description: r##"Checks for printing on *stderr*. The purpose of this lint\nis to catch debugging remnants."##,
5698 }, 6244 },
5699 LintCompletion { 6245 Lint {
5700 label: "clippy::print_stdout", 6246 label: "clippy::print_stdout",
5701 description: r##"Checks for printing on *stdout*. The purpose of this lint\nis to catch debugging remnants."##, 6247 description: r##"Checks for printing on *stdout*. The purpose of this lint\nis to catch debugging remnants."##,
5702 }, 6248 },
5703 LintCompletion { 6249 Lint {
5704 label: "clippy::print_with_newline", 6250 label: "clippy::print_with_newline",
5705 description: r##"This lint warns when you use `print!()` with a format\nstring that ends in a newline."##, 6251 description: r##"This lint warns when you use `print!()` with a format\nstring that ends in a newline."##,
5706 }, 6252 },
5707 LintCompletion { 6253 Lint {
5708 label: "clippy::println_empty_string", 6254 label: "clippy::println_empty_string",
5709 description: r##"This lint warns when you use `println!(\"\")` to\nprint a newline."##, 6255 description: r##"This lint warns when you use `println!(\"\")` to\nprint a newline."##,
5710 }, 6256 },
5711 LintCompletion { 6257 Lint {
5712 label: "clippy::ptr_arg", 6258 label: "clippy::ptr_arg",
5713 description: r##"This lint checks for function arguments of type `&String`\nor `&Vec` unless the references are mutable. It will also suggest you\nreplace `.clone()` calls with the appropriate `.to_owned()`/`to_string()`\ncalls."##, 6259 description: r##"This lint checks for function arguments of type `&String`\nor `&Vec` unless the references are mutable. It will also suggest you\nreplace `.clone()` calls with the appropriate `.to_owned()`/`to_string()`\ncalls."##,
5714 }, 6260 },
5715 LintCompletion { 6261 Lint {
5716 label: "clippy::ptr_as_ptr", 6262 label: "clippy::ptr_as_ptr",
5717 description: r##"Checks for `as` casts between raw pointers without changing its mutability,\nnamely `*const T` to `*const U` and `*mut T` to `*mut U`."##, 6263 description: r##"Checks for `as` casts between raw pointers without changing its mutability,\nnamely `*const T` to `*const U` and `*mut T` to `*mut U`."##,
5718 }, 6264 },
5719 LintCompletion { 6265 Lint { label: "clippy::ptr_eq", description: r##"Use `std::ptr::eq` when applicable"## },
5720 label: "clippy::ptr_eq", 6266 Lint {
5721 description: r##"Use `std::ptr::eq` when applicable"##,
5722 },
5723 LintCompletion {
5724 label: "clippy::ptr_offset_with_cast", 6267 label: "clippy::ptr_offset_with_cast",
5725 description: r##"Checks for usage of the `offset` pointer method with a `usize` casted to an\n`isize`."##, 6268 description: r##"Checks for usage of the `offset` pointer method with a `usize` casted to an\n`isize`."##,
5726 }, 6269 },
5727 LintCompletion { 6270 Lint {
5728 label: "clippy::pub_enum_variant_names", 6271 label: "clippy::pub_enum_variant_names",
5729 description: r##"Detects public enumeration variants that are\nprefixed or suffixed by the same characters."##, 6272 description: r##"Nothing. This lint has been deprecated."##,
5730 }, 6273 },
5731 LintCompletion { 6274 Lint {
5732 label: "clippy::question_mark", 6275 label: "clippy::question_mark",
5733 description: r##"Checks for expressions that could be replaced by the question mark operator."##, 6276 description: r##"Checks for expressions that could be replaced by the question mark operator."##,
5734 }, 6277 },
5735 LintCompletion { 6278 Lint {
5736 label: "clippy::range_minus_one", 6279 label: "clippy::range_minus_one",
5737 description: r##"Checks for inclusive ranges where 1 is subtracted from\nthe upper bound, e.g., `x..=(y-1)`."##, 6280 description: r##"Checks for inclusive ranges where 1 is subtracted from\nthe upper bound, e.g., `x..=(y-1)`."##,
5738 }, 6281 },
5739 LintCompletion { 6282 Lint {
5740 label: "clippy::range_plus_one", 6283 label: "clippy::range_plus_one",
5741 description: r##"Checks for exclusive ranges where 1 is added to the\nupper bound, e.g., `x..(y+1)`."##, 6284 description: r##"Checks for exclusive ranges where 1 is added to the\nupper bound, e.g., `x..(y+1)`."##,
5742 }, 6285 },
5743 LintCompletion { 6286 Lint {
5744 label: "clippy::range_step_by_zero", 6287 label: "clippy::range_step_by_zero",
5745 description: r##"Nothing. This lint has been deprecated."##, 6288 description: r##"Nothing. This lint has been deprecated."##,
5746 }, 6289 },
5747 LintCompletion { 6290 Lint {
5748 label: "clippy::range_zip_with_len", 6291 label: "clippy::range_zip_with_len",
5749 description: r##"Checks for zipping a collection with the range of\n`0.._.len()`."##, 6292 description: r##"Checks for zipping a collection with the range of\n`0.._.len()`."##,
5750 }, 6293 },
5751 LintCompletion { 6294 Lint {
5752 label: "clippy::rc_buffer", 6295 label: "clippy::rc_buffer",
5753 description: r##"Checks for `Rc<T>` and `Arc<T>` when `T` is a mutable buffer type such as `String` or `Vec`."##, 6296 description: r##"Checks for `Rc<T>` and `Arc<T>` when `T` is a mutable buffer type such as `String` or `Vec`."##,
5754 }, 6297 },
5755 LintCompletion { 6298 Lint {
5756 label: "clippy::redundant_allocation", 6299 label: "clippy::redundant_allocation",
5757 description: r##"Checks for use of redundant allocations anywhere in the code."##, 6300 description: r##"Checks for use of redundant allocations anywhere in the code."##,
5758 }, 6301 },
5759 LintCompletion { 6302 Lint {
5760 label: "clippy::redundant_clone", 6303 label: "clippy::redundant_clone",
5761 description: r##"Checks for a redundant `clone()` (and its relatives) which clones an owned\nvalue that is going to be dropped without further use."##, 6304 description: r##"Checks for a redundant `clone()` (and its relatives) which clones an owned\nvalue that is going to be dropped without further use."##,
5762 }, 6305 },
5763 LintCompletion { 6306 Lint {
5764 label: "clippy::redundant_closure", 6307 label: "clippy::redundant_closure",
5765 description: r##"Checks for closures which just call another function where\nthe function can be called directly. `unsafe` functions or calls where types\nget adjusted are ignored."##, 6308 description: r##"Checks for closures which just call another function where\nthe function can be called directly. `unsafe` functions or calls where types\nget adjusted are ignored."##,
5766 }, 6309 },
5767 LintCompletion { 6310 Lint {
5768 label: "clippy::redundant_closure_call", 6311 label: "clippy::redundant_closure_call",
5769 description: r##"Detects closures called in the same expression where they\nare defined."##, 6312 description: r##"Detects closures called in the same expression where they\nare defined."##,
5770 }, 6313 },
5771 LintCompletion { 6314 Lint {
5772 label: "clippy::redundant_closure_for_method_calls", 6315 label: "clippy::redundant_closure_for_method_calls",
5773 description: r##"Checks for closures which only invoke a method on the closure\nargument and can be replaced by referencing the method directly."##, 6316 description: r##"Checks for closures which only invoke a method on the closure\nargument and can be replaced by referencing the method directly."##,
5774 }, 6317 },
5775 LintCompletion { 6318 Lint {
5776 label: "clippy::redundant_else", 6319 label: "clippy::redundant_else",
5777 description: r##"Checks for `else` blocks that can be removed without changing semantics."##, 6320 description: r##"Checks for `else` blocks that can be removed without changing semantics."##,
5778 }, 6321 },
5779 LintCompletion { 6322 Lint {
5780 label: "clippy::redundant_field_names", 6323 label: "clippy::redundant_field_names",
5781 description: r##"Checks for fields in struct literals where shorthands\ncould be used."##, 6324 description: r##"Checks for fields in struct literals where shorthands\ncould be used."##,
5782 }, 6325 },
5783 LintCompletion { 6326 Lint {
5784 label: "clippy::redundant_pattern", 6327 label: "clippy::redundant_pattern",
5785 description: r##"Checks for patterns in the form `name @ _`."##, 6328 description: r##"Checks for patterns in the form `name @ _`."##,
5786 }, 6329 },
5787 LintCompletion { 6330 Lint {
5788 label: "clippy::redundant_pattern_matching", 6331 label: "clippy::redundant_pattern_matching",
5789 description: r##"Lint for redundant pattern matching over `Result`, `Option`,\n`std::task::Poll` or `std::net::IpAddr`"##, 6332 description: r##"Lint for redundant pattern matching over `Result`, `Option`,\n`std::task::Poll` or `std::net::IpAddr`"##,
5790 }, 6333 },
5791 LintCompletion { 6334 Lint {
5792 label: "clippy::redundant_pub_crate", 6335 label: "clippy::redundant_pub_crate",
5793 description: r##"Checks for items declared `pub(crate)` that are not crate visible because they\nare inside a private module."##, 6336 description: r##"Checks for items declared `pub(crate)` that are not crate visible because they\nare inside a private module."##,
5794 }, 6337 },
5795 LintCompletion { 6338 Lint {
5796 label: "clippy::redundant_slicing", 6339 label: "clippy::redundant_slicing",
5797 description: r##"Checks for redundant slicing expressions which use the full range, and\ndo not change the type."##, 6340 description: r##"Checks for redundant slicing expressions which use the full range, and\ndo not change the type."##,
5798 }, 6341 },
5799 LintCompletion { 6342 Lint {
5800 label: "clippy::redundant_static_lifetimes", 6343 label: "clippy::redundant_static_lifetimes",
5801 description: r##"Checks for constants and statics with an explicit `'static` lifetime."##, 6344 description: r##"Checks for constants and statics with an explicit `'static` lifetime."##,
5802 }, 6345 },
5803 LintCompletion { 6346 Lint {
6347 label: "clippy::ref_binding_to_reference",
6348 description: r##"Checks for `ref` bindings which create a reference to a reference."##,
6349 },
6350 Lint {
5804 label: "clippy::ref_in_deref", 6351 label: "clippy::ref_in_deref",
5805 description: r##"Checks for references in expressions that use\nauto dereference."##, 6352 description: r##"Checks for references in expressions that use\nauto dereference."##,
5806 }, 6353 },
5807 LintCompletion { 6354 Lint {
5808 label: "clippy::ref_option_ref", 6355 label: "clippy::ref_option_ref",
5809 description: r##"Checks for usage of `&Option<&T>`."##, 6356 description: r##"Checks for usage of `&Option<&T>`."##,
5810 }, 6357 },
5811 LintCompletion { 6358 Lint {
5812 label: "clippy::regex_macro", 6359 label: "clippy::regex_macro",
5813 description: r##"Nothing. This lint has been deprecated."##, 6360 description: r##"Nothing. This lint has been deprecated."##,
5814 }, 6361 },
5815 LintCompletion { 6362 Lint {
5816 label: "clippy::repeat_once", 6363 label: "clippy::repeat_once",
5817 description: r##"Checks for usage of `.repeat(1)` and suggest the following method for each types.\n- `.to_string()` for `str`\n- `.clone()` for `String`\n- `.to_vec()` for `slice`"##, 6364 description: r##"Checks for usage of `.repeat(1)` and suggest the following method for each types.\n- `.to_string()` for `str`\n- `.clone()` for `String`\n- `.to_vec()` for `slice`"##,
5818 }, 6365 },
5819 LintCompletion { 6366 Lint {
5820 label: "clippy::replace_consts", 6367 label: "clippy::replace_consts",
5821 description: r##"Nothing. This lint has been deprecated."##, 6368 description: r##"Nothing. This lint has been deprecated."##,
5822 }, 6369 },
5823 LintCompletion { 6370 Lint {
5824 label: "clippy::rest_pat_in_fully_bound_structs", 6371 label: "clippy::rest_pat_in_fully_bound_structs",
5825 description: r##"Checks for unnecessary '..' pattern binding on struct when all fields are explicitly matched."##, 6372 description: r##"Checks for unnecessary '..' pattern binding on struct when all fields are explicitly matched."##,
5826 }, 6373 },
5827 LintCompletion { 6374 Lint {
5828 label: "clippy::result_map_or_into_option", 6375 label: "clippy::result_map_or_into_option",
5829 description: r##"Checks for usage of `_.map_or(None, Some)`."##, 6376 description: r##"Checks for usage of `_.map_or(None, Some)`."##,
5830 }, 6377 },
5831 LintCompletion { 6378 Lint {
5832 label: "clippy::result_map_unit_fn", 6379 label: "clippy::result_map_unit_fn",
5833 description: r##"Checks for usage of `result.map(f)` where f is a function\nor closure that returns the unit type `()`."##, 6380 description: r##"Checks for usage of `result.map(f)` where f is a function\nor closure that returns the unit type `()`."##,
5834 }, 6381 },
5835 LintCompletion { 6382 Lint {
5836 label: "clippy::result_unit_err", 6383 label: "clippy::result_unit_err",
5837 description: r##"Checks for public functions that return a `Result`\nwith an `Err` type of `()`. It suggests using a custom type that\nimplements [`std::error::Error`]."##, 6384 description: r##"Checks for public functions that return a `Result`\nwith an `Err` type of `()`. It suggests using a custom type that\nimplements `std::error::Error`."##,
5838 }, 6385 },
5839 LintCompletion { 6386 Lint {
5840 label: "clippy::reversed_empty_ranges", 6387 label: "clippy::reversed_empty_ranges",
5841 description: r##"Checks for range expressions `x..y` where both `x` and `y`\nare constant and `x` is greater or equal to `y`."##, 6388 description: r##"Checks for range expressions `x..y` where both `x` and `y`\nare constant and `x` is greater or equal to `y`."##,
5842 }, 6389 },
5843 LintCompletion { 6390 Lint {
5844 label: "clippy::same_functions_in_if_condition", 6391 label: "clippy::same_functions_in_if_condition",
5845 description: r##"Checks for consecutive `if`s with the same function call."##, 6392 description: r##"Checks for consecutive `if`s with the same function call."##,
5846 }, 6393 },
5847 LintCompletion { 6394 Lint {
5848 label: "clippy::same_item_push", 6395 label: "clippy::same_item_push",
5849 description: r##"Checks whether a for loop is being used to push a constant\nvalue into a Vec."##, 6396 description: r##"Checks whether a for loop is being used to push a constant\nvalue into a Vec."##,
5850 }, 6397 },
5851 LintCompletion { 6398 Lint {
5852 label: "clippy::search_is_some", 6399 label: "clippy::search_is_some",
5853 description: r##"Checks for an iterator or string search (such as `find()`,\n`position()`, or `rposition()`) followed by a call to `is_some()`."##, 6400 description: r##"Checks for an iterator or string search (such as `find()`,\n`position()`, or `rposition()`) followed by a call to `is_some()` or `is_none()`."##,
5854 }, 6401 },
5855 LintCompletion { 6402 Lint {
5856 label: "clippy::self_assignment", 6403 label: "clippy::self_assignment",
5857 description: r##"Checks for explicit self-assignments."##, 6404 description: r##"Checks for explicit self-assignments."##,
5858 }, 6405 },
5859 LintCompletion { 6406 Lint {
5860 label: "clippy::semicolon_if_nothing_returned", 6407 label: "clippy::semicolon_if_nothing_returned",
5861 description: r##"Looks for blocks of expressions and fires if the last expression returns `()`\nbut is not followed by a semicolon."##, 6408 description: r##"Looks for blocks of expressions and fires if the last expression returns\n`()` but is not followed by a semicolon."##,
5862 }, 6409 },
5863 LintCompletion { 6410 Lint {
5864 label: "clippy::serde_api_misuse", 6411 label: "clippy::serde_api_misuse",
5865 description: r##"Checks for mis-uses of the serde API."##, 6412 description: r##"Checks for mis-uses of the serde API."##,
5866 }, 6413 },
5867 LintCompletion { 6414 Lint {
5868 label: "clippy::shadow_reuse", 6415 label: "clippy::shadow_reuse",
5869 description: r##"Checks for bindings that shadow other bindings already in\nscope, while reusing the original value."##, 6416 description: r##"Checks for bindings that shadow other bindings already in\nscope, while reusing the original value."##,
5870 }, 6417 },
5871 LintCompletion { 6418 Lint {
5872 label: "clippy::shadow_same", 6419 label: "clippy::shadow_same",
5873 description: r##"Checks for bindings that shadow other bindings already in\nscope, while just changing reference level or mutability."##, 6420 description: r##"Checks for bindings that shadow other bindings already in\nscope, while just changing reference level or mutability."##,
5874 }, 6421 },
5875 LintCompletion { 6422 Lint {
5876 label: "clippy::shadow_unrelated", 6423 label: "clippy::shadow_unrelated",
5877 description: r##"Checks for bindings that shadow other bindings already in\nscope, either without a initialization or with one that does not even use\nthe original value."##, 6424 description: r##"Checks for bindings that shadow other bindings already in\nscope, either without a initialization or with one that does not even use\nthe original value."##,
5878 }, 6425 },
5879 LintCompletion { 6426 Lint {
5880 label: "clippy::short_circuit_statement", 6427 label: "clippy::short_circuit_statement",
5881 description: r##"Checks for the use of short circuit boolean conditions as\na\nstatement."##, 6428 description: r##"Checks for the use of short circuit boolean conditions as\na\nstatement."##,
5882 }, 6429 },
5883 LintCompletion { 6430 Lint {
5884 label: "clippy::should_assert_eq", 6431 label: "clippy::should_assert_eq",
5885 description: r##"Nothing. This lint has been deprecated."##, 6432 description: r##"Nothing. This lint has been deprecated."##,
5886 }, 6433 },
5887 LintCompletion { 6434 Lint {
5888 label: "clippy::should_implement_trait", 6435 label: "clippy::should_implement_trait",
5889 description: r##"Checks for methods that should live in a trait\nimplementation of a `std` trait (see [llogiq's blog\npost](http://llogiq.github.io/2015/07/30/traits.html) for further\ninformation) instead of an inherent implementation."##, 6436 description: r##"Checks for methods that should live in a trait\nimplementation of a `std` trait (see [llogiq's blog\npost](http://llogiq.github.io/2015/07/30/traits.html) for further\ninformation) instead of an inherent implementation."##,
5890 }, 6437 },
5891 LintCompletion { 6438 Lint {
5892 label: "clippy::similar_names", 6439 label: "clippy::similar_names",
5893 description: r##"Checks for names that are very similar and thus confusing."##, 6440 description: r##"Checks for names that are very similar and thus confusing."##,
5894 }, 6441 },
5895 LintCompletion { 6442 Lint {
5896 label: "clippy::single_char_add_str", 6443 label: "clippy::single_char_add_str",
5897 description: r##"Warns when using `push_str`/`insert_str` with a single-character string literal\nwhere `push`/`insert` with a `char` would work fine."##, 6444 description: r##"Warns when using `push_str`/`insert_str` with a single-character string literal\nwhere `push`/`insert` with a `char` would work fine."##,
5898 }, 6445 },
5899 LintCompletion { 6446 Lint {
5900 label: "clippy::single_char_pattern", 6447 label: "clippy::single_char_pattern",
5901 description: r##"Checks for string methods that receive a single-character\n`str` as an argument, e.g., `_.split(\"x\")`."##, 6448 description: r##"Checks for string methods that receive a single-character\n`str` as an argument, e.g., `_.split(\"x\")`."##,
5902 }, 6449 },
5903 LintCompletion { 6450 Lint {
5904 label: "clippy::single_component_path_imports", 6451 label: "clippy::single_component_path_imports",
5905 description: r##"Checking for imports with single component use path."##, 6452 description: r##"Checking for imports with single component use path."##,
5906 }, 6453 },
5907 LintCompletion { 6454 Lint {
5908 label: "clippy::single_element_loop", 6455 label: "clippy::single_element_loop",
5909 description: r##"Checks whether a for loop has a single element."##, 6456 description: r##"Checks whether a for loop has a single element."##,
5910 }, 6457 },
5911 LintCompletion { 6458 Lint {
5912 label: "clippy::single_match", 6459 label: "clippy::single_match",
5913 description: r##"Checks for matches with a single arm where an `if let`\nwill usually suffice."##, 6460 description: r##"Checks for matches with a single arm where an `if let`\nwill usually suffice."##,
5914 }, 6461 },
5915 LintCompletion { 6462 Lint {
5916 label: "clippy::single_match_else", 6463 label: "clippy::single_match_else",
5917 description: r##"Checks for matches with two arms where an `if let else` will\nusually suffice."##, 6464 description: r##"Checks for matches with two arms where an `if let else` will\nusually suffice."##,
5918 }, 6465 },
5919 LintCompletion { 6466 Lint {
5920 label: "clippy::size_of_in_element_count", 6467 label: "clippy::size_of_in_element_count",
5921 description: r##"Detects expressions where\n`size_of::<T>` or `size_of_val::<T>` is used as a\ncount of elements of type `T`"##, 6468 description: r##"Detects expressions where\n`size_of::<T>` or `size_of_val::<T>` is used as a\ncount of elements of type `T`"##,
5922 }, 6469 },
5923 LintCompletion { 6470 Lint {
5924 label: "clippy::skip_while_next", 6471 label: "clippy::skip_while_next",
5925 description: r##"Checks for usage of `_.skip_while(condition).next()`."##, 6472 description: r##"Checks for usage of `_.skip_while(condition).next()`."##,
5926 }, 6473 },
5927 LintCompletion { 6474 Lint {
5928 label: "clippy::slow_vector_initialization", 6475 label: "clippy::slow_vector_initialization",
5929 description: r##"Checks slow zero-filled vector initialization"##, 6476 description: r##"Checks slow zero-filled vector initialization"##,
5930 }, 6477 },
5931 LintCompletion { 6478 Lint {
5932 label: "clippy::stable_sort_primitive", 6479 label: "clippy::stable_sort_primitive",
5933 description: r##"When sorting primitive values (integers, bools, chars, as well\nas arrays, slices, and tuples of such items), it is better to\nuse an unstable sort than a stable sort."##, 6480 description: r##"When sorting primitive values (integers, bools, chars, as well\nas arrays, slices, and tuples of such items), it is better to\nuse an unstable sort than a stable sort."##,
5934 }, 6481 },
5935 LintCompletion { 6482 Lint {
5936 label: "clippy::str_to_string", 6483 label: "clippy::str_to_string",
5937 description: r##"This lint checks for `.to_string()` method calls on values of type `&str`."##, 6484 description: r##"This lint checks for `.to_string()` method calls on values of type `&str`."##,
5938 }, 6485 },
5939 LintCompletion { 6486 Lint {
5940 label: "clippy::string_add", 6487 label: "clippy::string_add",
5941 description: r##"Checks for all instances of `x + _` where `x` is of type\n`String`, but only if [`string_add_assign`](#string_add_assign) does *not*\nmatch."##, 6488 description: r##"Checks for all instances of `x + _` where `x` is of type\n`String`, but only if [`string_add_assign`](#string_add_assign) does *not*\nmatch."##,
5942 }, 6489 },
5943 LintCompletion { 6490 Lint {
5944 label: "clippy::string_add_assign", 6491 label: "clippy::string_add_assign",
5945 description: r##"Checks for string appends of the form `x = x + y` (without\n`let`!)."##, 6492 description: r##"Checks for string appends of the form `x = x + y` (without\n`let`!)."##,
5946 }, 6493 },
5947 LintCompletion { 6494 Lint {
5948 label: "clippy::string_extend_chars", 6495 label: "clippy::string_extend_chars",
5949 description: r##"Checks for the use of `.extend(s.chars())` where s is a\n`&str` or `String`."##, 6496 description: r##"Checks for the use of `.extend(s.chars())` where s is a\n`&str` or `String`."##,
5950 }, 6497 },
5951 LintCompletion { 6498 Lint {
5952 label: "clippy::string_from_utf8_as_bytes", 6499 label: "clippy::string_from_utf8_as_bytes",
5953 description: r##"Check if the string is transformed to byte array and casted back to string."##, 6500 description: r##"Check if the string is transformed to byte array and casted back to string."##,
5954 }, 6501 },
5955 LintCompletion { 6502 Lint {
5956 label: "clippy::string_lit_as_bytes", 6503 label: "clippy::string_lit_as_bytes",
5957 description: r##"Checks for the `as_bytes` method called on string literals\nthat contain only ASCII characters."##, 6504 description: r##"Checks for the `as_bytes` method called on string literals\nthat contain only ASCII characters."##,
5958 }, 6505 },
5959 LintCompletion { 6506 Lint {
5960 label: "clippy::string_to_string", 6507 label: "clippy::string_to_string",
5961 description: r##"This lint checks for `.to_string()` method calls on values of type `String`."##, 6508 description: r##"This lint checks for `.to_string()` method calls on values of type `String`."##,
5962 }, 6509 },
5963 LintCompletion { 6510 Lint {
5964 label: "clippy::struct_excessive_bools", 6511 label: "clippy::struct_excessive_bools",
5965 description: r##"Checks for excessive\nuse of bools in structs."##, 6512 description: r##"Checks for excessive\nuse of bools in structs."##,
5966 }, 6513 },
5967 LintCompletion { 6514 Lint {
5968 label: "clippy::suboptimal_flops", 6515 label: "clippy::suboptimal_flops",
5969 description: r##"Looks for floating-point expressions that\ncan be expressed using built-in methods to improve both\naccuracy and performance."##, 6516 description: r##"Looks for floating-point expressions that\ncan be expressed using built-in methods to improve both\naccuracy and performance."##,
5970 }, 6517 },
5971 LintCompletion { 6518 Lint {
5972 label: "clippy::suspicious_arithmetic_impl", 6519 label: "clippy::suspicious_arithmetic_impl",
5973 description: r##"Lints for suspicious operations in impls of arithmetic operators, e.g.\nsubtracting elements in an Add impl."##, 6520 description: r##"Lints for suspicious operations in impls of arithmetic operators, e.g.\nsubtracting elements in an Add impl."##,
5974 }, 6521 },
5975 LintCompletion { 6522 Lint {
5976 label: "clippy::suspicious_assignment_formatting", 6523 label: "clippy::suspicious_assignment_formatting",
5977 description: r##"Checks for use of the non-existent `=*`, `=!` and `=-`\noperators."##, 6524 description: r##"Checks for use of the non-existent `=*`, `=!` and `=-`\noperators."##,
5978 }, 6525 },
5979 LintCompletion { 6526 Lint {
5980 label: "clippy::suspicious_else_formatting", 6527 label: "clippy::suspicious_else_formatting",
5981 description: r##"Checks for formatting of `else`. It lints if the `else`\nis followed immediately by a newline or the `else` seems to be missing."##, 6528 description: r##"Checks for formatting of `else`. It lints if the `else`\nis followed immediately by a newline or the `else` seems to be missing."##,
5982 }, 6529 },
5983 LintCompletion { 6530 Lint {
5984 label: "clippy::suspicious_map", 6531 label: "clippy::suspicious_map",
5985 description: r##"Checks for calls to `map` followed by a `count`."##, 6532 description: r##"Checks for calls to `map` followed by a `count`."##,
5986 }, 6533 },
5987 LintCompletion { 6534 Lint {
5988 label: "clippy::suspicious_op_assign_impl", 6535 label: "clippy::suspicious_op_assign_impl",
5989 description: r##"Lints for suspicious operations in impls of OpAssign, e.g.\nsubtracting elements in an AddAssign impl."##, 6536 description: r##"Lints for suspicious operations in impls of OpAssign, e.g.\nsubtracting elements in an AddAssign impl."##,
5990 }, 6537 },
5991 LintCompletion { 6538 Lint {
5992 label: "clippy::suspicious_operation_groupings", 6539 label: "clippy::suspicious_operation_groupings",
5993 description: r##"Checks for unlikely usages of binary operators that are almost\ncertainly typos and/or copy/paste errors, given the other usages\nof binary operators nearby."##, 6540 description: r##"Checks for unlikely usages of binary operators that are almost\ncertainly typos and/or copy/paste errors, given the other usages\nof binary operators nearby."##,
5994 }, 6541 },
5995 LintCompletion { 6542 Lint {
6543 label: "clippy::suspicious_splitn",
6544 description: r##"Checks for calls to [`splitn`]\n(https://doc.rust-lang.org/std/primitive.str.html#method.splitn) and\nrelated functions with either zero or one splits."##,
6545 },
6546 Lint {
5996 label: "clippy::suspicious_unary_op_formatting", 6547 label: "clippy::suspicious_unary_op_formatting",
5997 description: r##"Checks the formatting of a unary operator on the right hand side\nof a binary operator. It lints if there is no space between the binary and unary operators,\nbut there is a space between the unary and its operand."##, 6548 description: r##"Checks the formatting of a unary operator on the right hand side\nof a binary operator. It lints if there is no space between the binary and unary operators,\nbut there is a space between the unary and its operand."##,
5998 }, 6549 },
5999 LintCompletion { 6550 Lint {
6000 label: "clippy::tabs_in_doc_comments", 6551 label: "clippy::tabs_in_doc_comments",
6001 description: r##"Checks doc comments for usage of tab characters."##, 6552 description: r##"Checks doc comments for usage of tab characters."##,
6002 }, 6553 },
6003 LintCompletion { 6554 Lint {
6004 label: "clippy::temporary_assignment", 6555 label: "clippy::temporary_assignment",
6005 description: r##"Checks for construction of a structure or tuple just to\nassign a value in it."##, 6556 description: r##"Checks for construction of a structure or tuple just to\nassign a value in it."##,
6006 }, 6557 },
6007 LintCompletion { 6558 Lint {
6008 label: "clippy::temporary_cstring_as_ptr",
6009 description: r##"Nothing. This lint has been deprecated."##,
6010 },
6011 LintCompletion {
6012 label: "clippy::to_digit_is_some", 6559 label: "clippy::to_digit_is_some",
6013 description: r##"Checks for `.to_digit(..).is_some()` on `char`s."##, 6560 description: r##"Checks for `.to_digit(..).is_some()` on `char`s."##,
6014 }, 6561 },
6015 LintCompletion { 6562 Lint {
6016 label: "clippy::to_string_in_display", 6563 label: "clippy::to_string_in_display",
6017 description: r##"Checks for uses of `to_string()` in `Display` traits."##, 6564 description: r##"Checks for uses of `to_string()` in `Display` traits."##,
6018 }, 6565 },
6019 LintCompletion { label: "clippy::todo", description: r##"Checks for usage of `todo!`."## }, 6566 Lint { label: "clippy::todo", description: r##"Checks for usage of `todo!`."## },
6020 LintCompletion { 6567 Lint {
6021 label: "clippy::too_many_arguments", 6568 label: "clippy::too_many_arguments",
6022 description: r##"Checks for functions with too many parameters."##, 6569 description: r##"Checks for functions with too many parameters."##,
6023 }, 6570 },
6024 LintCompletion { 6571 Lint {
6025 label: "clippy::too_many_lines", 6572 label: "clippy::too_many_lines",
6026 description: r##"Checks for functions with a large amount of lines."##, 6573 description: r##"Checks for functions with a large amount of lines."##,
6027 }, 6574 },
6028 LintCompletion { 6575 Lint {
6029 label: "clippy::toplevel_ref_arg", 6576 label: "clippy::toplevel_ref_arg",
6030 description: r##"Checks for function arguments and let bindings denoted as\n`ref`."##, 6577 description: r##"Checks for function arguments and let bindings denoted as\n`ref`."##,
6031 }, 6578 },
6032 LintCompletion { 6579 Lint {
6033 label: "clippy::trait_duplication_in_bounds", 6580 label: "clippy::trait_duplication_in_bounds",
6034 description: r##"Checks for cases where generics are being used and multiple\nsyntax specifications for trait bounds are used simultaneously."##, 6581 description: r##"Checks for cases where generics are being used and multiple\nsyntax specifications for trait bounds are used simultaneously."##,
6035 }, 6582 },
6036 LintCompletion { 6583 Lint {
6037 label: "clippy::transmute_bytes_to_str", 6584 label: "clippy::transmute_bytes_to_str",
6038 description: r##"Checks for transmutes from a `&[u8]` to a `&str`."##, 6585 description: r##"Checks for transmutes from a `&[u8]` to a `&str`."##,
6039 }, 6586 },
6040 LintCompletion { 6587 Lint {
6041 label: "clippy::transmute_float_to_int", 6588 label: "clippy::transmute_float_to_int",
6042 description: r##"Checks for transmutes from a float to an integer."##, 6589 description: r##"Checks for transmutes from a float to an integer."##,
6043 }, 6590 },
6044 LintCompletion { 6591 Lint {
6045 label: "clippy::transmute_int_to_bool", 6592 label: "clippy::transmute_int_to_bool",
6046 description: r##"Checks for transmutes from an integer to a `bool`."##, 6593 description: r##"Checks for transmutes from an integer to a `bool`."##,
6047 }, 6594 },
6048 LintCompletion { 6595 Lint {
6049 label: "clippy::transmute_int_to_char", 6596 label: "clippy::transmute_int_to_char",
6050 description: r##"Checks for transmutes from an integer to a `char`."##, 6597 description: r##"Checks for transmutes from an integer to a `char`."##,
6051 }, 6598 },
6052 LintCompletion { 6599 Lint {
6053 label: "clippy::transmute_int_to_float", 6600 label: "clippy::transmute_int_to_float",
6054 description: r##"Checks for transmutes from an integer to a float."##, 6601 description: r##"Checks for transmutes from an integer to a float."##,
6055 }, 6602 },
6056 LintCompletion { 6603 Lint {
6057 label: "clippy::transmute_ptr_to_ptr", 6604 label: "clippy::transmute_ptr_to_ptr",
6058 description: r##"Checks for transmutes from a pointer to a pointer, or\nfrom a reference to a reference."##, 6605 description: r##"Checks for transmutes from a pointer to a pointer, or\nfrom a reference to a reference."##,
6059 }, 6606 },
6060 LintCompletion { 6607 Lint {
6061 label: "clippy::transmute_ptr_to_ref", 6608 label: "clippy::transmute_ptr_to_ref",
6062 description: r##"Checks for transmutes from a pointer to a reference."##, 6609 description: r##"Checks for transmutes from a pointer to a reference."##,
6063 }, 6610 },
6064 LintCompletion { 6611 Lint {
6065 label: "clippy::transmutes_expressible_as_ptr_casts", 6612 label: "clippy::transmutes_expressible_as_ptr_casts",
6066 description: r##"Checks for transmutes that could be a pointer cast."##, 6613 description: r##"Checks for transmutes that could be a pointer cast."##,
6067 }, 6614 },
6068 LintCompletion { 6615 Lint {
6069 label: "clippy::transmuting_null", 6616 label: "clippy::transmuting_null",
6070 description: r##"Checks for transmute calls which would receive a null pointer."##, 6617 description: r##"Checks for transmute calls which would receive a null pointer."##,
6071 }, 6618 },
6072 LintCompletion { 6619 Lint {
6073 label: "clippy::trivial_regex", 6620 label: "clippy::trivial_regex",
6074 description: r##"Checks for trivial [regex](https://crates.io/crates/regex)\ncreation (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`)."##, 6621 description: r##"Checks for trivial [regex](https://crates.io/crates/regex)\ncreation (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`)."##,
6075 }, 6622 },
6076 LintCompletion { 6623 Lint {
6077 label: "clippy::trivially_copy_pass_by_ref", 6624 label: "clippy::trivially_copy_pass_by_ref",
6078 description: r##"Checks for functions taking arguments by reference, where\nthe argument type is `Copy` and small enough to be more efficient to always\npass by value."##, 6625 description: r##"Checks for functions taking arguments by reference, where\nthe argument type is `Copy` and small enough to be more efficient to always\npass by value."##,
6079 }, 6626 },
6080 LintCompletion { 6627 Lint { label: "clippy::try_err", description: r##"Checks for usages of `Err(x)?`."## },
6081 label: "clippy::try_err", 6628 Lint {
6082 description: r##"Checks for usages of `Err(x)?`."##,
6083 },
6084 LintCompletion {
6085 label: "clippy::type_complexity", 6629 label: "clippy::type_complexity",
6086 description: r##"Checks for types used in structs, parameters and `let`\ndeclarations above a certain complexity threshold."##, 6630 description: r##"Checks for types used in structs, parameters and `let`\ndeclarations above a certain complexity threshold."##,
6087 }, 6631 },
6088 LintCompletion { 6632 Lint {
6089 label: "clippy::type_repetition_in_bounds", 6633 label: "clippy::type_repetition_in_bounds",
6090 description: r##"This lint warns about unnecessary type repetitions in trait bounds"##, 6634 description: r##"This lint warns about unnecessary type repetitions in trait bounds"##,
6091 }, 6635 },
6092 LintCompletion { 6636 Lint {
6093 label: "clippy::undropped_manually_drops", 6637 label: "clippy::undropped_manually_drops",
6094 description: r##"Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`."##, 6638 description: r##"Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`."##,
6095 }, 6639 },
6096 LintCompletion { 6640 Lint {
6097 label: "clippy::unicode_not_nfc", 6641 label: "clippy::unicode_not_nfc",
6098 description: r##"Checks for string literals that contain Unicode in a form\nthat is not equal to its\n[NFC-recomposition](http://www.unicode.org/reports/tr15/#Norm_Forms)."##, 6642 description: r##"Checks for string literals that contain Unicode in a form\nthat is not equal to its\n[NFC-recomposition](http://www.unicode.org/reports/tr15/#Norm_Forms)."##,
6099 }, 6643 },
6100 LintCompletion { 6644 Lint {
6101 label: "clippy::unimplemented", 6645 label: "clippy::unimplemented",
6102 description: r##"Checks for usage of `unimplemented!`."##, 6646 description: r##"Checks for usage of `unimplemented!`."##,
6103 }, 6647 },
6104 LintCompletion { 6648 Lint {
6105 label: "clippy::uninit_assumed_init", 6649 label: "clippy::uninit_assumed_init",
6106 description: r##"Checks for `MaybeUninit::uninit().assume_init()`."##, 6650 description: r##"Checks for `MaybeUninit::uninit().assume_init()`."##,
6107 }, 6651 },
6108 LintCompletion { 6652 Lint {
6109 label: "clippy::unit_arg", 6653 label: "clippy::unit_arg",
6110 description: r##"Checks for passing a unit value as an argument to a function without using a\nunit literal (`()`)."##, 6654 description: r##"Checks for passing a unit value as an argument to a function without using a\nunit literal (`()`)."##,
6111 }, 6655 },
6112 LintCompletion { 6656 Lint {
6113 label: "clippy::unit_cmp", 6657 label: "clippy::unit_cmp",
6114 description: r##"Checks for comparisons to unit. This includes all binary\ncomparisons (like `==` and `<`) and asserts."##, 6658 description: r##"Checks for comparisons to unit. This includes all binary\ncomparisons (like `==` and `<`) and asserts."##,
6115 }, 6659 },
6116 LintCompletion { 6660 Lint {
6117 label: "clippy::unit_return_expecting_ord", 6661 label: "clippy::unit_return_expecting_ord",
6118 description: r##"Checks for functions that expect closures of type\nFn(...) -> Ord where the implemented closure returns the unit type.\nThe lint also suggests to remove the semi-colon at the end of the statement if present."##, 6662 description: r##"Checks for functions that expect closures of type\nFn(...) -> Ord where the implemented closure returns the unit type.\nThe lint also suggests to remove the semi-colon at the end of the statement if present."##,
6119 }, 6663 },
6120 LintCompletion { 6664 Lint {
6121 label: "clippy::unknown_clippy_lints",
6122 description: r##"Nothing. This lint has been deprecated."##,
6123 },
6124 LintCompletion {
6125 label: "clippy::unnecessary_cast", 6665 label: "clippy::unnecessary_cast",
6126 description: r##"Checks for casts to the same type, casts of int literals to integer types\nand casts of float literals to float types."##, 6666 description: r##"Checks for casts to the same type, casts of int literals to integer types\nand casts of float literals to float types."##,
6127 }, 6667 },
6128 LintCompletion { 6668 Lint {
6129 label: "clippy::unnecessary_filter_map", 6669 label: "clippy::unnecessary_filter_map",
6130 description: r##"Checks for `filter_map` calls which could be replaced by `filter` or `map`.\nMore specifically it checks if the closure provided is only performing one of the\nfilter or map operations and suggests the appropriate option."##, 6670 description: r##"Checks for `filter_map` calls which could be replaced by `filter` or `map`.\nMore specifically it checks if the closure provided is only performing one of the\nfilter or map operations and suggests the appropriate option."##,
6131 }, 6671 },
6132 LintCompletion { 6672 Lint {
6133 label: "clippy::unnecessary_fold", 6673 label: "clippy::unnecessary_fold",
6134 description: r##"Checks for using `fold` when a more succinct alternative exists.\nSpecifically, this checks for `fold`s which could be replaced by `any`, `all`,\n`sum` or `product`."##, 6674 description: r##"Checks for using `fold` when a more succinct alternative exists.\nSpecifically, this checks for `fold`s which could be replaced by `any`, `all`,\n`sum` or `product`."##,
6135 }, 6675 },
6136 LintCompletion { 6676 Lint {
6137 label: "clippy::unnecessary_lazy_evaluations", 6677 label: "clippy::unnecessary_lazy_evaluations",
6138 description: r##"As the counterpart to `or_fun_call`, this lint looks for unnecessary\nlazily evaluated closures on `Option` and `Result`.\n\nThis lint suggests changing the following functions, when eager evaluation results in\nsimpler code:\n - `unwrap_or_else` to `unwrap_or`\n - `and_then` to `and`\n - `or_else` to `or`\n - `get_or_insert_with` to `get_or_insert`\n - `ok_or_else` to `ok_or`"##, 6678 description: r##"As the counterpart to `or_fun_call`, this lint looks for unnecessary\nlazily evaluated closures on `Option` and `Result`.\n\nThis lint suggests changing the following functions, when eager evaluation results in\nsimpler code:\n - `unwrap_or_else` to `unwrap_or`\n - `and_then` to `and`\n - `or_else` to `or`\n - `get_or_insert_with` to `get_or_insert`\n - `ok_or_else` to `ok_or`"##,
6139 }, 6679 },
6140 LintCompletion { 6680 Lint {
6141 label: "clippy::unnecessary_mut_passed", 6681 label: "clippy::unnecessary_mut_passed",
6142 description: r##"Detects passing a mutable reference to a function that only\nrequires an immutable reference."##, 6682 description: r##"Detects passing a mutable reference to a function that only\nrequires an immutable reference."##,
6143 }, 6683 },
6144 LintCompletion { 6684 Lint {
6145 label: "clippy::unnecessary_operation", 6685 label: "clippy::unnecessary_operation",
6146 description: r##"Checks for expression statements that can be reduced to a\nsub-expression."##, 6686 description: r##"Checks for expression statements that can be reduced to a\nsub-expression."##,
6147 }, 6687 },
6148 LintCompletion { 6688 Lint {
6689 label: "clippy::unnecessary_self_imports",
6690 description: r##"Checks for imports ending in `::{self}`."##,
6691 },
6692 Lint {
6149 label: "clippy::unnecessary_sort_by", 6693 label: "clippy::unnecessary_sort_by",
6150 description: r##"Detects uses of `Vec::sort_by` passing in a closure\nwhich compares the two arguments, either directly or indirectly."##, 6694 description: r##"Detects uses of `Vec::sort_by` passing in a closure\nwhich compares the two arguments, either directly or indirectly."##,
6151 }, 6695 },
6152 LintCompletion { 6696 Lint {
6153 label: "clippy::unnecessary_unwrap", 6697 label: "clippy::unnecessary_unwrap",
6154 description: r##"Checks for calls of `unwrap[_err]()` that cannot fail."##, 6698 description: r##"Checks for calls of `unwrap[_err]()` that cannot fail."##,
6155 }, 6699 },
6156 LintCompletion { 6700 Lint {
6157 label: "clippy::unnecessary_wraps", 6701 label: "clippy::unnecessary_wraps",
6158 description: r##"Checks for private functions that only return `Ok` or `Some`."##, 6702 description: r##"Checks for private functions that only return `Ok` or `Some`."##,
6159 }, 6703 },
6160 LintCompletion { 6704 Lint {
6161 label: "clippy::unneeded_field_pattern", 6705 label: "clippy::unneeded_field_pattern",
6162 description: r##"Checks for structure field patterns bound to wildcards."##, 6706 description: r##"Checks for structure field patterns bound to wildcards."##,
6163 }, 6707 },
6164 LintCompletion { 6708 Lint {
6165 label: "clippy::unneeded_wildcard_pattern", 6709 label: "clippy::unneeded_wildcard_pattern",
6166 description: r##"Checks for tuple patterns with a wildcard\npattern (`_`) is next to a rest pattern (`..`).\n\n_NOTE_: While `_, ..` means there is at least one element left, `..`\nmeans there are 0 or more elements left. This can make a difference\nwhen refactoring, but shouldn't result in errors in the refactored code,\nsince the wildcard pattern isn't used anyway."##, 6710 description: r##"Checks for tuple patterns with a wildcard\npattern (`_`) is next to a rest pattern (`..`).\n\n_NOTE_: While `_, ..` means there is at least one element left, `..`\nmeans there are 0 or more elements left. This can make a difference\nwhen refactoring, but shouldn't result in errors in the refactored code,\nsince the wildcard pattern isn't used anyway."##,
6167 }, 6711 },
6168 LintCompletion { 6712 Lint {
6169 label: "clippy::unnested_or_patterns", 6713 label: "clippy::unnested_or_patterns",
6170 description: r##"Checks for unnested or-patterns, e.g., `Some(0) | Some(2)` and\nsuggests replacing the pattern with a nested one, `Some(0 | 2)`.\n\nAnother way to think of this is that it rewrites patterns in\n*disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*."##, 6714 description: r##"Checks for unnested or-patterns, e.g., `Some(0) | Some(2)` and\nsuggests replacing the pattern with a nested one, `Some(0 | 2)`.\n\nAnother way to think of this is that it rewrites patterns in\n*disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*."##,
6171 }, 6715 },
6172 LintCompletion { 6716 Lint { label: "clippy::unreachable", description: r##"Checks for usage of `unreachable!`."## },
6173 label: "clippy::unreachable", 6717 Lint {
6174 description: r##"Checks for usage of `unreachable!`."##,
6175 },
6176 LintCompletion {
6177 label: "clippy::unreadable_literal", 6718 label: "clippy::unreadable_literal",
6178 description: r##"Warns if a long integral or floating-point constant does\nnot contain underscores."##, 6719 description: r##"Warns if a long integral or floating-point constant does\nnot contain underscores."##,
6179 }, 6720 },
6180 LintCompletion { 6721 Lint {
6181 label: "clippy::unsafe_derive_deserialize", 6722 label: "clippy::unsafe_derive_deserialize",
6182 description: r##"Checks for deriving `serde::Deserialize` on a type that\nhas methods using `unsafe`."##, 6723 description: r##"Checks for deriving `serde::Deserialize` on a type that\nhas methods using `unsafe`."##,
6183 }, 6724 },
6184 LintCompletion { 6725 Lint {
6185 label: "clippy::unsafe_removed_from_name", 6726 label: "clippy::unsafe_removed_from_name",
6186 description: r##"Checks for imports that remove \"unsafe\" from an item's\nname."##, 6727 description: r##"Checks for imports that remove \"unsafe\" from an item's\nname."##,
6187 }, 6728 },
6188 LintCompletion { 6729 Lint {
6189 label: "clippy::unsafe_vector_initialization", 6730 label: "clippy::unsafe_vector_initialization",
6190 description: r##"Nothing. This lint has been deprecated."##, 6731 description: r##"Nothing. This lint has been deprecated."##,
6191 }, 6732 },
6192 LintCompletion { 6733 Lint {
6193 label: "clippy::unseparated_literal_suffix", 6734 label: "clippy::unseparated_literal_suffix",
6194 description: r##"Warns if literal suffixes are not separated by an\nunderscore."##, 6735 description: r##"Warns if literal suffixes are not separated by an\nunderscore."##,
6195 }, 6736 },
6196 LintCompletion { 6737 Lint {
6197 label: "clippy::unsound_collection_transmute", 6738 label: "clippy::unsound_collection_transmute",
6198 description: r##"Checks for transmutes between collections whose\ntypes have different ABI, size or alignment."##, 6739 description: r##"Checks for transmutes between collections whose\ntypes have different ABI, size or alignment."##,
6199 }, 6740 },
6200 LintCompletion { 6741 Lint {
6201 label: "clippy::unstable_as_mut_slice", 6742 label: "clippy::unstable_as_mut_slice",
6202 description: r##"Nothing. This lint has been deprecated."##, 6743 description: r##"Nothing. This lint has been deprecated."##,
6203 }, 6744 },
6204 LintCompletion { 6745 Lint {
6205 label: "clippy::unstable_as_slice", 6746 label: "clippy::unstable_as_slice",
6206 description: r##"Nothing. This lint has been deprecated."##, 6747 description: r##"Nothing. This lint has been deprecated."##,
6207 }, 6748 },
6208 LintCompletion { 6749 Lint {
6750 label: "clippy::unused_async",
6751 description: r##"Checks for functions that are declared `async` but have no `.await`s inside of them."##,
6752 },
6753 Lint {
6209 label: "clippy::unused_collect", 6754 label: "clippy::unused_collect",
6210 description: r##"Nothing. This lint has been deprecated."##, 6755 description: r##"Nothing. This lint has been deprecated."##,
6211 }, 6756 },
6212 LintCompletion { 6757 Lint {
6213 label: "clippy::unused_io_amount", 6758 label: "clippy::unused_io_amount",
6214 description: r##"Checks for unused written/read amount."##, 6759 description: r##"Checks for unused written/read amount."##,
6215 }, 6760 },
6216 LintCompletion { 6761 Lint {
6217 label: "clippy::unused_label",
6218 description: r##"Nothing. This lint has been deprecated."##,
6219 },
6220 LintCompletion {
6221 label: "clippy::unused_self", 6762 label: "clippy::unused_self",
6222 description: r##"Checks methods that contain a `self` argument but don't use it"##, 6763 description: r##"Checks methods that contain a `self` argument but don't use it"##,
6223 }, 6764 },
6224 LintCompletion { 6765 Lint {
6225 label: "clippy::unused_unit", 6766 label: "clippy::unused_unit",
6226 description: r##"Checks for unit (`()`) expressions that can be removed."##, 6767 description: r##"Checks for unit (`()`) expressions that can be removed."##,
6227 }, 6768 },
6228 LintCompletion { 6769 Lint {
6229 label: "clippy::unusual_byte_groupings", 6770 label: "clippy::unusual_byte_groupings",
6230 description: r##"Warns if hexadecimal or binary literals are not grouped\nby nibble or byte."##, 6771 description: r##"Warns if hexadecimal or binary literals are not grouped\nby nibble or byte."##,
6231 }, 6772 },
6232 LintCompletion { 6773 Lint {
6233 label: "clippy::unwrap_in_result", 6774 label: "clippy::unwrap_in_result",
6234 description: r##"Checks for functions of type Result that contain `expect()` or `unwrap()`"##, 6775 description: r##"Checks for functions of type Result that contain `expect()` or `unwrap()`"##,
6235 }, 6776 },
6236 LintCompletion { 6777 Lint {
6237 label: "clippy::unwrap_used", 6778 label: "clippy::unwrap_used",
6238 description: r##"Checks for `.unwrap()` calls on `Option`s and on `Result`s."##, 6779 description: r##"Checks for `.unwrap()` calls on `Option`s and on `Result`s."##,
6239 }, 6780 },
6240 LintCompletion { 6781 Lint {
6241 label: "clippy::upper_case_acronyms", 6782 label: "clippy::upper_case_acronyms",
6242 description: r##"Checks for fully capitalized names and optionally names containing a capitalized acronym."##, 6783 description: r##"Checks for fully capitalized names and optionally names containing a capitalized acronym."##,
6243 }, 6784 },
6244 LintCompletion { 6785 Lint {
6245 label: "clippy::use_debug", 6786 label: "clippy::use_debug",
6246 description: r##"Checks for use of `Debug` formatting. The purpose of this\nlint is to catch debugging remnants."##, 6787 description: r##"Checks for use of `Debug` formatting. The purpose of this\nlint is to catch debugging remnants."##,
6247 }, 6788 },
6248 LintCompletion { 6789 Lint {
6249 label: "clippy::use_self", 6790 label: "clippy::use_self",
6250 description: r##"Checks for unnecessary repetition of structure name when a\nreplacement with `Self` is applicable."##, 6791 description: r##"Checks for unnecessary repetition of structure name when a\nreplacement with `Self` is applicable."##,
6251 }, 6792 },
6252 LintCompletion { 6793 Lint {
6253 label: "clippy::used_underscore_binding", 6794 label: "clippy::used_underscore_binding",
6254 description: r##"Checks for the use of bindings with a single leading\nunderscore."##, 6795 description: r##"Checks for the use of bindings with a single leading\nunderscore."##,
6255 }, 6796 },
6256 LintCompletion { 6797 Lint {
6257 label: "clippy::useless_asref", 6798 label: "clippy::useless_asref",
6258 description: r##"Checks for usage of `.as_ref()` or `.as_mut()` where the\ntypes before and after the call are the same."##, 6799 description: r##"Checks for usage of `.as_ref()` or `.as_mut()` where the\ntypes before and after the call are the same."##,
6259 }, 6800 },
6260 LintCompletion { 6801 Lint {
6261 label: "clippy::useless_attribute", 6802 label: "clippy::useless_attribute",
6262 description: r##"Checks for `extern crate` and `use` items annotated with\nlint attributes.\n\nThis lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]`,\n`#[allow(unreachable_pub)]`, `#[allow(clippy::wildcard_imports)]` and\n`#[allow(clippy::enum_glob_use)]` on `use` items and `#[allow(unused_imports)]` on\n`extern crate` items with a `#[macro_use]` attribute."##, 6803 description: r##"Checks for `extern crate` and `use` items annotated with\nlint attributes.\n\nThis lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]`,\n`#[allow(unreachable_pub)]`, `#[allow(clippy::wildcard_imports)]` and\n`#[allow(clippy::enum_glob_use)]` on `use` items and `#[allow(unused_imports)]` on\n`extern crate` items with a `#[macro_use]` attribute."##,
6263 }, 6804 },
6264 LintCompletion { 6805 Lint {
6265 label: "clippy::useless_conversion", 6806 label: "clippy::useless_conversion",
6266 description: r##"Checks for `Into`, `TryInto`, `From`, `TryFrom`, or `IntoIter` calls\nwhich uselessly convert to the same type."##, 6807 description: r##"Checks for `Into`, `TryInto`, `From`, `TryFrom`, or `IntoIter` calls\nwhich uselessly convert to the same type."##,
6267 }, 6808 },
6268 LintCompletion { 6809 Lint {
6269 label: "clippy::useless_format", 6810 label: "clippy::useless_format",
6270 description: r##"Checks for the use of `format!(\"string literal with no\nargument\")` and `format!(\"{}\", foo)` where `foo` is a string."##, 6811 description: r##"Checks for the use of `format!(\"string literal with no\nargument\")` and `format!(\"{}\", foo)` where `foo` is a string."##,
6271 }, 6812 },
6272 LintCompletion { 6813 Lint {
6273 label: "clippy::useless_let_if_seq", 6814 label: "clippy::useless_let_if_seq",
6274 description: r##"Checks for variable declarations immediately followed by a\nconditional affectation."##, 6815 description: r##"Checks for variable declarations immediately followed by a\nconditional affectation."##,
6275 }, 6816 },
6276 LintCompletion { 6817 Lint {
6277 label: "clippy::useless_transmute", 6818 label: "clippy::useless_transmute",
6278 description: r##"Checks for transmutes to the original type of the object\nand transmutes that could be a cast."##, 6819 description: r##"Checks for transmutes to the original type of the object\nand transmutes that could be a cast."##,
6279 }, 6820 },
6280 LintCompletion { 6821 Lint {
6281 label: "clippy::useless_vec", 6822 label: "clippy::useless_vec",
6282 description: r##"Checks for usage of `&vec![..]` when using `&[..]` would\nbe possible."##, 6823 description: r##"Checks for usage of `&vec![..]` when using `&[..]` would\nbe possible."##,
6283 }, 6824 },
6284 LintCompletion { 6825 Lint {
6285 label: "clippy::vec_box", 6826 label: "clippy::vec_box",
6286 description: r##"Checks for use of `Vec<Box<T>>` where T: Sized anywhere in the code.\nCheck the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##, 6827 description: r##"Checks for use of `Vec<Box<T>>` where T: Sized anywhere in the code.\nCheck the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information."##,
6287 }, 6828 },
6288 LintCompletion { 6829 Lint {
6289 label: "clippy::vec_init_then_push", 6830 label: "clippy::vec_init_then_push",
6290 description: r##"Checks for calls to `push` immediately after creating a new `Vec`."##, 6831 description: r##"Checks for calls to `push` immediately after creating a new `Vec`."##,
6291 }, 6832 },
6292 LintCompletion { 6833 Lint {
6293 label: "clippy::vec_resize_to_zero", 6834 label: "clippy::vec_resize_to_zero",
6294 description: r##"Finds occurrences of `Vec::resize(0, an_int)`"##, 6835 description: r##"Finds occurrences of `Vec::resize(0, an_int)`"##,
6295 }, 6836 },
6296 LintCompletion { 6837 Lint {
6297 label: "clippy::verbose_bit_mask", 6838 label: "clippy::verbose_bit_mask",
6298 description: r##"Checks for bit masks that can be replaced by a call\nto `trailing_zeros`"##, 6839 description: r##"Checks for bit masks that can be replaced by a call\nto `trailing_zeros`"##,
6299 }, 6840 },
6300 LintCompletion { 6841 Lint {
6301 label: "clippy::verbose_file_reads", 6842 label: "clippy::verbose_file_reads",
6302 description: r##"Checks for use of File::read_to_end and File::read_to_string."##, 6843 description: r##"Checks for use of File::read_to_end and File::read_to_string."##,
6303 }, 6844 },
6304 LintCompletion { 6845 Lint {
6305 label: "clippy::vtable_address_comparisons", 6846 label: "clippy::vtable_address_comparisons",
6306 description: r##"Checks for comparisons with an address of a trait vtable."##, 6847 description: r##"Checks for comparisons with an address of a trait vtable."##,
6307 }, 6848 },
6308 LintCompletion { 6849 Lint {
6309 label: "clippy::while_immutable_condition", 6850 label: "clippy::while_immutable_condition",
6310 description: r##"Checks whether variables used within while loop condition\ncan be (and are) mutated in the body."##, 6851 description: r##"Checks whether variables used within while loop condition\ncan be (and are) mutated in the body."##,
6311 }, 6852 },
6312 LintCompletion { 6853 Lint {
6313 label: "clippy::while_let_loop", 6854 label: "clippy::while_let_loop",
6314 description: r##"Detects `loop + match` combinations that are easier\nwritten as a `while let` loop."##, 6855 description: r##"Detects `loop + match` combinations that are easier\nwritten as a `while let` loop."##,
6315 }, 6856 },
6316 LintCompletion { 6857 Lint {
6317 label: "clippy::while_let_on_iterator", 6858 label: "clippy::while_let_on_iterator",
6318 description: r##"Checks for `while let` expressions on iterators."##, 6859 description: r##"Checks for `while let` expressions on iterators."##,
6319 }, 6860 },
6320 LintCompletion { 6861 Lint {
6321 label: "clippy::wildcard_dependencies", 6862 label: "clippy::wildcard_dependencies",
6322 description: r##"Checks for wildcard dependencies in the `Cargo.toml`."##, 6863 description: r##"Checks for wildcard dependencies in the `Cargo.toml`."##,
6323 }, 6864 },
6324 LintCompletion { 6865 Lint {
6325 label: "clippy::wildcard_enum_match_arm", 6866 label: "clippy::wildcard_enum_match_arm",
6326 description: r##"Checks for wildcard enum matches using `_`."##, 6867 description: r##"Checks for wildcard enum matches using `_`."##,
6327 }, 6868 },
6328 LintCompletion { 6869 Lint {
6329 label: "clippy::wildcard_imports", 6870 label: "clippy::wildcard_imports",
6330 description: r##"Checks for wildcard imports `use _::*`."##, 6871 description: r##"Checks for wildcard imports `use _::*`."##,
6331 }, 6872 },
6332 LintCompletion { 6873 Lint {
6333 label: "clippy::wildcard_in_or_patterns", 6874 label: "clippy::wildcard_in_or_patterns",
6334 description: r##"Checks for wildcard pattern used with others patterns in same match arm."##, 6875 description: r##"Checks for wildcard pattern used with others patterns in same match arm."##,
6335 }, 6876 },
6336 LintCompletion { 6877 Lint {
6337 label: "clippy::write_literal", 6878 label: "clippy::write_literal",
6338 description: r##"This lint warns about the use of literals as `write!`/`writeln!` args."##, 6879 description: r##"This lint warns about the use of literals as `write!`/`writeln!` args."##,
6339 }, 6880 },
6340 LintCompletion { 6881 Lint {
6341 label: "clippy::write_with_newline", 6882 label: "clippy::write_with_newline",
6342 description: r##"This lint warns when you use `write!()` with a format\nstring that\nends in a newline."##, 6883 description: r##"This lint warns when you use `write!()` with a format\nstring that\nends in a newline."##,
6343 }, 6884 },
6344 LintCompletion { 6885 Lint {
6345 label: "clippy::writeln_empty_string", 6886 label: "clippy::writeln_empty_string",
6346 description: r##"This lint warns when you use `writeln!(buf, \"\")` to\nprint a newline."##, 6887 description: r##"This lint warns when you use `writeln!(buf, \"\")` to\nprint a newline."##,
6347 }, 6888 },
6348 LintCompletion { 6889 Lint {
6349 label: "clippy::wrong_pub_self_convention", 6890 label: "clippy::wrong_pub_self_convention",
6350 description: r##"This is the same as\n[`wrong_self_convention`](#wrong_self_convention), but for public items."##, 6891 description: r##"Nothing. This lint has been deprecated."##,
6351 }, 6892 },
6352 LintCompletion { 6893 Lint {
6353 label: "clippy::wrong_self_convention", 6894 label: "clippy::wrong_self_convention",
6354 description: r##"Checks for methods with certain name prefixes and which\ndoesn't match how self is taken. The actual rules are:\n\n|Prefix |`self` taken |\n|-------|----------------------|\n|`as_` |`&self` or `&mut self`|\n|`from_`| none |\n|`into_`|`self` |\n|`is_` |`&self` or none |\n|`to_` |`&self` |"##, 6895 description: r##"Checks for methods with certain name prefixes and which\ndoesn't match how self is taken. The actual rules are:\n\n|Prefix |Postfix |`self` taken | `self` type |\n|-------|------------|-----------------------|--------------|\n|`as_` | none |`&self` or `&mut self` | any |\n|`from_`| none | none | any |\n|`into_`| none |`self` | any |\n|`is_` | none |`&self` or none | any |\n|`to_` | `_mut` |`&mut self` | any |\n|`to_` | not `_mut` |`self` | `Copy` |\n|`to_` | not `_mut` |`&self` | not `Copy` |\n\nNote: Clippy doesn't trigger methods with `to_` prefix in:\n- Traits definition.\nClippy can not tell if a type that implements a trait is `Copy` or not.\n- Traits implementation, when `&self` is taken.\nThe method signature is controlled by the trait and often `&self` is required for all types that implement the trait\n(see e.g. the `std::string::ToString` trait).\n\nPlease find more info here:\nhttps://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv"##,
6355 }, 6896 },
6356 LintCompletion { 6897 Lint {
6357 label: "clippy::wrong_transmute", 6898 label: "clippy::wrong_transmute",
6358 description: r##"Checks for transmutes that can't ever be correct on any\narchitecture."##, 6899 description: r##"Checks for transmutes that can't ever be correct on any\narchitecture."##,
6359 }, 6900 },
6360 LintCompletion { 6901 Lint { label: "clippy::zero_divided_by_zero", description: r##"Checks for `0.0 / 0.0`."## },
6361 label: "clippy::zero_divided_by_zero", 6902 Lint {
6362 description: r##"Checks for `0.0 / 0.0`."##,
6363 },
6364 LintCompletion {
6365 label: "clippy::zero_prefixed_literal", 6903 label: "clippy::zero_prefixed_literal",
6366 description: r##"Warns if an integral constant literal starts with `0`."##, 6904 description: r##"Warns if an integral constant literal starts with `0`."##,
6367 }, 6905 },
6368 LintCompletion { 6906 Lint {
6369 label: "clippy::zero_ptr", 6907 label: "clippy::zero_ptr",
6370 description: r##"Catch casts from `0` to some pointer type"##, 6908 description: r##"Catch casts from `0` to some pointer type"##,
6371 }, 6909 },
6372 LintCompletion { 6910 Lint {
6373 label: "clippy::zero_sized_map_values", 6911 label: "clippy::zero_sized_map_values",
6374 description: r##"Checks for maps with zero-sized value types anywhere in the code."##, 6912 description: r##"Checks for maps with zero-sized value types anywhere in the code."##,
6375 }, 6913 },
6376 LintCompletion { 6914 Lint {
6377 label: "clippy::zst_offset", 6915 label: "clippy::zst_offset",
6378 description: r##"Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to\nzero-sized types"##, 6916 description: r##"Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to\nzero-sized types"##,
6379 }, 6917 },