diff options
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_derive.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 67 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 49 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 52 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/name.rs | 116 |
5 files changed, 203 insertions, 85 deletions
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 78fa9b09a..574637602 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs | |||
@@ -208,7 +208,7 @@ fn partial_ord_expand( | |||
208 | #[cfg(test)] | 208 | #[cfg(test)] |
209 | mod tests { | 209 | mod tests { |
210 | use super::*; | 210 | use super::*; |
211 | use crate::{test_db::TestDB, AstId, MacroCallKind, MacroCallLoc, MacroFileKind}; | 211 | use crate::{test_db::TestDB, AstId, MacroCallKind, MacroCallLoc}; |
212 | use ra_db::{fixture::WithFixture, SourceDatabase}; | 212 | use ra_db::{fixture::WithFixture, SourceDatabase}; |
213 | 213 | ||
214 | fn expand_builtin_derive(s: &str, expander: BuiltinDeriveExpander) -> String { | 214 | fn expand_builtin_derive(s: &str, expander: BuiltinDeriveExpander) -> String { |
@@ -229,7 +229,7 @@ mod tests { | |||
229 | }; | 229 | }; |
230 | 230 | ||
231 | let id = db.intern_macro(loc); | 231 | let id = db.intern_macro(loc); |
232 | let parsed = db.parse_or_expand(id.as_file(MacroFileKind::Items)).unwrap(); | 232 | let parsed = db.parse_or_expand(id.as_file()).unwrap(); |
233 | 233 | ||
234 | // FIXME text() for syntax nodes parsed from token tree looks weird | 234 | // FIXME text() for syntax nodes parsed from token tree looks weird |
235 | // because there's no whitespace, see below | 235 | // because there's no whitespace, see below |
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 35f99b2bc..c7071fe85 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -2,8 +2,7 @@ | |||
2 | use crate::db::AstDatabase; | 2 | use crate::db::AstDatabase; |
3 | use crate::{ | 3 | use crate::{ |
4 | ast::{self, AstNode}, | 4 | ast::{self, AstNode}, |
5 | name, AstId, CrateId, HirFileId, MacroCallId, MacroDefId, MacroDefKind, MacroFileKind, | 5 | name, AstId, CrateId, HirFileId, MacroCallId, MacroDefId, MacroDefKind, TextUnit, |
6 | TextUnit, | ||
7 | }; | 6 | }; |
8 | 7 | ||
9 | use crate::quote; | 8 | use crate::quote; |
@@ -49,7 +48,11 @@ register_builtin! { | |||
49 | (COMPILE_ERROR_MACRO, CompileError) => compile_error_expand, | 48 | (COMPILE_ERROR_MACRO, CompileError) => compile_error_expand, |
50 | (FILE_MACRO, File) => file_expand, | 49 | (FILE_MACRO, File) => file_expand, |
51 | (LINE_MACRO, Line) => line_expand, | 50 | (LINE_MACRO, Line) => line_expand, |
52 | (STRINGIFY_MACRO, Stringify) => stringify_expand | 51 | (STRINGIFY_MACRO, Stringify) => stringify_expand, |
52 | (FORMAT_ARGS_MACRO, FormatArgs) => format_args_expand, | ||
53 | // format_args_nl only differs in that it adds a newline in the end, | ||
54 | // so we use the same stub expansion for now | ||
55 | (FORMAT_ARGS_NL_MACRO, FormatArgsNl) => format_args_expand | ||
53 | } | 56 | } |
54 | 57 | ||
55 | fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { | 58 | fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { |
@@ -86,7 +89,7 @@ fn line_expand( | |||
86 | let arg = loc.kind.arg(db).ok_or_else(|| mbe::ExpandError::UnexpectedToken)?; | 89 | let arg = loc.kind.arg(db).ok_or_else(|| mbe::ExpandError::UnexpectedToken)?; |
87 | let arg_start = arg.text_range().start(); | 90 | let arg_start = arg.text_range().start(); |
88 | 91 | ||
89 | let file = id.as_file(MacroFileKind::Expr); | 92 | let file = id.as_file(); |
90 | let line_num = to_line_number(db, file, arg_start); | 93 | let line_num = to_line_number(db, file, arg_start); |
91 | 94 | ||
92 | let expanded = quote! { | 95 | let expanded = quote! { |
@@ -154,7 +157,7 @@ fn column_expand( | |||
154 | let _arg = macro_call.token_tree().ok_or_else(|| mbe::ExpandError::UnexpectedToken)?; | 157 | let _arg = macro_call.token_tree().ok_or_else(|| mbe::ExpandError::UnexpectedToken)?; |
155 | let col_start = macro_call.syntax().text_range().start(); | 158 | let col_start = macro_call.syntax().text_range().start(); |
156 | 159 | ||
157 | let file = id.as_file(MacroFileKind::Expr); | 160 | let file = id.as_file(); |
158 | let col_num = to_col_number(db, file, col_start); | 161 | let col_num = to_col_number(db, file, col_start); |
159 | 162 | ||
160 | let expanded = quote! { | 163 | let expanded = quote! { |
@@ -200,6 +203,41 @@ fn compile_error_expand( | |||
200 | Err(mbe::ExpandError::BindingError("Must be a string".into())) | 203 | Err(mbe::ExpandError::BindingError("Must be a string".into())) |
201 | } | 204 | } |
202 | 205 | ||
206 | fn format_args_expand( | ||
207 | _db: &dyn AstDatabase, | ||
208 | _id: MacroCallId, | ||
209 | tt: &tt::Subtree, | ||
210 | ) -> Result<tt::Subtree, mbe::ExpandError> { | ||
211 | // We expand `format_args!("", arg1, arg2)` to | ||
212 | // `std::fmt::Arguments::new_v1(&[], &[&arg1, &arg2])`, | ||
213 | // which is still not really correct, but close enough for now | ||
214 | let mut args = Vec::new(); | ||
215 | let mut current = Vec::new(); | ||
216 | for tt in tt.token_trees.iter().cloned() { | ||
217 | match tt { | ||
218 | tt::TokenTree::Leaf(tt::Leaf::Punct(p)) if p.char == ',' => { | ||
219 | args.push(tt::Subtree { delimiter: tt::Delimiter::None, token_trees: current }); | ||
220 | current = Vec::new(); | ||
221 | } | ||
222 | _ => { | ||
223 | current.push(tt); | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | if !current.is_empty() { | ||
228 | args.push(tt::Subtree { delimiter: tt::Delimiter::None, token_trees: current }); | ||
229 | } | ||
230 | if args.is_empty() { | ||
231 | return Err(mbe::ExpandError::NoMatchingRule); | ||
232 | } | ||
233 | let _format_string = args.remove(0); | ||
234 | let arg_tts = args.into_iter().flat_map(|arg| (quote! { & #arg , }).token_trees); | ||
235 | let expanded = quote! { | ||
236 | std::fmt::Arguments::new_v1(&[], &[##arg_tts]) | ||
237 | }; | ||
238 | Ok(expanded) | ||
239 | } | ||
240 | |||
203 | #[cfg(test)] | 241 | #[cfg(test)] |
204 | mod tests { | 242 | mod tests { |
205 | use super::*; | 243 | use super::*; |
@@ -230,7 +268,7 @@ mod tests { | |||
230 | }; | 268 | }; |
231 | 269 | ||
232 | let id = db.intern_macro(loc); | 270 | let id = db.intern_macro(loc); |
233 | let parsed = db.parse_or_expand(id.as_file(MacroFileKind::Expr)).unwrap(); | 271 | let parsed = db.parse_or_expand(id.as_file()).unwrap(); |
234 | 272 | ||
235 | parsed.text().to_string() | 273 | parsed.text().to_string() |
236 | } | 274 | } |
@@ -307,4 +345,21 @@ mod tests { | |||
307 | 345 | ||
308 | assert_eq!(expanded, r#"loop{"error!"}"#); | 346 | assert_eq!(expanded, r#"loop{"error!"}"#); |
309 | } | 347 | } |
348 | |||
349 | #[test] | ||
350 | fn test_format_args_expand() { | ||
351 | let expanded = expand_builtin_macro( | ||
352 | r#" | ||
353 | #[rustc_builtin_macro] | ||
354 | macro_rules! format_args { | ||
355 | ($fmt:expr) => ({ /* compiler built-in */ }); | ||
356 | ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ }) | ||
357 | } | ||
358 | format_args!("{} {:?}", arg1(a, b, c), arg2); | ||
359 | "#, | ||
360 | BuiltinFnLikeExpander::FormatArgs, | ||
361 | ); | ||
362 | |||
363 | assert_eq!(expanded, r#"std::fmt::Arguments::new_v1(&[] ,&[&arg1(a,b,c),&arg2,])"#); | ||
364 | } | ||
310 | } | 365 | } |
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 99dabf3fb..4bdb41619 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -6,11 +6,11 @@ use mbe::MacroRules; | |||
6 | use ra_db::{salsa, SourceDatabase}; | 6 | use ra_db::{salsa, SourceDatabase}; |
7 | use ra_parser::FragmentKind; | 7 | use ra_parser::FragmentKind; |
8 | use ra_prof::profile; | 8 | use ra_prof::profile; |
9 | use ra_syntax::{AstNode, Parse, SyntaxNode}; | 9 | use ra_syntax::{AstNode, Parse, SyntaxKind::*, SyntaxNode}; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, HirFileId, HirFileIdRepr, | 12 | ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, HirFileId, HirFileIdRepr, |
13 | MacroCallId, MacroCallLoc, MacroDefId, MacroDefKind, MacroFile, MacroFileKind, | 13 | MacroCallId, MacroCallLoc, MacroDefId, MacroDefKind, MacroFile, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | #[derive(Debug, Clone, Eq, PartialEq)] | 16 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -45,8 +45,8 @@ impl TokenExpander { | |||
45 | pub fn map_id_up(&self, id: tt::TokenId) -> (tt::TokenId, mbe::Origin) { | 45 | pub fn map_id_up(&self, id: tt::TokenId) -> (tt::TokenId, mbe::Origin) { |
46 | match self { | 46 | match self { |
47 | TokenExpander::MacroRules(it) => it.map_id_up(id), | 47 | TokenExpander::MacroRules(it) => it.map_id_up(id), |
48 | TokenExpander::Builtin(..) => (id, mbe::Origin::Def), | 48 | TokenExpander::Builtin(..) => (id, mbe::Origin::Call), |
49 | TokenExpander::BuiltinDerive(..) => (id, mbe::Origin::Def), | 49 | TokenExpander::BuiltinDerive(..) => (id, mbe::Origin::Call), |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
@@ -155,11 +155,42 @@ pub(crate) fn parse_macro( | |||
155 | }) | 155 | }) |
156 | .ok()?; | 156 | .ok()?; |
157 | 157 | ||
158 | let fragment_kind = match macro_file.macro_file_kind { | 158 | let fragment_kind = to_fragment_kind(db, macro_call_id); |
159 | MacroFileKind::Items => FragmentKind::Items, | 159 | |
160 | MacroFileKind::Expr => FragmentKind::Expr, | ||
161 | MacroFileKind::Statements => FragmentKind::Statements, | ||
162 | }; | ||
163 | let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?; | 160 | let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?; |
164 | Some((parse, Arc::new(rev_token_map))) | 161 | Some((parse, Arc::new(rev_token_map))) |
165 | } | 162 | } |
163 | |||
164 | /// Given a `MacroCallId`, return what `FragmentKind` it belongs to. | ||
165 | /// FIXME: Not completed | ||
166 | fn to_fragment_kind(db: &dyn AstDatabase, macro_call_id: MacroCallId) -> FragmentKind { | ||
167 | let syn = db.lookup_intern_macro(macro_call_id).kind.node(db).value; | ||
168 | |||
169 | let parent = match syn.parent() { | ||
170 | Some(it) => it, | ||
171 | None => { | ||
172 | // FIXME: | ||
173 | // If it is root, which means the parent HirFile | ||
174 | // MacroKindFile must be non-items | ||
175 | // return expr now. | ||
176 | return FragmentKind::Expr; | ||
177 | } | ||
178 | }; | ||
179 | |||
180 | match parent.kind() { | ||
181 | MACRO_ITEMS | SOURCE_FILE => FragmentKind::Items, | ||
182 | LET_STMT => { | ||
183 | // FIXME: Handle Pattern | ||
184 | FragmentKind::Expr | ||
185 | } | ||
186 | EXPR_STMT => FragmentKind::Statements, | ||
187 | BLOCK => FragmentKind::Statements, | ||
188 | ARG_LIST => FragmentKind::Expr, | ||
189 | TRY_EXPR => FragmentKind::Expr, | ||
190 | TUPLE_EXPR => FragmentKind::Expr, | ||
191 | _ => { | ||
192 | // Unknown , Just guess it is `Items` | ||
193 | FragmentKind::Items | ||
194 | } | ||
195 | } | ||
196 | } | ||
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 59c69b91b..94e1e466a 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -76,6 +76,17 @@ impl HirFileId { | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | /// If this is a macro call, returns the syntax node of the call. | ||
80 | pub fn call_node(self, db: &dyn db::AstDatabase) -> Option<InFile<SyntaxNode>> { | ||
81 | match self.0 { | ||
82 | HirFileIdRepr::FileId(_) => None, | ||
83 | HirFileIdRepr::MacroFile(macro_file) => { | ||
84 | let loc = db.lookup_intern_macro(macro_file.macro_call_id); | ||
85 | Some(loc.kind.node(db)) | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
79 | /// Return expansion information if it is a macro-expansion file | 90 | /// Return expansion information if it is a macro-expansion file |
80 | pub fn expansion_info(self, db: &dyn db::AstDatabase) -> Option<ExpansionInfo> { | 91 | pub fn expansion_info(self, db: &dyn db::AstDatabase) -> Option<ExpansionInfo> { |
81 | match self.0 { | 92 | match self.0 { |
@@ -106,14 +117,6 @@ impl HirFileId { | |||
106 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 117 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
107 | pub struct MacroFile { | 118 | pub struct MacroFile { |
108 | macro_call_id: MacroCallId, | 119 | macro_call_id: MacroCallId, |
109 | macro_file_kind: MacroFileKind, | ||
110 | } | ||
111 | |||
112 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
113 | pub enum MacroFileKind { | ||
114 | Items, | ||
115 | Expr, | ||
116 | Statements, | ||
117 | } | 120 | } |
118 | 121 | ||
119 | /// `MacroCallId` identifies a particular macro invocation, like | 122 | /// `MacroCallId` identifies a particular macro invocation, like |
@@ -176,6 +179,13 @@ impl MacroCallKind { | |||
176 | } | 179 | } |
177 | } | 180 | } |
178 | 181 | ||
182 | pub fn node(&self, db: &dyn db::AstDatabase) -> InFile<SyntaxNode> { | ||
183 | match self { | ||
184 | MacroCallKind::FnLike(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()), | ||
185 | MacroCallKind::Attr(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()), | ||
186 | } | ||
187 | } | ||
188 | |||
179 | pub fn arg(&self, db: &dyn db::AstDatabase) -> Option<SyntaxNode> { | 189 | pub fn arg(&self, db: &dyn db::AstDatabase) -> Option<SyntaxNode> { |
180 | match self { | 190 | match self { |
181 | MacroCallKind::FnLike(ast_id) => { | 191 | MacroCallKind::FnLike(ast_id) => { |
@@ -187,9 +197,8 @@ impl MacroCallKind { | |||
187 | } | 197 | } |
188 | 198 | ||
189 | impl MacroCallId { | 199 | impl MacroCallId { |
190 | pub fn as_file(self, kind: MacroFileKind) -> HirFileId { | 200 | pub fn as_file(self) -> HirFileId { |
191 | let macro_file = MacroFile { macro_call_id: self, macro_file_kind: kind }; | 201 | MacroFile { macro_call_id: self }.into() |
192 | macro_file.into() | ||
193 | } | 202 | } |
194 | } | 203 | } |
195 | 204 | ||
@@ -283,3 +292,24 @@ impl<T> InFile<T> { | |||
283 | db.parse_or_expand(self.file_id).expect("source created from invalid file") | 292 | db.parse_or_expand(self.file_id).expect("source created from invalid file") |
284 | } | 293 | } |
285 | } | 294 | } |
295 | |||
296 | impl<T: Clone> InFile<&T> { | ||
297 | pub fn cloned(&self) -> InFile<T> { | ||
298 | self.with_value(self.value.clone()) | ||
299 | } | ||
300 | } | ||
301 | |||
302 | impl InFile<SyntaxNode> { | ||
303 | pub fn ancestors_with_macros<'a>( | ||
304 | self, | ||
305 | db: &'a impl crate::db::AstDatabase, | ||
306 | ) -> impl Iterator<Item = InFile<SyntaxNode>> + 'a { | ||
307 | std::iter::successors(Some(self), move |node| match node.value.parent() { | ||
308 | Some(parent) => Some(node.with_value(parent)), | ||
309 | None => { | ||
310 | let parent_node = node.file_id.call_node(db)?; | ||
311 | Some(parent_node) | ||
312 | } | ||
313 | }) | ||
314 | } | ||
315 | } | ||
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"); |