1
Fork 0

Warn on method call mutating const, even if it has destructor

This commit is contained in:
David Tolnay 2020-09-30 22:16:32 -07:00
parent eef5104c53
commit 75c2fdf34a
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 28 additions and 3 deletions

View file

@ -111,7 +111,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ConstMutationChecker<'a, 'tcx> {
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, loc: Location) {
if let Rvalue::Ref(_, BorrowKind::Mut { .. }, place) = rvalue {
let local = place.local;
if let Some(def_id) = self.is_const_item_without_destructor(local) {
if let Some(def_id) = self.is_const_item(local) {
// If this Rvalue is being used as the right-hand side of a
// `StatementKind::Assign`, see if it ends up getting used as
// the `self` parameter of a method call (as the terminator of our current