Skip to content

Commit 07ffa36

Browse files
Make sure to enforce ~const DerefMut on mutability
1 parent 85f33dc commit 07ffa36

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

compiler/rustc_hir_typeck/src/place_op.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
289289
)
290290
{
291291
let method = self.register_infer_ok_obligations(ok);
292-
let ty::Ref(_, _, mutbl) = *method.sig.output().kind() else {
293-
span_bug!(
294-
self.tcx.def_span(method.def_id),
295-
"expected DerefMut to return a &mut"
296-
);
297-
};
298-
*deref = OverloadedDeref { mutbl, span: deref.span };
292+
if let ty::Ref(_, _, mutbl) = *method.sig.output().kind() {
293+
*deref = OverloadedDeref { mutbl, span: deref.span };
294+
}
295+
self.enforce_context_effects(expr.span, method.def_id, method.args);
299296
// If this is a union field, also throw an error for `DerefMut` of `ManuallyDrop` (see RFC 2514).
300297
// This helps avoid accidental drops.
301298
if inside_union

0 commit comments

Comments
 (0)