We can define const values with Cell types now.
#![feature(const_fn)]
use std::cell::Cell;
const G: Cell<i32> = Cell::new(1);
fn main() {
G.set(2);
drop(G);
println!("{}", G.get());
}
But compiler still allows to call methods which can modify its internal value. Of course these methods take no effect. I think this behavior is counter-intuitive in my mental model. Why not trigger a compile error to forbid these methods?
Some may argue that this rule could be added in clippy, but I think it’s better to do it in compiler itself.