Skip to content

Commit 7b86e2a

Browse files
committed
tidy
1 parent 0dc23dc commit 7b86e2a

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/librustc_middle/mir/mono.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
22
use crate::ich::{NodeIdHashingMode, StableHashingContext};
33
use crate::ty::print::obsolete::DefPathBasedNames;
4-
use crate::ty::{subst::InternalSubsts, subst::GenericArgKind, Instance, InstanceDef, SymbolName, TyCtxt};
4+
use crate::ty::{
5+
subst::GenericArgKind, subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt,
6+
};
57
use rustc_attr::InlineAttr;
68
use rustc_data_structures::base_n;
79
use rustc_data_structures::fingerprint::Fingerprint;
@@ -77,10 +79,12 @@ impl<'tcx> MonoItem<'tcx> {
7779

7880
pub fn has_closure_generic_argument(&self) -> bool {
7981
match *self {
80-
MonoItem::Fn(instance) => instance.substs.non_erasable_generics().any(|arg| match arg {
81-
GenericArgKind::Type(ty) => ty.is_closure(),
82-
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
83-
}),
82+
MonoItem::Fn(instance) => {
83+
instance.substs.non_erasable_generics().any(|arg| match arg {
84+
GenericArgKind::Type(ty) => ty.is_closure(),
85+
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
86+
})
87+
}
8488
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => false,
8589
}
8690
}
@@ -229,7 +233,7 @@ impl<'tcx> MonoItem<'tcx> {
229233
match *self {
230234
MonoItem::Fn(Instance { def, .. }) => def.def_id().is_local(),
231235
MonoItem::Static(def_id) => def_id.is_local(),
232-
MonoItem::GlobalAsm(..) => true
236+
MonoItem::GlobalAsm(..) => true,
233237
}
234238
}
235239
}

src/librustc_mir/monomorphize/partitioning.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ where
155155
// local functions the definition of which is marked with `#[inline]`.
156156
let mut post_inlining = {
157157
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_inline_items");
158-
let is_debug_incremental = tcx.sess.opts.optimize == OptLevel::No && tcx.sess.opts.incremental.is_some();
158+
let is_debug_incremental =
159+
tcx.sess.opts.optimize == OptLevel::No && tcx.sess.opts.incremental.is_some();
159160
place_inlined_mono_items(initial_partitioning, inlining_map, is_debug_incremental)
160161
};
161162

@@ -228,14 +229,22 @@ where
228229
InstantiationMode::LocalCopy => continue,
229230
}
230231

231-
let characteristic_def_id = characteristic_def_id_of_mono_item(tcx, mono_item, is_debug_incremental);
232+
let characteristic_def_id =
233+
characteristic_def_id_of_mono_item(tcx, mono_item, is_debug_incremental);
232234
let is_volatile = is_incremental_build && mono_item.is_generic_fn();
233235

234236
let codegen_unit_name = match (characteristic_def_id, mono_item.is_local()) {
235237
(Some(def_id), false) if is_debug_incremental => {
236238
let crate_name = tcx.crate_name(def_id.krate);
237-
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &[&*crate_name.as_str(), if mono_item.has_closure_generic_argument() { "has_closure" } else { "" }], Some("cgu"))
238-
},
239+
cgu_name_builder.build_cgu_name(
240+
LOCAL_CRATE,
241+
&[
242+
&*crate_name.as_str(),
243+
if mono_item.has_closure_generic_argument() { "has_closure" } else { "" },
244+
],
245+
Some("cgu"),
246+
)
247+
}
239248
(Some(def_id), _) => compute_codegen_unit_name(
240249
tcx,
241250
cgu_name_builder,
@@ -468,7 +477,9 @@ fn merge_codegen_units<'tcx>(
468477
assert!(target_cgu_count >= 1);
469478
let codegen_units = &mut initial_partitioning.codegen_units;
470479

471-
if tcx.is_compiler_builtins(LOCAL_CRATE) || (tcx.dep_graph.is_fully_enabled() && tcx.sess.opts.optimize == OptLevel::No) {
480+
if tcx.is_compiler_builtins(LOCAL_CRATE)
481+
|| (tcx.dep_graph.is_fully_enabled() && tcx.sess.opts.optimize == OptLevel::No)
482+
{
472483
// Compiler builtins require some degree of control over how mono items
473484
// are partitioned into compilation units. Provide it by keeping the
474485
// original partitioning when compiling the compiler builtins crate.

0 commit comments

Comments
 (0)