diff options
| author | David Tolnay <dtolnay@gmail.com> | 2020-10-01 13:41:29 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2020-10-01 13:41:43 -0700 |
| commit | 804d159c6276025e26ade90a6ef013bda33207c3 (patch) | |
| tree | 5714d22e365c0cd60efd8fc5d030994efad68edd | |
| parent | 75c2fdf34a5384627db9ba240c5dcc0723aea763 (diff) | |
| download | rust-804d159c6276025e26ade90a6ef013bda33207c3.tar.gz rust-804d159c6276025e26ade90a6ef013bda33207c3.zip | |
Fixme with link for re-enabling const mutation lint for Drop consts
| -rw-r--r-- | compiler/rustc_mir/src/transform/check_const_item_mutation.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_mir/src/transform/check_const_item_mutation.rs b/compiler/rustc_mir/src/transform/check_const_item_mutation.rs index a0edb377243..b6d57b899dd 100644 --- a/compiler/rustc_mir/src/transform/check_const_item_mutation.rs +++ b/compiler/rustc_mir/src/transform/check_const_item_mutation.rs @@ -39,14 +39,21 @@ impl<'a, 'tcx> ConstMutationChecker<'a, 'tcx> { // We avoid linting mutation of a const item if the const's type has a // Drop impl. The Drop logic observes the mutation which was performed. // - // struct Log { msg: &'static str } - // const LOG: Log = Log { msg: "" }; + // pub struct Log { msg: &'static str } + // pub const LOG: Log = Log { msg: "" }; // impl Drop for Log { // fn drop(&mut self) { println!("{}", self.msg); } // } // // LOG.msg = "wow"; // prints "wow" // + // FIXME(https://github.com/rust-lang/rust/issues/77425): + // Drop this exception once there is a stable attribute to suppress the + // const item mutation lint for a single specific const only. Something + // equivalent to: + // + // #[const_mutation_allowed] + // pub const LOG: Log = Log { msg: "" }; match self.tcx.calculate_dtor(def_id, &mut any_dtor) { Some(_) => None, None => Some(def_id), |
