Skip to content

Commit 45c1e0a

Browse files
committed
Auto-generate lint documentation.
1 parent a055c5a commit 45c1e0a

22 files changed

+3914
-1567
lines changed

Cargo.lock

+9
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,15 @@ version = "0.5.3"
16771677
source = "registry+https://github.com/rust-lang/crates.io-index"
16781678
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
16791679

1680+
[[package]]
1681+
name = "lint-docs"
1682+
version = "0.1.0"
1683+
dependencies = [
1684+
"serde_json",
1685+
"tempfile",
1686+
"walkdir",
1687+
]
1688+
16801689
[[package]]
16811690
name = "lock_api"
16821691
version = "0.3.4"

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ members = [
99
"src/tools/compiletest",
1010
"src/tools/error_index_generator",
1111
"src/tools/linkchecker",
12+
"src/tools/lint-docs",
1213
"src/tools/rustbook",
1314
"src/tools/unstable-book-gen",
1415
"src/tools/tidy",

compiler/rustc_lint/src/array_into_iter.rs

+25
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ use rustc_session::lint::FutureIncompatibleInfo;
77
use rustc_span::symbol::sym;
88

99
declare_lint! {
10+
/// The `array_into_iter` lint detects calling `into_iter` on arrays.
11+
///
12+
/// ### Example
13+
///
14+
/// ```rust
15+
/// # #![allow(unused)]
16+
/// [1, 2, 3].into_iter().for_each(|n| { *n; });
17+
/// ```
18+
///
19+
/// {{produces}}
20+
///
21+
/// ### Explanation
22+
///
23+
/// In the future, it is planned to add an `IntoIter` implementation for
24+
/// arrays such that it will iterate over *values* of the array instead of
25+
/// references. Due to how method resolution works, this will change
26+
/// existing code that uses `into_iter` on arrays. The solution to avoid
27+
/// this warning is to use `iter()` instead of `into_iter()`.
28+
///
29+
/// This is a [future-incompatible] lint to transition this to a hard error
30+
/// in the future. See [issue #66145] for more details and a more thorough
31+
/// description of the lint.
32+
///
33+
/// [issue #66145]: https://github.com/rust-lang/rust/issues/66145
34+
/// [future-incompatible]: ../index.md#future-incompatible-lints
1035
pub ARRAY_INTO_ITER,
1136
Warn,
1237
"detects calling `into_iter` on arrays",

0 commit comments

Comments
 (0)