Fix mut self not emitting mutable binding on self use

This commit is contained in:
Lukas Wirth 2020-10-11 18:27:38 +02:00
parent cde189c5d5
commit 9909ccb4f4
2 changed files with 5 additions and 2 deletions

View File

@ -107,7 +107,10 @@ impl ExprCollector<'_> {
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),

View File

@ -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">-&gt;</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>