Skip to content

Commit 804d159

Browse files
committed
Fixme with link for re-enabling const mutation lint for Drop consts
1 parent 75c2fdf commit 804d159

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/rustc_mir/src/transform/check_const_item_mutation.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,21 @@ impl<'a, 'tcx> ConstMutationChecker<'a, 'tcx> {
3939
// We avoid linting mutation of a const item if the const's type has a
4040
// Drop impl. The Drop logic observes the mutation which was performed.
4141
//
42-
// struct Log { msg: &'static str }
43-
// const LOG: Log = Log { msg: "" };
42+
// pub struct Log { msg: &'static str }
43+
// pub const LOG: Log = Log { msg: "" };
4444
// impl Drop for Log {
4545
// fn drop(&mut self) { println!("{}", self.msg); }
4646
// }
4747
//
4848
// LOG.msg = "wow"; // prints "wow"
4949
//
50+
// FIXME(https://github.com/rust-lang/rust/issues/77425):
51+
// Drop this exception once there is a stable attribute to suppress the
52+
// const item mutation lint for a single specific const only. Something
53+
// equivalent to:
54+
//
55+
// #[const_mutation_allowed]
56+
// pub const LOG: Log = Log { msg: "" };
5057
match self.tcx.calculate_dtor(def_id, &mut any_dtor) {
5158
Some(_) => None,
5259
None => Some(def_id),

0 commit comments

Comments
 (0)