Skip to content

Commit ba23886

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

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+12-23
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ fn exported_symbols_provider_local(
331331
rustc_middle::ty::Coroutine(def_id, _) => *def_id,
332332
rustc_middle::ty::CoroutineClosure(def_id, _) => *def_id,
333333
rustc_middle::ty::CoroutineWitness(def_id, _) => *def_id,
334-
rustc_middle::ty::Foreign(def_id) => *def_id,
335-
_ => {
336-
return false;
337-
}
334+
_ => return false,
338335
};
339336
let Some(root_def_id) = root_def_id.as_local() else {
340337
return false;
@@ -346,12 +343,7 @@ fn exported_symbols_provider_local(
346343

347344
let is_instantiable_downstream = |did, type_args| {
348345
std::iter::once(tcx.type_of(did).skip_binder()).chain(type_args).all(|arg| {
349-
arg.walk().all(|ty| {
350-
let Some(ty) = ty.as_type() else {
351-
return true;
352-
};
353-
!is_local_to_current_crate(ty)
354-
})
346+
arg.walk().all(|ty| ty.as_type().map_or(true, |ty| !is_local_to_current_crate(ty)))
355347
})
356348
};
357349
// The symbols created in this loop are sorted below it
@@ -400,20 +392,17 @@ fn exported_symbols_provider_local(
400392
}
401393
}
402394
MonoItem::Fn(Instance { def: InstanceKind::DropGlue(_, Some(ty)), args }) => {
403-
let Some(GenericArgKind::Type(typ)) = args.non_erasable_generics().next()
404-
else {
405-
bug!("Expected a type argument for drop glue");
406-
};
407-
let should_export = {
408-
let root_identifier = match typ.kind() {
409-
rustc_middle::ty::Adt(def, args) => Some((def.did(), args)),
410-
rustc_middle::ty::Closure(id, args) => Some((*id, args)),
411-
_ => None,
412-
};
413-
root_identifier.map_or(true, |(did, args)| {
414-
is_instantiable_downstream(did, args.types())
415-
})
395+
// A little sanity-check
396+
assert_eq!(args.non_erasable_generics().next(), Some(GenericArgKind::Type(ty)));
397+
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,
416402
};
403+
let should_export = root_identifier
404+
.map_or(true, |(did, args)| is_instantiable_downstream(did, args.types()));
405+
417406
if should_export {
418407
symbols.push((
419408
ExportedSymbol::DropGlue(ty),

0 commit comments

Comments
 (0)