diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-06 20:59:51 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-06 20:59:51 +0000 |
commit | 431836f4a01dda39d10f6275915f9c8e99a28028 (patch) | |
tree | 0cb8ceaa2e07b30da2f841d792e505df6b460d41 /crates/ra_hir_expand/src/name.rs | |
parent | f18b7e18c479144325ec150be00837aae3329ae2 (diff) | |
parent | b2c01f446edcbc12b5dd870064cbfc6c1a47eb8b (diff) |
Merge #2489
2489: Implement `format_args` r=flodiebold a=flodiebold
This fixes a huge amount of type mismatches (because every format call was a type mismatch so far); I also hoped to get go to def working within `format!` etc., and the test says it should, but in practice it still doesn't seem to...
Also remove the `len` parameter from `Name::new_inline_ascii`, which I'm assuming was only there because of `const fn` limitations?
cc @edwin0cheng
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src/name.rs')
-rw-r--r-- | crates/ra_hir_expand/src/name.rs | 116 |
1 files changed, 59 insertions, 57 deletions
diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs index c5a191160..4f2f702c0 100644 --- a/crates/ra_hir_expand/src/name.rs +++ b/crates/ra_hir_expand/src/name.rs | |||
@@ -38,8 +38,8 @@ impl Name { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | /// Shortcut to create inline plain text name | 40 | /// Shortcut to create inline plain text name |
41 | const fn new_inline_ascii(len: usize, text: &[u8]) -> Name { | 41 | const fn new_inline_ascii(text: &[u8]) -> Name { |
42 | Name::new_text(SmolStr::new_inline_from_ascii(len, text)) | 42 | Name::new_text(SmolStr::new_inline_from_ascii(text.len(), text)) |
43 | } | 43 | } |
44 | 44 | ||
45 | /// Resolve a name from the text of token. | 45 | /// Resolve a name from the text of token. |
@@ -105,68 +105,70 @@ impl AsName for ra_db::Dependency { | |||
105 | } | 105 | } |
106 | 106 | ||
107 | // Primitives | 107 | // Primitives |
108 | pub const ISIZE: Name = Name::new_inline_ascii(5, b"isize"); | 108 | pub const ISIZE: Name = Name::new_inline_ascii(b"isize"); |
109 | pub const I8: Name = Name::new_inline_ascii(2, b"i8"); | 109 | pub const I8: Name = Name::new_inline_ascii(b"i8"); |
110 | pub const I16: Name = Name::new_inline_ascii(3, b"i16"); | 110 | pub const I16: Name = Name::new_inline_ascii(b"i16"); |
111 | pub const I32: Name = Name::new_inline_ascii(3, b"i32"); | 111 | pub const I32: Name = Name::new_inline_ascii(b"i32"); |
112 | pub const I64: Name = Name::new_inline_ascii(3, b"i64"); | 112 | pub const I64: Name = Name::new_inline_ascii(b"i64"); |
113 | pub const I128: Name = Name::new_inline_ascii(4, b"i128"); | 113 | pub const I128: Name = Name::new_inline_ascii(b"i128"); |
114 | pub const USIZE: Name = Name::new_inline_ascii(5, b"usize"); | 114 | pub const USIZE: Name = Name::new_inline_ascii(b"usize"); |
115 | pub const U8: Name = Name::new_inline_ascii(2, b"u8"); | 115 | pub const U8: Name = Name::new_inline_ascii(b"u8"); |
116 | pub const U16: Name = Name::new_inline_ascii(3, b"u16"); | 116 | pub const U16: Name = Name::new_inline_ascii(b"u16"); |
117 | pub const U32: Name = Name::new_inline_ascii(3, b"u32"); | 117 | pub const U32: Name = Name::new_inline_ascii(b"u32"); |
118 | pub const U64: Name = Name::new_inline_ascii(3, b"u64"); | 118 | pub const U64: Name = Name::new_inline_ascii(b"u64"); |
119 | pub const U128: Name = Name::new_inline_ascii(4, b"u128"); | 119 | pub const U128: Name = Name::new_inline_ascii(b"u128"); |
120 | pub const F32: Name = Name::new_inline_ascii(3, b"f32"); | 120 | pub const F32: Name = Name::new_inline_ascii(b"f32"); |
121 | pub const F64: Name = Name::new_inline_ascii(3, b"f64"); | 121 | pub const F64: Name = Name::new_inline_ascii(b"f64"); |
122 | pub const BOOL: Name = Name::new_inline_ascii(4, b"bool"); | 122 | pub const BOOL: Name = Name::new_inline_ascii(b"bool"); |
123 | pub const CHAR: Name = Name::new_inline_ascii(4, b"char"); | 123 | pub const CHAR: Name = Name::new_inline_ascii(b"char"); |
124 | pub const STR: Name = Name::new_inline_ascii(3, b"str"); | 124 | pub const STR: Name = Name::new_inline_ascii(b"str"); |
125 | 125 | ||
126 | // Special names | 126 | // Special names |
127 | pub const SELF_PARAM: Name = Name::new_inline_ascii(4, b"self"); | 127 | pub const SELF_PARAM: Name = Name::new_inline_ascii(b"self"); |
128 | pub const SELF_TYPE: Name = Name::new_inline_ascii(4, b"Self"); | 128 | pub const SELF_TYPE: Name = Name::new_inline_ascii(b"Self"); |
129 | pub const MACRO_RULES: Name = Name::new_inline_ascii(11, b"macro_rules"); | 129 | pub const MACRO_RULES: Name = Name::new_inline_ascii(b"macro_rules"); |
130 | 130 | ||
131 | // Components of known path (value or mod name) | 131 | // Components of known path (value or mod name) |
132 | pub const STD: Name = Name::new_inline_ascii(3, b"std"); | 132 | pub const STD: Name = Name::new_inline_ascii(b"std"); |
133 | pub const ITER: Name = Name::new_inline_ascii(4, b"iter"); | 133 | pub const ITER: Name = Name::new_inline_ascii(b"iter"); |
134 | pub const OPS: Name = Name::new_inline_ascii(3, b"ops"); | 134 | pub const OPS: Name = Name::new_inline_ascii(b"ops"); |
135 | pub const FUTURE: Name = Name::new_inline_ascii(6, b"future"); | 135 | pub const FUTURE: Name = Name::new_inline_ascii(b"future"); |
136 | pub const RESULT: Name = Name::new_inline_ascii(6, b"result"); | 136 | pub const RESULT: Name = Name::new_inline_ascii(b"result"); |
137 | pub const BOXED: Name = Name::new_inline_ascii(5, b"boxed"); | 137 | pub const BOXED: Name = Name::new_inline_ascii(b"boxed"); |
138 | 138 | ||
139 | // Components of known path (type name) | 139 | // Components of known path (type name) |
140 | pub const INTO_ITERATOR_TYPE: Name = Name::new_inline_ascii(12, b"IntoIterator"); | 140 | pub const INTO_ITERATOR_TYPE: Name = Name::new_inline_ascii(b"IntoIterator"); |
141 | pub const ITEM_TYPE: Name = Name::new_inline_ascii(4, b"Item"); | 141 | pub const ITEM_TYPE: Name = Name::new_inline_ascii(b"Item"); |
142 | pub const TRY_TYPE: Name = Name::new_inline_ascii(3, b"Try"); | 142 | pub const TRY_TYPE: Name = Name::new_inline_ascii(b"Try"); |
143 | pub const OK_TYPE: Name = Name::new_inline_ascii(2, b"Ok"); | 143 | pub const OK_TYPE: Name = Name::new_inline_ascii(b"Ok"); |
144 | pub const FUTURE_TYPE: Name = Name::new_inline_ascii(6, b"Future"); | 144 | pub const FUTURE_TYPE: Name = Name::new_inline_ascii(b"Future"); |
145 | pub const RESULT_TYPE: Name = Name::new_inline_ascii(6, b"Result"); | 145 | pub const RESULT_TYPE: Name = Name::new_inline_ascii(b"Result"); |
146 | pub const OUTPUT_TYPE: Name = Name::new_inline_ascii(6, b"Output"); | 146 | pub const OUTPUT_TYPE: Name = Name::new_inline_ascii(b"Output"); |
147 | pub const TARGET_TYPE: Name = Name::new_inline_ascii(6, b"Target"); | 147 | pub const TARGET_TYPE: Name = Name::new_inline_ascii(b"Target"); |
148 | pub const BOX_TYPE: Name = Name::new_inline_ascii(3, b"Box"); | 148 | pub const BOX_TYPE: Name = Name::new_inline_ascii(b"Box"); |
149 | pub const RANGE_FROM_TYPE: Name = Name::new_inline_ascii(9, b"RangeFrom"); | 149 | pub const RANGE_FROM_TYPE: Name = Name::new_inline_ascii(b"RangeFrom"); |
150 | pub const RANGE_FULL_TYPE: Name = Name::new_inline_ascii(9, b"RangeFull"); | 150 | pub const RANGE_FULL_TYPE: Name = Name::new_inline_ascii(b"RangeFull"); |
151 | pub const RANGE_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(14, b"RangeInclusive"); | 151 | pub const RANGE_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(b"RangeInclusive"); |
152 | pub const RANGE_TO_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(16, b"RangeToInclusive"); | 152 | pub const RANGE_TO_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(b"RangeToInclusive"); |
153 | pub const RANGE_TO_TYPE: Name = Name::new_inline_ascii(7, b"RangeTo"); | 153 | pub const RANGE_TO_TYPE: Name = Name::new_inline_ascii(b"RangeTo"); |
154 | pub const RANGE_TYPE: Name = Name::new_inline_ascii(5, b"Range"); | 154 | pub const RANGE_TYPE: Name = Name::new_inline_ascii(b"Range"); |
155 | 155 | ||
156 | // Builtin Macros | 156 | // Builtin Macros |
157 | pub const FILE_MACRO: Name = Name::new_inline_ascii(4, b"file"); | 157 | pub const FILE_MACRO: Name = Name::new_inline_ascii(b"file"); |
158 | pub const COLUMN_MACRO: Name = Name::new_inline_ascii(6, b"column"); | 158 | pub const COLUMN_MACRO: Name = Name::new_inline_ascii(b"column"); |
159 | pub const COMPILE_ERROR_MACRO: Name = Name::new_inline_ascii(13, b"compile_error"); | 159 | pub const COMPILE_ERROR_MACRO: Name = Name::new_inline_ascii(b"compile_error"); |
160 | pub const LINE_MACRO: Name = Name::new_inline_ascii(4, b"line"); | 160 | pub const LINE_MACRO: Name = Name::new_inline_ascii(b"line"); |
161 | pub const STRINGIFY_MACRO: Name = Name::new_inline_ascii(9, b"stringify"); | 161 | pub const STRINGIFY_MACRO: Name = Name::new_inline_ascii(b"stringify"); |
162 | pub const FORMAT_ARGS_MACRO: Name = Name::new_inline_ascii(b"format_args"); | ||
163 | pub const FORMAT_ARGS_NL_MACRO: Name = Name::new_inline_ascii(b"format_args_nl"); | ||
162 | 164 | ||
163 | // Builtin derives | 165 | // Builtin derives |
164 | pub const COPY_TRAIT: Name = Name::new_inline_ascii(4, b"Copy"); | 166 | pub const COPY_TRAIT: Name = Name::new_inline_ascii(b"Copy"); |
165 | pub const CLONE_TRAIT: Name = Name::new_inline_ascii(5, b"Clone"); | 167 | pub const CLONE_TRAIT: Name = Name::new_inline_ascii(b"Clone"); |
166 | pub const DEFAULT_TRAIT: Name = Name::new_inline_ascii(7, b"Default"); | 168 | pub const DEFAULT_TRAIT: Name = Name::new_inline_ascii(b"Default"); |
167 | pub const DEBUG_TRAIT: Name = Name::new_inline_ascii(5, b"Debug"); | 169 | pub const DEBUG_TRAIT: Name = Name::new_inline_ascii(b"Debug"); |
168 | pub const HASH_TRAIT: Name = Name::new_inline_ascii(4, b"Hash"); | 170 | pub const HASH_TRAIT: Name = Name::new_inline_ascii(b"Hash"); |
169 | pub const ORD_TRAIT: Name = Name::new_inline_ascii(3, b"Ord"); | 171 | pub const ORD_TRAIT: Name = Name::new_inline_ascii(b"Ord"); |
170 | pub const PARTIAL_ORD_TRAIT: Name = Name::new_inline_ascii(10, b"PartialOrd"); | 172 | pub const PARTIAL_ORD_TRAIT: Name = Name::new_inline_ascii(b"PartialOrd"); |
171 | pub const EQ_TRAIT: Name = Name::new_inline_ascii(2, b"Eq"); | 173 | pub const EQ_TRAIT: Name = Name::new_inline_ascii(b"Eq"); |
172 | pub const PARTIAL_EQ_TRAIT: Name = Name::new_inline_ascii(9, b"PartialEq"); | 174 | pub const PARTIAL_EQ_TRAIT: Name = Name::new_inline_ascii(b"PartialEq"); |