Skip to content

Commit

Permalink
Merge #5823
Browse files Browse the repository at this point in the history
5823: Don't underline function definition if self is &mut r=Nashenas88 a=matklad

The self is right there, and is already underlined, so it makes little
sense to emit even more underlines.

before:
![before](https://user-images.githubusercontent.com/1711539/90672843-0d379500-e257-11ea-840f-b0caed4410f1.png)
after:
![after](https://user-images.githubusercontent.com/1711539/90672840-0c9efe80-e257-11ea-9739-23af433841c6.png)



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
  • Loading branch information
bors[bot] and matklad authored Aug 22, 2020
2 parents d7466c9 + 8000d1d commit e65d48d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 0 additions & 6 deletions crates/ide/src/syntax_highlighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,6 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight {
if func.is_unsafe(db) {
h |= HighlightModifier::Unsafe;
}
if let Some(self_param) = func.self_param(db) {
match self_param.access(db) {
hir::Access::Exclusive => h |= HighlightModifier::Mutable,
hir::Access::Shared | hir::Access::Owned => (),
}
}
return h;
}
hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct,
Expand Down
4 changes: 2 additions & 2 deletions crates/ide/test_data/highlighting.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span>
<span class="punctuation">}</span>

<span class="keyword">fn</span> <span class="function declaration mutable">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>
<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>
<span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span>
<span class="punctuation">}</span>

Expand All @@ -84,7 +84,7 @@
<span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span>
<span class="punctuation">}</span>

<span class="keyword">fn</span> <span class="function declaration mutable">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>
<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>
<span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span>
<span class="punctuation">}</span>

Expand Down

0 comments on commit e65d48d

Please sign in to comment.