aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/tools/rust/rust-analyzer/downgrade-smol_str.patch
blob: c3ceb096333607bdc127ab6d6e41ea722d41d591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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<LangItemTarget> {
         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),
                     };