Add justification of the destructor filter
This commit is contained in:
parent
17db1cb5d5
commit
0dfe7b6434
1 changed files with 12 additions and 0 deletions
|
@ -34,6 +34,18 @@ impl<'a, 'tcx> ConstMutationChecker<'a, 'tcx> {
|
||||||
|
|
||||||
fn is_const_item_without_destructor(&self, local: Local) -> Option<DefId> {
|
fn is_const_item_without_destructor(&self, local: Local) -> Option<DefId> {
|
||||||
let def_id = self.is_const_item(local)?;
|
let def_id = self.is_const_item(local)?;
|
||||||
|
|
||||||
|
// 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: "" };
|
||||||
|
// impl Drop for Log {
|
||||||
|
// fn drop(&mut self) { println!("{}", self.msg); }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// LOG.msg = "wow"; // prints "wow"
|
||||||
|
//
|
||||||
match self.tcx.adt_def(def_id).destructor(self.tcx) {
|
match self.tcx.adt_def(def_id).destructor(self.tcx) {
|
||||||
Some(_) => None,
|
Some(_) => None,
|
||||||
None => Some(def_id),
|
None => Some(def_id),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue