Some comment nits

This commit is contained in:
Oli Scherer 2024-03-11 18:39:23 +00:00
parent bbedde835e
commit e2773733f3
4 changed files with 5 additions and 6 deletions

View file

@ -26,7 +26,7 @@ fn predefine_static(
let attrs = self.tcx.codegen_fn_attrs(def_id);
let instance = Instance::mono(self.tcx, def_id);
let DefKind::Static { nested, .. } = self.tcx.def_kind(def_id) else { bug!() };
// Nested statics do not have a type, so pick a random type and let `define_static` figure out
// Nested statics do not have a type, so pick a dummy type and let `codegen_static` figure out
// the gcc type from the actual evaluated initializer.
let ty = if nested {
self.tcx.types.unit

View file

@ -232,7 +232,7 @@ pub(crate) fn get_static(&self, def_id: DefId) -> &'ll Value {
trace!(?instance);
let DefKind::Static { nested, .. } = self.tcx.def_kind(def_id) else { bug!() };
// Nested statics do not have a type, so pick a random type and let `define_static` figure out
// Nested statics do not have a type, so pick a dummy type and let `codegen_static` figure out
// the llvm type from the actual evaluated initializer.
let llty = if nested {
self.type_i8()
@ -415,8 +415,7 @@ fn codegen_static_item(&self, def_id: DefId) {
llvm::LLVMRustSetDSOLocal(g, true);
}
// As an optimization, all shared statics which do not have interior
// mutability are placed into read-only memory.
// Forward the allocation's mutability (picked by the const interner) to LLVM.
if alloc.mutability.is_not() {
llvm::LLVMSetGlobalConstant(g, llvm::True);
}

View file

@ -24,7 +24,7 @@ fn predefine_static(
) {
let instance = Instance::mono(self.tcx, def_id);
let DefKind::Static { nested, .. } = self.tcx.def_kind(def_id) else { bug!() };
// Nested statics do not have a type, so pick a random type and let `define_static` figure out
// Nested statics do not have a type, so pick a dummy type and let `codegen_static` figure out
// the llvm type from the actual evaluated initializer.
let ty = if nested {
self.tcx.types.unit

View file

@ -251,7 +251,7 @@ pub fn def_path_data(self, name: Symbol) -> DefPathData {
| DefKind::TyParam
| DefKind::ExternCrate => DefPathData::TypeNs(name),
// It's not exactly an anon const, but wrt DefPathData, there
// is not difference.
// is no difference.
DefKind::Static { nested: true, .. } => DefPathData::AnonConst,
DefKind::Fn
| DefKind::Const