Skip to content

Commit 7a73990

Browse files
committed
Auto merge of #6389 - giraffate:sync-from-rust, r=llogiq
Rustup changelog: none
2 parents 403816f + e91d15f commit 7a73990

File tree

5 files changed

+3
-3120
lines changed

5 files changed

+3
-3120
lines changed

clippy_dev/src/update_lints.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,7 @@ pub fn run(update_mode: UpdateMode) {
2222

2323
let usable_lint_count = round_to_fifty(usable_lints.len());
2424

25-
let mut file_change = replace_region_in_file(
26-
Path::new("src/lintlist/mod.rs"),
27-
"begin lint list",
28-
"end lint list",
29-
false,
30-
update_mode == UpdateMode::Change,
31-
|| {
32-
format!("vec!{:#?}", sorted_usable_lints)
33-
.lines()
34-
.map(ToString::to_string)
35-
.collect::<Vec<_>>()
36-
},
37-
)
38-
.changed;
25+
let mut file_change = false;
3926

4027
file_change |= replace_region_in_file(
4128
Path::new("README.md"),

clippy_lints/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::utils::{
55
span_lint_and_sugg, span_lint_and_then, without_block_comments,
66
};
77
use if_chain::if_chain;
8-
use rustc_ast::util::lev_distance::find_best_match_for_name;
98
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
109
use rustc_errors::Applicability;
1110
use rustc_hir::{
@@ -15,6 +14,7 @@ use rustc_lint::{CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext,
1514
use rustc_middle::lint::in_external_macro;
1615
use rustc_middle::ty;
1716
use rustc_session::{declare_lint_pass, declare_tool_lint};
17+
use rustc_span::lev_distance::find_best_match_for_name;
1818
use rustc_span::source_map::Span;
1919
use rustc_span::sym;
2020
use rustc_span::symbol::{Symbol, SymbolStr};
@@ -427,7 +427,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, ident: &str, items: &[NestedMet
427427
.map(|l| Symbol::intern(&l.name_lower()))
428428
.collect::<Vec<_>>();
429429
let sugg = find_best_match_for_name(
430-
symbols.iter(),
430+
&symbols,
431431
Symbol::intern(&format!("clippy::{}", name_lower)),
432432
None,
433433
);

src/driver.rs

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
// FIXME: switch to something more ergonomic here, once available.
1010
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
11-
extern crate rustc_data_structures;
1211
extern crate rustc_driver;
1312
extern crate rustc_errors;
1413
extern crate rustc_interface;
@@ -26,8 +25,6 @@ use std::panic;
2625
use std::path::{Path, PathBuf};
2726
use std::process::{exit, Command};
2827

29-
mod lintlist;
30-
3128
/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
3229
/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
3330
fn arg_value<'a, T: Deref<Target = str>>(
@@ -92,113 +89,6 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
9289
}
9390
}
9491

95-
#[allow(clippy::find_map, clippy::filter_map)]
96-
fn describe_lints() {
97-
use lintlist::{Level, Lint, ALL_LINTS, LINT_LEVELS};
98-
use rustc_data_structures::fx::FxHashSet;
99-
100-
println!(
101-
"
102-
Available lint options:
103-
-W <foo> Warn about <foo>
104-
-A <foo> Allow <foo>
105-
-D <foo> Deny <foo>
106-
-F <foo> Forbid <foo> (deny <foo> and all attempts to override)
107-
108-
"
109-
);
110-
111-
let lint_level = |lint: &Lint| {
112-
LINT_LEVELS
113-
.iter()
114-
.find(|level_mapping| level_mapping.0 == lint.group)
115-
.map(|(_, level)| match level {
116-
Level::Allow => "allow",
117-
Level::Warn => "warn",
118-
Level::Deny => "deny",
119-
})
120-
.unwrap()
121-
};
122-
123-
let mut lints: Vec<_> = ALL_LINTS.iter().collect();
124-
// The sort doesn't case-fold but it's doubtful we care.
125-
lints.sort_by_cached_key(|x: &&Lint| (lint_level(x), x.name));
126-
127-
let max_lint_name_len = lints
128-
.iter()
129-
.map(|lint| lint.name.len())
130-
.map(|len| len + "clippy::".len())
131-
.max()
132-
.unwrap_or(0);
133-
134-
let padded = |x: &str| {
135-
let mut s = " ".repeat(max_lint_name_len - x.chars().count());
136-
s.push_str(x);
137-
s
138-
};
139-
140-
let scoped = |x: &str| format!("clippy::{}", x);
141-
142-
let lint_groups: FxHashSet<_> = lints.iter().map(|lint| lint.group).collect();
143-
144-
println!("Lint checks provided by clippy:\n");
145-
println!(" {} {:7.7} meaning", padded("name"), "default");
146-
println!(" {} {:7.7} -------", padded("----"), "-------");
147-
148-
let print_lints = |lints: &[&Lint]| {
149-
for lint in lints {
150-
let name = lint.name.replace("_", "-");
151-
println!(
152-
" {} {:7.7} {}",
153-
padded(&scoped(&name)),
154-
lint_level(lint),
155-
lint.desc
156-
);
157-
}
158-
println!("\n");
159-
};
160-
161-
print_lints(&lints);
162-
163-
let max_group_name_len = std::cmp::max(
164-
"clippy::all".len(),
165-
lint_groups
166-
.iter()
167-
.map(|group| group.len())
168-
.map(|len| len + "clippy::".len())
169-
.max()
170-
.unwrap_or(0),
171-
);
172-
173-
let padded_group = |x: &str| {
174-
let mut s = " ".repeat(max_group_name_len - x.chars().count());
175-
s.push_str(x);
176-
s
177-
};
178-
179-
println!("Lint groups provided by clippy:\n");
180-
println!(" {} sub-lints", padded_group("name"));
181-
println!(" {} ---------", padded_group("----"));
182-
println!(" {} the set of all clippy lints", padded_group("clippy::all"));
183-
184-
let print_lint_groups = || {
185-
for group in lint_groups {
186-
let name = group.to_lowercase().replace("_", "-");
187-
let desc = lints
188-
.iter()
189-
.filter(|&lint| lint.group == group)
190-
.map(|lint| lint.name)
191-
.map(|name| name.replace("_", "-"))
192-
.collect::<Vec<String>>()
193-
.join(", ");
194-
println!(" {} {}", padded_group(&scoped(&name)), desc);
195-
}
196-
println!("\n");
197-
};
198-
199-
print_lint_groups();
200-
}
201-
20292
fn display_help() {
20393
println!(
20494
"\
@@ -379,17 +269,6 @@ pub fn main() {
379269
exit(0);
380270
}
381271

382-
let should_describe_lints = || {
383-
let args: Vec<_> = env::args().collect();
384-
args.windows(2)
385-
.any(|args| args[1] == "help" && matches!(args[0].as_str(), "-W" | "-A" | "-D" | "-F"))
386-
};
387-
388-
if !wrapper_mode && should_describe_lints() {
389-
describe_lints();
390-
exit(0);
391-
}
392-
393272
// this conditional check for the --sysroot flag is there so users can call
394273
// `clippy_driver` directly
395274
// without having to pass --sysroot or anything

src/lintlist/lint.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)