From 269e67312d30e8e5a5c38cec3f12c52ba0d6d9b6 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 26 Oct 2020 22:27:28 +0100 Subject: Highlight never type as BuiltinType --- crates/ide/src/syntax_highlighting.rs | 3 +++ crates/ide/src/syntax_highlighting/test_data/highlighting.html | 6 ++++++ crates/ide/src/syntax_highlighting/tests.rs | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 9f864179e..624a63075 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -562,6 +562,9 @@ fn highlight_element( T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { HighlightTag::Macro.into() } + T![!] if element.parent().and_then(ast::NeverType::cast).is_some() => { + HighlightTag::BuiltinType.into() + } T![*] if element.parent().and_then(ast::PtrType::cast).is_some() => { HighlightTag::Keyword.into() } diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index c6b4f5a00..b0e547d57 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -110,6 +110,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd foo::<'a, i32>() } +fn never() -> ! { + loop {} +} + use ops::Fn; fn baz<F: Fn() -> ()>(f: F) { f() @@ -179,6 +183,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let baz = -42; let baz = -baz; + + let _ = !true; } enum Option<T> { diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index dd43f9dd9..f13cf3ef3 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -84,6 +84,10 @@ fn foo<'a, T>() -> T { foo::<'a, i32>() } +fn never() -> ! { + loop {} +} + use ops::Fn; fn baz ()>(f: F) { f() @@ -153,6 +157,8 @@ fn main() { let baz = -42; let baz = -baz; + + let _ = !true; } enum Option { -- cgit v1.2.3