Skip to content

Commit e5a7722

Browse files
committed
Auto merge of #4206 - rust-lang:update_lints, r=phansch
Use replace_region_in_file for creating the lint list r? @phansch changelog: none
2 parents 7a95c20 + 0e480ca commit e5a7722

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

clippy_dev/src/main.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,26 @@ fn update_lints(update_mode: &UpdateMode) {
9494
let mut sorted_usable_lints = usable_lints.clone();
9595
sorted_usable_lints.sort_by_key(|lint| lint.name.clone());
9696

97-
std::fs::write(
97+
let mut file_change = replace_region_in_file(
9898
"../src/lintlist/mod.rs",
99-
&format!(
100-
"\
101-
//! This file is managed by `util/dev update_lints`. Do not edit.
102-
103-
pub mod lint;
104-
pub use lint::Level;
105-
pub use lint::Lint;
106-
pub use lint::LINT_LEVELS;
107-
108-
pub const ALL_LINTS: [Lint; {}] = {:#?};\n",
109-
sorted_usable_lints.len(),
110-
sorted_usable_lints
111-
),
99+
"begin lint list",
100+
"end lint list",
101+
false,
102+
update_mode == &UpdateMode::Change,
103+
|| {
104+
format!(
105+
"pub const ALL_LINTS: [Lint; {}] = {:#?};",
106+
sorted_usable_lints.len(),
107+
sorted_usable_lints
108+
)
109+
.lines()
110+
.map(ToString::to_string)
111+
.collect::<Vec<_>>()
112+
},
112113
)
113-
.expect("can write to file");
114+
.changed;
114115

115-
let mut file_change = replace_region_in_file(
116+
file_change |= replace_region_in_file(
116117
"../README.md",
117118
r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#,
118119
"",

src/lintlist/mod.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ pub use lint::Level;
55
pub use lint::Lint;
66
pub use lint::LINT_LEVELS;
77

8-
pub const ALL_LINTS: [Lint; 304] = [
8+
// begin lint list, do not remove this comment, it’s used in `update_lints`
9+
pub const ALL_LINTS: [Lint; 305] = [
910
Lint {
1011
name: "absurd_extreme_comparisons",
1112
group: "correctness",
@@ -251,13 +252,6 @@ pub const ALL_LINTS: [Lint; 304] = [
251252
deprecation: None,
252253
module: "collapsible_if",
253254
},
254-
Lint {
255-
name: "const_static_lifetime",
256-
group: "style",
257-
desc: "Using explicit `\'static` lifetime for constants when elision rules would allow omitting them.",
258-
deprecation: None,
259-
module: "const_static_lifetime",
260-
},
261255
Lint {
262256
name: "copy_iterator",
263257
group: "pedantic",
@@ -762,6 +756,13 @@ pub const ALL_LINTS: [Lint; 304] = [
762756
deprecation: None,
763757
module: "arithmetic",
764758
},
759+
Lint {
760+
name: "integer_division",
761+
group: "pedantic",
762+
desc: "integer division may cause loss of precision",
763+
deprecation: None,
764+
module: "integer_division",
765+
},
765766
Lint {
766767
name: "into_iter_on_array",
767768
group: "correctness",
@@ -1525,6 +1526,13 @@ pub const ALL_LINTS: [Lint; 304] = [
15251526
deprecation: None,
15261527
module: "redundant_pattern_matching",
15271528
},
1529+
Lint {
1530+
name: "redundant_static_lifetimes",
1531+
group: "style",
1532+
desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1533+
deprecation: None,
1534+
module: "redundant_static_lifetimes",
1535+
},
15281536
Lint {
15291537
name: "ref_in_deref",
15301538
group: "complexity",
@@ -2135,3 +2143,4 @@ pub const ALL_LINTS: [Lint; 304] = [
21352143
module: "unicode",
21362144
},
21372145
];
2146+
// end lint list, do not remove this comment, it’s used in `update_lints`

0 commit comments

Comments
 (0)