Skip to content

Commit 7e0a42b

Browse files
authored
Merge pull request rust-lang#165 from yvt/fix-const-memattr
Define immutable statics with const qualified types
2 parents e6dbecd + 10a9c0e commit 7e0a42b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/consts.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
4747
}
4848
}
4949
let global_value = self.static_addr_of_mut(cv, align, kind);
50-
// TODO(antoyo): set global constant.
50+
#[cfg(feature = "master")]
51+
self.global_lvalues.borrow().get(&global_value)
52+
.expect("`static_addr_of_mut` did not add the global to `self.global_lvalues`")
53+
.global_set_readonly();
5154
self.const_globals.borrow_mut().insert(cv, global_value);
5255
global_value
5356
}
@@ -88,7 +91,8 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
8891
// mutability are placed into read-only memory.
8992
if !is_mutable {
9093
if self.type_is_freeze(ty) {
91-
// TODO(antoyo): set global constant.
94+
#[cfg(feature = "master")]
95+
global.global_set_readonly();
9296
}
9397
}
9498

0 commit comments

Comments
 (0)