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:
commit
b27661eb33
61 changed files with 458 additions and 506 deletions
|
@ -41,7 +41,7 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
|
|||
fn track_diagnostic(diagnostic: &Diagnostic) {
|
||||
tls::with_context_opt(|icx| {
|
||||
if let Some(icx) = icx {
|
||||
if let Some(ref diagnostics) = icx.diagnostics {
|
||||
if let Some(diagnostics) = icx.diagnostics {
|
||||
let mut diagnostics = diagnostics.lock();
|
||||
diagnostics.extend(Some(diagnostic.clone()));
|
||||
}
|
||||
|
|
|
@ -65,13 +65,7 @@ impl Compiler {
|
|||
sess: &Session,
|
||||
attrs: &[ast::Attribute],
|
||||
) -> OutputFilenames {
|
||||
util::build_output_filenames(
|
||||
&self.input,
|
||||
&self.output_dir,
|
||||
&self.output_file,
|
||||
&attrs,
|
||||
&sess,
|
||||
)
|
||||
util::build_output_filenames(&self.input, &self.output_dir, &self.output_file, attrs, sess)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ pub fn create_resolver(
|
|||
) -> BoxedResolver {
|
||||
tracing::trace!("create_resolver");
|
||||
BoxedResolver::new(sess, move |sess, resolver_arenas| {
|
||||
Resolver::new(sess, &krate, &crate_name, metadata_loader, &resolver_arenas)
|
||||
Resolver::new(sess, krate, crate_name, metadata_loader, resolver_arenas)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ pub fn register_plugins<'a>(
|
|||
sess.opts.cg.metadata.clone(),
|
||||
);
|
||||
sess.stable_crate_id.set(stable_crate_id).expect("not yet initialized");
|
||||
rustc_incremental::prepare_session_directory(sess, &crate_name, stable_crate_id)?;
|
||||
rustc_incremental::prepare_session_directory(sess, crate_name, stable_crate_id)?;
|
||||
|
||||
if sess.opts.incremental.is_some() {
|
||||
sess.time("incr_comp_garbage_collect_session_directories", || {
|
||||
|
@ -219,7 +219,7 @@ pub fn register_plugins<'a>(
|
|||
sess.opts.debugging_opts.no_interleave_lints,
|
||||
sess.unstable_options(),
|
||||
);
|
||||
register_lints(&sess, &mut lint_store);
|
||||
register_lints(sess, &mut lint_store);
|
||||
|
||||
let registrars =
|
||||
sess.time("plugin_loading", || plugin::load::load_plugins(sess, metadata_loader, &krate));
|
||||
|
@ -244,7 +244,7 @@ fn pre_expansion_lint(
|
|||
rustc_lint::check_ast_crate(
|
||||
sess,
|
||||
lint_store,
|
||||
&krate,
|
||||
krate,
|
||||
crate_attrs,
|
||||
true,
|
||||
None,
|
||||
|
@ -270,10 +270,10 @@ pub fn configure_and_expand(
|
|||
|
||||
krate = sess.time("crate_injection", || {
|
||||
let alt_std_name = sess.opts.alt_std_name.as_ref().map(|s| Symbol::intern(s));
|
||||
rustc_builtin_macros::standard_library_imports::inject(krate, resolver, &sess, alt_std_name)
|
||||
rustc_builtin_macros::standard_library_imports::inject(krate, resolver, sess, alt_std_name)
|
||||
});
|
||||
|
||||
util::check_attr_crate_type(&sess, &krate.attrs, &mut resolver.lint_buffer());
|
||||
util::check_attr_crate_type(sess, &krate.attrs, &mut resolver.lint_buffer());
|
||||
|
||||
// Expand all macros
|
||||
krate = sess.time("macro_expand_crate", || {
|
||||
|
@ -310,9 +310,9 @@ pub fn configure_and_expand(
|
|||
|
||||
// Create the config for macro expansion
|
||||
let features = sess.features_untracked();
|
||||
let recursion_limit = get_recursion_limit(&krate.attrs, &sess);
|
||||
let recursion_limit = get_recursion_limit(&krate.attrs, sess);
|
||||
let cfg = rustc_expand::expand::ExpansionConfig {
|
||||
features: Some(&features),
|
||||
features: Some(features),
|
||||
recursion_limit,
|
||||
trace_mac: sess.opts.debugging_opts.trace_macros,
|
||||
should_test: sess.opts.test,
|
||||
|
@ -327,7 +327,7 @@ pub fn configure_and_expand(
|
|||
pre_expansion_lint(sess, lint_store, &krate, &crate_attrs, &ident.name.as_str());
|
||||
(krate.attrs, krate.items)
|
||||
};
|
||||
let mut ecx = ExtCtxt::new(&sess, cfg, resolver, Some(&extern_mod_loaded));
|
||||
let mut ecx = ExtCtxt::new(sess, cfg, resolver, Some(&extern_mod_loaded));
|
||||
|
||||
// Expand macros now!
|
||||
let krate = sess.time("expand_crate", || ecx.monotonic_expander().expand_crate(krate));
|
||||
|
@ -369,7 +369,7 @@ pub fn configure_and_expand(
|
|||
})?;
|
||||
|
||||
sess.time("maybe_building_test_harness", || {
|
||||
rustc_builtin_macros::test_harness::inject(&sess, resolver, &mut krate)
|
||||
rustc_builtin_macros::test_harness::inject(sess, resolver, &mut krate)
|
||||
});
|
||||
|
||||
if let Some(PpMode::Source(PpSourceMode::EveryBodyLoops)) = sess.opts.pretty {
|
||||
|
@ -392,8 +392,8 @@ pub fn configure_and_expand(
|
|||
// start passing '--crate-type proc-macro'
|
||||
if has_proc_macro_decls && sess.opts.actually_rustdoc && !is_proc_macro_crate {
|
||||
let mut msg = sess.diagnostic().struct_warn(
|
||||
&"Trying to document proc macro crate \
|
||||
without passing '--crate-type proc-macro to rustdoc",
|
||||
"Trying to document proc macro crate \
|
||||
without passing '--crate-type proc-macro to rustdoc",
|
||||
);
|
||||
|
||||
msg.warn("The generated documentation may be incorrect");
|
||||
|
@ -403,7 +403,7 @@ pub fn configure_and_expand(
|
|||
let num_crate_types = crate_types.len();
|
||||
let is_test_crate = sess.opts.test;
|
||||
rustc_builtin_macros::proc_macro_harness::inject(
|
||||
&sess,
|
||||
sess,
|
||||
resolver,
|
||||
krate,
|
||||
is_proc_macro_crate,
|
||||
|
@ -691,7 +691,7 @@ pub fn prepare_outputs(
|
|||
);
|
||||
|
||||
let output_paths =
|
||||
generated_output_paths(sess, &outputs, compiler.output_file.is_some(), &crate_name);
|
||||
generated_output_paths(sess, &outputs, compiler.output_file.is_some(), crate_name);
|
||||
|
||||
// Ensure the source file isn't accidentally overwritten during compilation.
|
||||
if let Some(ref input_path) = compiler.input_path {
|
||||
|
@ -832,7 +832,7 @@ pub fn create_global_ctxt<'tcx>(
|
|||
dep_graph,
|
||||
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
|
||||
queries.as_dyn(),
|
||||
&crate_name,
|
||||
crate_name,
|
||||
outputs,
|
||||
)
|
||||
})
|
||||
|
|
|
@ -110,7 +110,7 @@ impl<'tcx> Queries<'tcx> {
|
|||
&self.compiler.sess
|
||||
}
|
||||
fn codegen_backend(&self) -> &Lrc<Box<dyn CodegenBackend>> {
|
||||
&self.compiler.codegen_backend()
|
||||
self.compiler.codegen_backend()
|
||||
}
|
||||
|
||||
fn dep_graph_future(&self) -> Result<&Query<Option<DepGraphFuture>>> {
|
||||
|
@ -181,7 +181,7 @@ impl<'tcx> Queries<'tcx> {
|
|||
&crate_name,
|
||||
);
|
||||
let krate = resolver.access(|resolver| {
|
||||
passes::configure_and_expand(&sess, &lint_store, krate, &crate_name, resolver)
|
||||
passes::configure_and_expand(sess, &lint_store, krate, &crate_name, resolver)
|
||||
})?;
|
||||
Ok((Rc::new(krate), Rc::new(RefCell::new(resolver)), lint_store))
|
||||
})
|
||||
|
@ -343,7 +343,7 @@ impl Linker {
|
|||
let sess = &self.sess;
|
||||
let dep_graph = self.dep_graph;
|
||||
sess.time("serialize_work_products", || {
|
||||
rustc_incremental::save_work_product_index(&sess, &dep_graph, work_products)
|
||||
rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)
|
||||
});
|
||||
|
||||
let prof = self.sess.prof.clone();
|
||||
|
@ -386,7 +386,7 @@ impl Compiler {
|
|||
F: for<'tcx> FnOnce(&'tcx Queries<'tcx>) -> T,
|
||||
{
|
||||
let mut _timer = None;
|
||||
let queries = Queries::new(&self);
|
||||
let queries = Queries::new(self);
|
||||
let ret = f(&queries);
|
||||
|
||||
// NOTE: intentionally does not compute the global context if it hasn't been built yet,
|
||||
|
|
|
@ -402,7 +402,7 @@ pub fn get_codegen_sysroot(
|
|||
.iter()
|
||||
.chain(sysroot_candidates.iter())
|
||||
.map(|sysroot| {
|
||||
filesearch::make_target_lib_path(&sysroot, &target).with_file_name("codegen-backends")
|
||||
filesearch::make_target_lib_path(sysroot, target).with_file_name("codegen-backends")
|
||||
})
|
||||
.find(|f| {
|
||||
info!("codegen backend candidate: {}", f.display());
|
||||
|
@ -619,7 +619,7 @@ pub fn build_output_filenames(
|
|||
.opts
|
||||
.crate_name
|
||||
.clone()
|
||||
.or_else(|| rustc_attr::find_crate_name(&sess, attrs).map(|n| n.to_string()))
|
||||
.or_else(|| rustc_attr::find_crate_name(sess, attrs).map(|n| n.to_string()))
|
||||
.unwrap_or_else(|| input.filestem().to_owned());
|
||||
|
||||
OutputFilenames::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue