Skip to content

Commit 57eaa9a

Browse files
osiewiczbjorn3
andcommitted
Apply suggestions from code review
Co-authored-by: bjorn3 <[email protected]>
1 parent ba23886 commit 57eaa9a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ fn exported_symbols_provider_local(
326326
let is_local_to_current_crate = |ty: Ty<'_>| {
327327
let no_refs = ty.peel_refs();
328328
let root_def_id = match no_refs.kind() {
329-
rustc_middle::ty::Closure(closure, _) => *closure,
330-
rustc_middle::ty::FnDef(def_id, _) => *def_id,
331-
rustc_middle::ty::Coroutine(def_id, _) => *def_id,
332-
rustc_middle::ty::CoroutineClosure(def_id, _) => *def_id,
333-
rustc_middle::ty::CoroutineWitness(def_id, _) => *def_id,
329+
ty::Closure(closure, _) => *closure,
330+
ty::FnDef(def_id, _) => *def_id,
331+
ty::Coroutine(def_id, _) => *def_id,
332+
ty::CoroutineClosure(def_id, _) => *def_id,
333+
ty::CoroutineWitness(def_id, _) => *def_id,
334334
_ => return false,
335335
};
336336
let Some(root_def_id) = root_def_id.as_local() else {
@@ -346,6 +346,7 @@ fn exported_symbols_provider_local(
346346
arg.walk().all(|ty| ty.as_type().map_or(true, |ty| !is_local_to_current_crate(ty)))
347347
})
348348
};
349+
349350
// The symbols created in this loop are sorted below it
350351
#[allow(rustc::potential_query_instability)]
351352
for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
@@ -395,13 +396,11 @@ fn exported_symbols_provider_local(
395396
// A little sanity-check
396397
assert_eq!(args.non_erasable_generics().next(), Some(GenericArgKind::Type(ty)));
397398

398-
let root_identifier = match ty.kind() {
399-
rustc_middle::ty::Adt(def, args) => Some((def.did(), args)),
400-
rustc_middle::ty::Closure(id, args) => Some((*id, args)),
401-
_ => None,
399+
let should_export = match ty.kind() {
400+
ty::Adt(def, args) => is_instantiable_downstream(def.did(), args.types()),
401+
ty::Closure(id, args) => is_instantiable_downstream(*id, args.types()),
402+
_ => true,
402403
};
403-
let should_export = root_identifier
404-
.map_or(true, |(did, args)| is_instantiable_downstream(did, args.types()));
405404

406405
if should_export {
407406
symbols.push((

0 commit comments

Comments
 (0)