Merge #6199
6199: Fix `mut self` not emitting mutable binding on `self` use r=matklad a=Veykril Prior to this, when `self` in a function is taken by value and bound mutably, its use inside of the method body won't be marked `mutably`. Fixes #5461 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
93de4918ea
@ -107,7 +107,10 @@ fn collect(
|
||||
let param_pat = self.alloc_pat(
|
||||
Pat::Bind {
|
||||
name: name![self],
|
||||
mode: BindingAnnotation::Unannotated,
|
||||
mode: BindingAnnotation::new(
|
||||
self_param.mut_token().is_some() && self_param.amp_token().is_none(),
|
||||
false,
|
||||
),
|
||||
subpat: None,
|
||||
},
|
||||
Either::Right(ptr),
|
||||
|
@ -62,7 +62,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
|
||||
<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="punctuation">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="punctuation">(</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">,</span> <span class="value_param declaration">f</span><span class="punctuation">:</span> <span class="struct">Foo</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span>
|
||||
<span class="value_param">f</span><span class="punctuation">.</span><span class="function consuming">baz</span><span class="punctuation">(</span><span class="self_keyword consuming">self</span><span class="punctuation">)</span>
|
||||
<span class="value_param">f</span><span class="punctuation">.</span><span class="function consuming">baz</span><span class="punctuation">(</span><span class="self_keyword mutable consuming">self</span><span class="punctuation">)</span>
|
||||
<span class="punctuation">}</span>
|
||||
|
||||
<span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span>
|
||||
|
Loading…
Reference in New Issue
Block a user