From 73bab32aef073a101854099d6ef193737cf2a4fe Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 09:46:50 -0300 Subject: Highlight more cases of SyntaxKind when it is a punctuation --- crates/ra_ide/src/syntax_highlighting.rs | 46 ++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 6ac44c2c0..606637d11 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -539,21 +539,39 @@ fn highlight_element( _ => h, } } - T![*] => { - let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?; - - let expr = prefix_expr.expr()?; - let ty = sema.type_of_expr(&expr)?; - if !ty.is_raw_ptr() { - return None; - } else { - HighlightTag::Operator | HighlightModifier::Unsafe + p if p.is_punct() => match p { + T![::] | T![->] | T![=>] | T![&] => HighlightTag::Operator.into(), + T![@] => HighlightTag::Operator | HighlightModifier::ControlFlow, + T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { + Highlight::new(HighlightTag::Macro) } - } - T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { - Highlight::new(HighlightTag::Macro) - } - p if p.is_punct() => HighlightTag::Punctuation.into(), + T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { + let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?; + + let expr = prefix_expr.expr()?; + let ty = sema.type_of_expr(&expr)?; + if ty.is_raw_ptr() { + HighlightTag::Operator | HighlightModifier::Unsafe + } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() { + HighlightTag::Operator.into() + } else { + HighlightTag::Punctuation.into() + } + } + T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { + HighlightTag::NumericLiteral.into() + } + _ if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { + HighlightTag::Operator.into() + } + _ if element.parent().and_then(ast::BinExpr::cast).is_some() => { + HighlightTag::Operator.into() + } + _ if element.parent().and_then(ast::RangeExpr::cast).is_some() => { + HighlightTag::Operator.into() + } + _ => HighlightTag::Punctuation.into(), + }, k if k.is_keyword() => { let h = Highlight::new(HighlightTag::Keyword); -- cgit v1.2.3 From 54ebb2ce301813a9b5b48d5abe97ace370cfa617 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 11:21:40 -0300 Subject: Handle semantic highlight when STAR is part of the `*{const, mut}` --- crates/ra_ide/src/syntax_highlighting.rs | 5 +++- crates/ra_ide/test_data/highlight_doctest.html | 14 +++++----- crates/ra_ide/test_data/highlight_injection.html | 2 +- crates/ra_ide/test_data/highlight_strings.html | 6 ++--- crates/ra_ide/test_data/highlight_unsafe.html | 6 ++--- crates/ra_ide/test_data/highlighting.html | 34 ++++++++++++------------ 6 files changed, 35 insertions(+), 32 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 606637d11..2b1b6a4fd 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -543,7 +543,10 @@ fn highlight_element( T![::] | T![->] | T![=>] | T![&] => HighlightTag::Operator.into(), T![@] => HighlightTag::Operator | HighlightModifier::ControlFlow, T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { - Highlight::new(HighlightTag::Macro) + HighlightTag::Macro.into() + } + T![*] if element.parent().and_then(ast::PointerType::cast).is_some() => { + HighlightTag::Keyword.into() } T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?; diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index 1cc17d6d0..e79e89807 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -51,9 +51,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// /// ``` /// # #![allow(unused_mut)] - /// let mut foo: Foo = Foo::new(); + /// let mut foo: Foo = Foo::new(); /// ``` - pub const fn new() -> Foo { + pub const fn new() -> Foo { Foo { bar: true } } @@ -62,14 +62,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// # Examples /// /// ``` - /// use x::y; + /// use x::y; /// - /// let foo = Foo::new(); + /// let foo = Foo::new(); /// /// // calls bar on foo /// assert!(foo.bar()); /// - /// let bar = foo.bar || Foo::bar; + /// let bar = foo.bar || Foo::bar; /// /// /* multi-line /// comment */ @@ -81,13 +81,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// ``` /// /// ```rust,no_run - /// let foobar = Foo::new().bar(); + /// let foobar = Foo::new().bar(); /// ``` /// /// ```sh /// echo 1 /// ``` - pub fn foo(&self) -> bool { + pub fn foo(&self) -> bool { true } } diff --git a/crates/ra_ide/test_data/highlight_injection.html b/crates/ra_ide/test_data/highlight_injection.html index 461cfc437..18addd00d 100644 --- a/crates/ra_ide/test_data/highlight_injection.html +++ b/crates/ra_ide/test_data/highlight_injection.html @@ -35,7 +35,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
fn fixture(ra_fixture: &str) {}
+
fn fixture(ra_fixture: &str) {}
 
 fn main() {
     fixture(r#"
diff --git a/crates/ra_ide/test_data/highlight_strings.html b/crates/ra_ide/test_data/highlight_strings.html
index 9f98e73e7..258bd404b 100644
--- a/crates/ra_ide/test_data/highlight_strings.html
+++ b/crates/ra_ide/test_data/highlight_strings.html
@@ -36,14 +36,14 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
 
 
macro_rules! println {
-    ($($arg:tt)*) => ({
-        $crate::io::_print($crate::format_args_nl!($($arg)*));
+    ($($arg:tt)*) => ({
+        $crate::io::_print($crate::format_args_nl!($($arg)*));
     })
 }
 #[rustc_builtin_macro]
 macro_rules! format_args_nl {
     ($fmt:expr) => {{ /* compiler built-in */ }};
-    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
 }
 
 fn main() {
diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index 88ac91f9a..6c210bfa8 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -40,15 +40,15 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 struct HasUnsafeFn;
 
 impl HasUnsafeFn {
-    unsafe fn unsafe_method(&self) {}
+    unsafe fn unsafe_method(&self) {}
 }
 
 fn main() {
-    let x = &5 as *const usize;
+    let x = &5 as *const usize;
     unsafe {
         unsafe_fn();
         HasUnsafeFn.unsafe_method();
         let y = *(x);
-        let z = -x;
+        let z = -x;
     }
 }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html index 767e82f9d..c49645b0d 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -42,37 +42,37 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } trait Bar { - fn bar(&self) -> i32; + fn bar(&self) -> i32; } impl Bar for Foo { - fn bar(&self) -> i32 { + fn bar(&self) -> i32 { self.x } } impl Foo { - fn baz(mut self) -> i32 { + fn baz(mut self) -> i32 { self.x } - fn qux(&mut self) { - self.x = 0; + fn qux(&mut self) { + self.x = 0; } } static mut STATIC_MUT: i32 = 0; -fn foo<'a, T>() -> T { - foo::<'a, i32>() +fn foo<'a, T>() -> T { + foo::<'a, i32>() } macro_rules! def_fn { - ($($tt:tt)*) => {$($tt)*} + ($($tt:tt)*) => {$($tt)*} } def_fn! { - fn bar() -> u32 { + fn bar() -> u32 { 100 } } @@ -87,14 +87,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fn main() { println!("Hello, {}!", 92); - let mut vec = Vec::new(); + let mut vec = Vec::new(); if true { let x = 92; vec.push(Foo { x, y: 1 }); } unsafe { vec.set_len(0); - STATIC_MUT = 1; + STATIC_MUT = 1; } for e in vec { @@ -104,8 +104,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd noop!(noop!(1)); let mut x = 42; - let y = &mut x; - let z = &y; + let y = &mut x; + let z = &y; let Foo { x: z, y } = Foo { x: z, y }; @@ -116,13 +116,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd Some(T), None, } -use Option::*; +use Option::*; impl<T> Option<T> { - fn and<U>(self, other: Option<U>) -> Option<(T, U)> { + fn and<U>(self, other: Option<U>) -> Option<(T, U)> { match other { - None => unimplemented!(), - Nope => Nope, + None => unimplemented!(), + Nope => Nope, } } }
\ No newline at end of file -- cgit v1.2.3 From a662228de41a8b35d61b2bd312d30d34623e2232 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 12:36:23 -0300 Subject: Assingment semantic highlight --- crates/ra_ide/src/syntax_highlighting.rs | 8 ++++++- crates/ra_ide/test_data/highlight_doctest.html | 16 ++++++------- crates/ra_ide/test_data/highlight_strings.html | 28 +++++++++++------------ crates/ra_ide/test_data/highlight_unsafe.html | 6 ++--- crates/ra_ide/test_data/highlighting.html | 18 +++++++-------- crates/ra_ide/test_data/rainbow_highlighting.html | 12 +++++----- 6 files changed, 47 insertions(+), 41 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 2b1b6a4fd..f088487fa 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -540,7 +540,7 @@ fn highlight_element( } } p if p.is_punct() => match p { - T![::] | T![->] | T![=>] | T![&] => HighlightTag::Operator.into(), + T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] => HighlightTag::Operator.into(), T![@] => HighlightTag::Operator | HighlightModifier::ControlFlow, T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { HighlightTag::Macro.into() @@ -573,6 +573,12 @@ fn highlight_element( _ if element.parent().and_then(ast::RangeExpr::cast).is_some() => { HighlightTag::Operator.into() } + _ if element.parent().and_then(ast::RangePat::cast).is_some() => { + HighlightTag::Operator.into() + } + _ if element.parent().and_then(ast::DotDotPat::cast).is_some() => { + HighlightTag::Operator.into() + } _ => HighlightTag::Punctuation.into(), }, diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index e79e89807..10cb9b20b 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
/// ```
-/// let _ = "early doctests should not go boom";
+/// let _ = "early doctests should not go boom";
 /// ```
 struct Foo {
     bar: bool,
 }
 
 impl Foo {
-    pub const bar: bool = true;
+    pub const bar: bool = true;
 
     /// Constructs a new `Foo`.
     ///
@@ -51,7 +51,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     ///
     /// ```
     /// # #![allow(unused_mut)]
-    /// let mut foo: Foo = Foo::new();
+    /// let mut foo: Foo = Foo::new();
     /// ```
     pub const fn new() -> Foo {
         Foo { bar: true }
@@ -64,24 +64,24 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     /// ```
     /// use x::y;
     ///
-    /// let foo = Foo::new();
+    /// let foo = Foo::new();
     ///
     /// // calls bar on foo
     /// assert!(foo.bar());
     ///
-    /// let bar = foo.bar || Foo::bar;
+    /// let bar = foo.bar || Foo::bar;
     ///
     /// /* multi-line
     ///        comment */
     ///
-    /// let multi_line_string = "Foo
+    /// let multi_line_string = "Foo
     ///   bar
     ///          ";
     ///
     /// ```
     ///
     /// ```rust,no_run
-    /// let foobar = Foo::new().bar();
+    /// let foobar = Foo::new().bar();
     /// ```
     ///
     /// ```sh
@@ -96,7 +96,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 /// noop!(1);
 /// ```
 macro_rules! noop {
-    ($expr:expr) => {
+    ($expr:expr) => {
         $expr
     }
 }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlight_strings.html b/crates/ra_ide/test_data/highlight_strings.html index 258bd404b..1b681b2c6 100644 --- a/crates/ra_ide/test_data/highlight_strings.html +++ b/crates/ra_ide/test_data/highlight_strings.html @@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
macro_rules! println {
-    ($($arg:tt)*) => ({
+    ($($arg:tt)*) => ({
         $crate::io::_print($crate::format_args_nl!($($arg)*));
     })
 }
 #[rustc_builtin_macro]
 macro_rules! format_args_nl {
-    ($fmt:expr) => {{ /* compiler built-in */ }};
-    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+    ($fmt:expr) => {{ /* compiler built-in */ }};
+    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
 }
 
 fn main() {
@@ -52,18 +52,18 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     println!("Hello, {}!", "world");   // => "Hello, world!"
     println!("The number is {}", 1);   // => "The number is 1"
     println!("{:?}", (3, 4));          // => "(3, 4)"
-    println!("{value}", value=4);      // => "4"
+    println!("{value}", value=4);      // => "4"
     println!("{} {}", 1, 2);           // => "1 2"
     println!("{:04}", 42);             // => "0042" with leading zerosV
     println!("{1} {} {0} {}", 1, 2);   // => "2 1 1 2"
-    println!("{argument}", argument = "test");   // => "test"
-    println!("{name} {}", 1, name = 2);          // => "2 1"
-    println!("{a} {c} {b}", a="a", b='b', c=3);  // => "a 3 b"
+    println!("{argument}", argument = "test");   // => "test"
+    println!("{name} {}", 1, name = 2);          // => "2 1"
+    println!("{a} {c} {b}", a="a", b='b', c=3);  // => "a 3 b"
     println!("{{{}}}", 2);                       // => "{2}"
     println!("Hello {:5}!", "x");
     println!("Hello {:1$}!", "x", 5);
     println!("Hello {1:0$}!", 5, "x");
-    println!("Hello {:width$}!", "x", width = 5);
+    println!("Hello {:width$}!", "x", width = 5);
     println!("Hello {:<5}!", "x");
     println!("Hello {:-<5}!", "x");
     println!("Hello {:^5}!", "x");
@@ -78,10 +78,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
     println!("Hello {} is {:.*}",    "x", 5, 0.01);
     println!("Hello {} is {2:.*}",   "x", 5, 0.01);
-    println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
-    println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
-    println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
-    println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
+    println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
+    println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
+    println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
+    println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
     println!("Hello {{}}");
     println!("{{ Hello");
 
@@ -91,6 +91,6 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     println!("Hello\nWorld");
     println!("\u{48}\x65\x6C\x6C\x6F World");
 
-    println!("{\x41}", A = 92);
-    println!("{ничоси}", ничоси = 92);
+    println!("{\x41}", A = 92);
+    println!("{ничоси}", ничоси = 92);
 }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html index 6c210bfa8..b81b6f1c3 100644 --- a/crates/ra_ide/test_data/highlight_unsafe.html +++ b/crates/ra_ide/test_data/highlight_unsafe.html @@ -44,11 +44,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } fn main() { - let x = &5 as *const usize; + let x = &5 as *const usize; unsafe { unsafe_fn(); HasUnsafeFn.unsafe_method(); - let y = *(x); - let z = -x; + let y = *(x); + let z = -x; } }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html index c49645b0d..d72efa04a 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -61,14 +61,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } } -static mut STATIC_MUT: i32 = 0; +static mut STATIC_MUT: i32 = 0; fn foo<'a, T>() -> T { foo::<'a, i32>() } macro_rules! def_fn { - ($($tt:tt)*) => {$($tt)*} + ($($tt:tt)*) => {$($tt)*} } def_fn! { @@ -78,7 +78,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } macro_rules! noop { - ($expr:expr) => { + ($expr:expr) => { $expr } } @@ -87,9 +87,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fn main() { println!("Hello, {}!", 92); - let mut vec = Vec::new(); + let mut vec = Vec::new(); if true { - let x = 92; + let x = 92; vec.push(Foo { x, y: 1 }); } unsafe { @@ -103,11 +103,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd noop!(noop!(1)); - let mut x = 42; - let y = &mut x; - let z = &y; + let mut x = 42; + let y = &mut x; + let z = &y; - let Foo { x: z, y } = Foo { x: z, y }; + let Foo { x: z, y } = Foo { x: z, y }; y; } diff --git a/crates/ra_ide/test_data/rainbow_highlighting.html b/crates/ra_ide/test_data/rainbow_highlighting.html index 2fed04a44..08d83302c 100644 --- a/crates/ra_ide/test_data/rainbow_highlighting.html +++ b/crates/ra_ide/test_data/rainbow_highlighting.html @@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
fn main() {
-    let hello = "hello";
-    let x = hello.to_string();
-    let y = hello.to_string();
+    let hello = "hello";
+    let x = hello.to_string();
+    let y = hello.to_string();
 
-    let x = "other color please!";
-    let y = x.to_string();
+    let x = "other color please!";
+    let y = x.to_string();
 }
 
 fn bar() {
-    let mut hello = "hello";
+    let mut hello = "hello";
 }
\ No newline at end of file -- cgit v1.2.3 From d8eec71dc921a5a20ce9b3abe5251781709fb0db Mon Sep 17 00:00:00 2001 From: kjeremy Date: Mon, 20 Jul 2020 15:37:50 -0400 Subject: Bump lexer --- crates/ra_syntax/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 57cc09854..670f04578 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] itertools = "0.9.0" rowan = "0.10.0" -rustc_lexer = { version = "666.0.0", package = "rustc-ap-rustc_lexer" } +rustc_lexer = { version = "669.0.0", package = "rustc-ap-rustc_lexer" } rustc-hash = "1.1.0" arrayvec = "0.5.1" once_cell = "1.3.1" -- cgit v1.2.3 From 9cfb373665e25fac5412ac40a97664b82c9176a6 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Mon, 20 Jul 2020 15:50:35 -0400 Subject: Bump chalk --- crates/ra_hir_ty/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 78f5e55bb..548a3fc1f 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -28,9 +28,9 @@ test_utils = { path = "../test_utils" } scoped-tls = "1" -chalk-solve = { version = "0.17.0" } -chalk-ir = { version = "0.17.0" } -chalk-recursive = { version = "0.17.0" } +chalk-solve = { version = "0.18.0" } +chalk-ir = { version = "0.18.0" } +chalk-recursive = { version = "0.18.0" } [dev-dependencies] insta = "0.16.0" -- cgit v1.2.3 From 54cc3fee4550ec7e2e8b6f118de4b7ced546bc97 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 20 Jul 2020 23:50:41 +0300 Subject: Do not show default types in closures --- crates/ra_hir_ty/src/display.rs | 22 +++++++++++++++++++--- crates/ra_ide/src/inlay_hints.rs | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 758d5f5ac..19770e609 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs @@ -257,7 +257,12 @@ impl HirDisplay for ApplicationTy { write!(f, ")")?; let ret = sig.ret(); if *ret != Ty::unit() { - write!(f, " -> {}", ret.display(f.db))?; + let ret_display = if f.omit_verbose_types() { + ret.display_truncated(f.db, f.max_size) + } else { + ret.display(f.db) + }; + write!(f, " -> {}", ret_display)?; } } TypeCtor::FnDef(def) => { @@ -288,7 +293,12 @@ impl HirDisplay for ApplicationTy { write!(f, ")")?; let ret = sig.ret(); if *ret != Ty::unit() { - write!(f, " -> {}", ret.display(f.db))?; + let ret_display = if f.omit_verbose_types() { + ret.display_truncated(f.db, f.max_size) + } else { + ret.display(f.db) + }; + write!(f, " -> {}", ret_display)?; } } TypeCtor::Adt(def_id) => { @@ -397,7 +407,13 @@ impl HirDisplay for ApplicationTy { f.write_joined(sig.params(), ", ")?; write!(f, "|")?; }; - write!(f, " -> {}", sig.ret().display(f.db))?; + + let ret_display = if f.omit_verbose_types() { + sig.ret().display_truncated(f.db, f.max_size) + } else { + sig.ret().display(f.db) + }; + write!(f, " -> {}", ret_display)?; } else { write!(f, "{{closure}}")?; } diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 09883ab4d..f2e4f7ee5 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -425,6 +425,8 @@ fn main() { //^^ Test let zz_ref = &zz; //^^^^^^ &Test + let test = || zz; + //^^^^ || -> Test }"#, ); } -- cgit v1.2.3 From 462e0158dae29cc0c55e699dd0e83c36a60ef5b9 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 23:00:13 -0300 Subject: @ as operator --- crates/ra_ide/src/syntax_highlighting.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index f088487fa..0088077cc 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -540,8 +540,9 @@ fn highlight_element( } } p if p.is_punct() => match p { - T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] => HighlightTag::Operator.into(), - T![@] => HighlightTag::Operator | HighlightModifier::ControlFlow, + T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => { + HighlightTag::Operator.into() + } T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { HighlightTag::Macro.into() } -- cgit v1.2.3 From 04d8dc4a10be5e0c6a852011c98284f0121f3293 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 23:19:29 -0300 Subject: `#` as Attribute - Issue #5453 --- crates/ra_ide/src/syntax_highlighting.rs | 1 + crates/ra_ide/test_data/highlight_doctest.html | 2 +- crates/ra_ide/test_data/highlighting.html | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 0088077cc..036180c60 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -540,6 +540,7 @@ fn highlight_element( } } p if p.is_punct() => match p { + T![#] => HighlightTag::Attribute.into(), T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => { HighlightTag::Operator.into() } diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index 10cb9b20b..78c2a30c3 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -50,7 +50,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// # Examples /// /// ``` - /// # #![allow(unused_mut)] + /// # #![allow(unused_mut)] /// let mut foo: Foo = Foo::new(); /// ``` pub const fn new() -> Foo { diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html index d72efa04a..182a3817a 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -35,7 +35,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
#[derive(Clone, Debug)]
+
#[derive(Clone, Debug)]
 struct Foo {
     pub x: i32,
     pub y: i32,
-- 
cgit v1.2.3


From 5ca3855c06b6e28aaa99f5fdda41b6b80ed871b7 Mon Sep 17 00:00:00 2001
From: GrayJack 
Date: Mon, 20 Jul 2020 23:37:31 -0300
Subject: On second thought, we want to preserve the textMate here where all
 punctuation that are from a Attr be highlited as Attribute

---
 crates/ra_ide/src/syntax_highlighting.rs       | 4 +++-
 crates/ra_ide/test_data/highlight_doctest.html | 2 +-
 crates/ra_ide/test_data/highlighting.html      | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

(limited to 'crates')

diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 036180c60..d456d5d36 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -540,7 +540,6 @@ fn highlight_element(
             }
         }
         p if p.is_punct() => match p {
-            T![#] => HighlightTag::Attribute.into(),
             T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => {
                 HighlightTag::Operator.into()
             }
@@ -581,6 +580,9 @@ fn highlight_element(
             _ if element.parent().and_then(ast::DotDotPat::cast).is_some() => {
                 HighlightTag::Operator.into()
             }
+            _ if element.parent().and_then(ast::Attr::cast).is_some() => {
+                HighlightTag::Attribute.into()
+            }
             _ => HighlightTag::Punctuation.into(),
         },
 
diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html
index 78c2a30c3..6322d404f 100644
--- a/crates/ra_ide/test_data/highlight_doctest.html
+++ b/crates/ra_ide/test_data/highlight_doctest.html
@@ -50,7 +50,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     /// # Examples
     ///
     /// ```
-    /// # #![allow(unused_mut)]
+    /// # #![allow(unused_mut)]
     /// let mut foo: Foo = Foo::new();
     /// ```
     pub const fn new() -> Foo {
diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html
index 182a3817a..345a2f023 100644
--- a/crates/ra_ide/test_data/highlighting.html
+++ b/crates/ra_ide/test_data/highlighting.html
@@ -35,7 +35,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
 
-
#[derive(Clone, Debug)]
+
#[derive(Clone, Debug)]
 struct Foo {
     pub x: i32,
     pub y: i32,
-- 
cgit v1.2.3