diff --git a/Cargo.lock b/Cargo.lock index e0ba7b688a..90a9f38220 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,9 +126,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "chalk-derive" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9396f12a23b1a40d5019aa81bc0cbd7ccd2c9736d6bc4afc95868533c2346dcb" +checksum = "eea3a22f0c30b2504ac4ab58934dac0d00b92a4d7788df32795cabca24c3f929" dependencies = [ "proc-macro2", "quote", @@ -138,9 +138,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e9c67d500717d65ede27affb7ae40efe240d86fbefff1006fe0ffb62d4caf9" +checksum = "fb617b643e145e3b151502799e91a9625dd5daf1cf05dc2cb821bc75ae0c9cbd" dependencies = [ "chalk-derive", "lazy_static", @@ -148,9 +148,9 @@ dependencies = [ [[package]] name = "chalk-recursive" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fd2ac0fc06c857b95614d229bbe8ea317d1d94a7e8b9442a3f05c9a2c2d5f4" +checksum = "d280565c8eefbf9b2bc615df49c7dfd971faad37774bf65734e626fd23864bd6" dependencies = [ "chalk-derive", "chalk-ir", @@ -161,9 +161,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a79166f2405c1e51eadcc1344f5ee833c7b391532dd78f64a0731a9a123cc58" +checksum = "be906fbca3f3077dce0e76d9864771d0f450c946af0d86b569fb9504148a065a" dependencies = [ "chalk-derive", "chalk-ir", @@ -1506,9 +1506,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_lexer" -version = "666.0.0" +version = "669.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e00c526f9f8430ea4cd2178d25b02bfc7debe6677350c57292f92f50e65d2fe" +checksum = "456af5f09c006cf6c22c1a433ee0232c4bb74bdc6c647a010166a47c94ed2a63" dependencies = [ "unicode-xid", ] diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 78f5e55bb8..548a3fc1f4 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" diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 758d5f5ac6..19770e609a 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 09883ab4de..f2e4f7ee54 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 }"#, ); } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 6ac44c2c02..d456d5d362 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -539,21 +539,52 @@ 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![&] | T![..] | T![=] | T![@] => { + HighlightTag::Operator.into() } - } - 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::MacroCall::cast).is_some() => { + 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)?; + + 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() + } + _ 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() + } + _ if element.parent().and_then(ast::Attr::cast).is_some() => { + HighlightTag::Attribute.into() + } + _ => HighlightTag::Punctuation.into(), + }, k if k.is_keyword() => { let h = Highlight::new(HighlightTag::Keyword); diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index 1cc17d6d01..6322d404fb 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -36,24 +36,24 @@ 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`.
     ///
     /// # Examples
     ///
     /// ```
-    /// # #![allow(unused_mut)]
-    /// let mut foo: Foo = Foo::new();
+    /// # #![allow(unused_mut)]
+    /// let mut foo: Foo = Foo::new();
     /// ```
-    pub const fn new() -> Foo {
+    pub const fn new() -> Foo {
         Foo { bar: true }
     }
 
@@ -62,32 +62,32 @@ 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 */
     ///
-    /// 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
     /// echo 1
     /// ```
-    pub fn foo(&self) -> bool {
+    pub fn foo(&self) -> bool {
         true
     }
 }
@@ -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_injection.html b/crates/ra_ide/test_data/highlight_injection.html index 461cfc4377..18addd00d2 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 9f98e73e74..1b681b2c6b 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) => {{ /* 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 88ac91f9a0..b81b6f1c3b 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 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 767e82f9d0..345a2f0231 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -35,50 +35,50 @@ 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,
 }
 
 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;
+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
     }
 }
 
 macro_rules! noop {
-    ($expr:expr) => {
+    ($expr:expr) => {
         $expr
     }
 }
@@ -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;
+        let x = 92;
         vec.push(Foo { x, y: 1 });
     }
     unsafe {
         vec.set_len(0);
-        STATIC_MUT = 1;
+        STATIC_MUT = 1;
     }
 
     for e in vec {
@@ -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;
 }
@@ -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 diff --git a/crates/ra_ide/test_data/rainbow_highlighting.html b/crates/ra_ide/test_data/rainbow_highlighting.html index 2fed04a444..08d83302ce 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 diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 57cc09854b..670f04578a 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"