Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillot

Fix clippy lints

I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.
This commit is contained in:
bors 2021-10-02 10:52:09 +00:00
commit b27661eb33
61 changed files with 458 additions and 506 deletions

View file

@ -128,7 +128,7 @@ impl Callbacks for TimePassesCallbacks {
}
pub fn diagnostics_registry() -> Registry {
Registry::new(&rustc_error_codes::DIAGNOSTICS)
Registry::new(rustc_error_codes::DIAGNOSTICS)
}
/// This is the primary entry point for rustc.
@ -265,8 +265,8 @@ fn run_compiler(
&***compiler.codegen_backend(),
compiler.session(),
None,
&compiler.output_dir(),
&compiler.output_file(),
compiler.output_dir(),
compiler.output_file(),
);
if should_stop == Compilation::Stop {
@ -330,7 +330,7 @@ fn run_compiler(
let krate = queries.parse()?.take();
pretty::print_after_parsing(
sess,
&compiler.input(),
compiler.input(),
&krate,
*ppm,
compiler.output_file().as_ref().map(|p| &**p),
@ -356,7 +356,7 @@ fn run_compiler(
// Lint plugins are registered; now we can process command line flags.
if sess.opts.describe_lints {
describe_lints(&sess, &lint_store, true);
describe_lints(sess, lint_store, true);
return early_exit();
}
}
@ -388,7 +388,7 @@ fn run_compiler(
save::process_crate(
tcx,
&crate_name,
&compiler.input(),
compiler.input(),
None,
DumpHandler::new(
compiler.output_dir().as_ref().map(|p| &**p),
@ -598,7 +598,7 @@ impl RustcDefaultCalls {
if let Input::File(file) = compiler.input() {
// FIXME: #![crate_type] and #![crate_name] support not implemented yet
sess.init_crate_types(collect_crate_types(sess, &[]));
let outputs = compiler.build_output_filenames(&sess, &[]);
let outputs = compiler.build_output_filenames(sess, &[]);
let rlink_data = fs::read_to_string(file).unwrap_or_else(|err| {
sess.fatal(&format!("failed to read rlink file: {}", err));
});
@ -606,7 +606,7 @@ impl RustcDefaultCalls {
json::decode(&rlink_data).unwrap_or_else(|err| {
sess.fatal(&format!("failed to decode rlink: {}", err));
});
let result = compiler.codegen_backend().link(&sess, codegen_results, &outputs);
let result = compiler.codegen_backend().link(sess, codegen_results, &outputs);
abort_on_err(result, sess);
} else {
sess.fatal("rlink must be a file")
@ -894,9 +894,9 @@ Available lint options:
};
println!("Lint groups provided by rustc:\n");
println!(" {} {}", padded("name"), "sub-lints");
println!(" {} {}", padded("----"), "---------");
println!(" {} {}", padded("warnings"), "all lints that are set to issue warnings");
println!(" {} sub-lints", padded("name"));
println!(" {} ---------", padded("----"));
println!(" {} all lints that are set to issue warnings", padded("warnings"));
let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>| {
for (name, to) in lints {
@ -1217,7 +1217,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
}
for note in &xs {
handler.note_without_error(&note);
handler.note_without_error(note);
}
// If backtraces are enabled, also print the query stack
@ -1326,7 +1326,7 @@ mod signal_handler {
std::alloc::alloc(std::alloc::Layout::from_size_align(ALT_STACK_SIZE, 1).unwrap())
as *mut libc::c_void;
alt_stack.ss_size = ALT_STACK_SIZE;
libc::sigaltstack(&mut alt_stack, std::ptr::null_mut());
libc::sigaltstack(&alt_stack, std::ptr::null_mut());
let mut sa: libc::sigaction = std::mem::zeroed();
sa.sa_sigaction = print_stack_trace as libc::sighandler_t;

View file

@ -296,7 +296,7 @@ struct TypedAnnotation<'tcx> {
impl<'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'tcx> {
fn sess(&self) -> &Session {
&self.tcx.sess
self.tcx.sess
}
fn hir_map(&self) -> Option<hir_map::Map<'tcx>> {
@ -347,8 +347,7 @@ impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> {
fn get_source(input: &Input, sess: &Session) -> (String, FileName) {
let src_name = input.source_name();
let src = String::clone(
&sess
.source_map()
sess.source_map()
.get_source_file(&src_name)
.expect("get_source_file")
.src