diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix index 5d66f6e21007..7a2586f01389 100644 --- a/pkgs/development/tools/rust/rust-analyzer/default.nix +++ b/pkgs/development/tools/rust/rust-analyzer/default.nix @@ -2,10 +2,10 @@ { rust-analyzer-unwrapped = callPackage ./generic.nix rec { - rev = "2020-09-21"; + rev = "2020-09-28"; version = "unstable-${rev}"; - sha256 = "1wjm69r1c6s8a4rd91csg7c48bp8jamxsrm5m6rg3bk2gqp8yzz8"; - cargoSha256 = "089w2i6lvpjxkxghkb2mij9sxfxlcc1zv4iq4qmzq8gnc6ddz12d"; + sha256 = "1ynwrkdy78105xbrcynk0qimk90y849hn54sw8q3akdlyfx1kdrs"; + cargoSha256 = "0iy7h3q7dp2nbfzzg7yc8zbkb5npghz8l15d83xd8w8q39i3qff5"; }; rust-analyzer = callPackage ./wrapper.nix {} { diff --git a/pkgs/development/tools/rust/rust-analyzer/downgrade-smol_str.patch b/pkgs/development/tools/rust/rust-analyzer/downgrade-smol_str.patch new file mode 100644 index 000000000000..c3ceb0963336 --- /dev/null +++ b/pkgs/development/tools/rust/rust-analyzer/downgrade-smol_str.patch @@ -0,0 +1,82 @@ +This patch revert 875ad9b5c410200f5072515ae91b4ff51cff0448 (Bump smol_str from 0.1.16 to 0.1.17 ). + +diff --git a/Cargo.lock b/Cargo.lock +index 477af57aa..8b9055879 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -1470,9 +1470,9 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" + + [[package]] + name = "smol_str" +-version = "0.1.17" ++version = "0.1.16" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "6ca0f7ce3a29234210f0f4f0b56f8be2e722488b95cb522077943212da3b32eb" ++checksum = "2f7909a1d8bc166a862124d84fdc11bda0ea4ed3157ccca662296919c2972db1" + dependencies = [ + "serde", + ] +diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs +index a5750d829..49841c7a1 100644 +--- a/crates/hir_expand/src/name.rs ++++ b/crates/hir_expand/src/name.rs +@@ -43,8 +43,8 @@ impl Name { + } + + /// Shortcut to create inline plain text name +- const fn new_inline(text: &str) -> Name { +- Name::new_text(SmolStr::new_inline(text)) ++ const fn new_inline_ascii(text: &[u8]) -> Name { ++ Name::new_text(SmolStr::new_inline_from_ascii(text.len(), text)) + } + + /// Resolve a name from the text of token. +@@ -127,7 +127,7 @@ pub mod known { + $( + #[allow(bad_style)] + pub const $ident: super::Name = +- super::Name::new_inline(stringify!($ident)); ++ super::Name::new_inline_ascii(stringify!($ident).as_bytes()); + )* + }; + } +@@ -210,8 +210,8 @@ pub mod known { + ); + + // self/Self cannot be used as an identifier +- pub const SELF_PARAM: super::Name = super::Name::new_inline("self"); +- pub const SELF_TYPE: super::Name = super::Name::new_inline("Self"); ++ pub const SELF_PARAM: super::Name = super::Name::new_inline_ascii(b"self"); ++ pub const SELF_TYPE: super::Name = super::Name::new_inline_ascii(b"Self"); + + #[macro_export] + macro_rules! name { +diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs +index 9a7785c76..2b53b8297 100644 +--- a/crates/hir_ty/src/infer.rs ++++ b/crates/hir_ty/src/infer.rs +@@ -555,7 +555,7 @@ impl<'a> InferenceContext<'a> { + + fn resolve_lang_item(&self, name: &str) -> Option { + let krate = self.resolver.krate()?; +- let name = SmolStr::new_inline(name); ++ let name = SmolStr::new_inline_from_ascii(name.len(), name.as_bytes()); + self.db.lang_item(krate, name) + } + +diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs +index d987b2500..a8ad917fb 100644 +--- a/crates/mbe/src/syntax_bridge.rs ++++ b/crates/mbe/src/syntax_bridge.rs +@@ -636,10 +636,7 @@ impl<'a> TreeSink for TtTreeSink<'a> { + let (text, id) = match leaf { + tt::Leaf::Ident(ident) => (ident.text.clone(), ident.id), + tt::Leaf::Punct(punct) => { +- assert!(punct.char.is_ascii()); +- let char = &(punct.char as u8); +- let text = std::str::from_utf8(std::slice::from_ref(char)).unwrap(); +- (SmolStr::new_inline(text), punct.id) ++ (SmolStr::new_inline_from_ascii(1, &[punct.char as u8]), punct.id) + } + tt::Leaf::Literal(lit) => (lit.text.clone(), lit.id), + }; diff --git a/pkgs/development/tools/rust/rust-analyzer/generic.nix b/pkgs/development/tools/rust/rust-analyzer/generic.nix index 3bd6d1ccee14..20fb38b66b70 100644 --- a/pkgs/development/tools/rust/rust-analyzer/generic.nix +++ b/pkgs/development/tools/rust/rust-analyzer/generic.nix @@ -16,6 +16,11 @@ rustPlatform.buildRustPackage { inherit rev sha256; }; + # FIXME: Temporary fix for our rust 1.45.0 since rust-analyzer requires 1.46.0 + cargoPatches = [ + ./downgrade-smol_str.patch + ]; + patches = [ # FIXME: Temporary fix for our rust 1.45.0 since rust-analyzer requires 1.46.0 ./no-loop-in-const-fn.patch