]>
Commit | Line | Data |
---|---|---|
476ff2be | 1 | //! An "interner" is a data structure that associates values with usize tags and |
0731742a | 2 | //! allows bidirectional lookup; i.e., given a value, one can easily find the |
476ff2be SL |
3 | //! type, and vice versa. |
4 | ||
f035d41b | 5 | use rustc_arena::DroplessArena; |
0731742a | 6 | use rustc_data_structures::fx::FxHashMap; |
dfeec247 | 7 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; |
3dfed10e | 8 | use rustc_macros::HashStable_Generic; |
416331ca | 9 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
0731742a | 10 | |
dfeec247 | 11 | use std::cmp::{Ord, PartialEq, PartialOrd}; |
dc9dc135 | 12 | use std::fmt; |
83c7162d | 13 | use std::hash::{Hash, Hasher}; |
dc9dc135 | 14 | use std::str; |
476ff2be | 15 | |
136023e0 | 16 | use crate::{with_session_globals, Edition, Span, DUMMY_SP}; |
0731742a | 17 | |
416331ca XL |
18 | #[cfg(test)] |
19 | mod tests; | |
20 | ||
6a06907d | 21 | // The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`. |
48663c56 XL |
22 | symbols! { |
23 | // After modifying this list adjust `is_special`, `is_used_keyword`/`is_unused_keyword`, | |
24 | // this should be rarely necessary though if the keywords are kept in alphabetic order. | |
25 | Keywords { | |
26 | // Special reserved identifiers used internally for elided lifetimes, | |
27 | // unnamed method parameters, crate root module, error recovery etc. | |
5869c6ff | 28 | Empty: "", |
48663c56 XL |
29 | PathRoot: "{{root}}", |
30 | DollarCrate: "$crate", | |
31 | Underscore: "_", | |
32 | ||
33 | // Keywords that are used in stable Rust. | |
34 | As: "as", | |
35 | Break: "break", | |
36 | Const: "const", | |
37 | Continue: "continue", | |
38 | Crate: "crate", | |
39 | Else: "else", | |
40 | Enum: "enum", | |
41 | Extern: "extern", | |
42 | False: "false", | |
43 | Fn: "fn", | |
44 | For: "for", | |
45 | If: "if", | |
46 | Impl: "impl", | |
47 | In: "in", | |
48 | Let: "let", | |
49 | Loop: "loop", | |
50 | Match: "match", | |
51 | Mod: "mod", | |
52 | Move: "move", | |
53 | Mut: "mut", | |
54 | Pub: "pub", | |
55 | Ref: "ref", | |
56 | Return: "return", | |
57 | SelfLower: "self", | |
58 | SelfUpper: "Self", | |
59 | Static: "static", | |
60 | Struct: "struct", | |
61 | Super: "super", | |
62 | Trait: "trait", | |
63 | True: "true", | |
64 | Type: "type", | |
65 | Unsafe: "unsafe", | |
66 | Use: "use", | |
67 | Where: "where", | |
68 | While: "while", | |
69 | ||
70 | // Keywords that are used in unstable Rust or reserved for future use. | |
71 | Abstract: "abstract", | |
72 | Become: "become", | |
73 | Box: "box", | |
74 | Do: "do", | |
75 | Final: "final", | |
76 | Macro: "macro", | |
77 | Override: "override", | |
78 | Priv: "priv", | |
79 | Typeof: "typeof", | |
80 | Unsized: "unsized", | |
81 | Virtual: "virtual", | |
82 | Yield: "yield", | |
83 | ||
84 | // Edition-specific keywords that are used in stable Rust. | |
e1599b0c XL |
85 | Async: "async", // >= 2018 Edition only |
86 | Await: "await", // >= 2018 Edition only | |
48663c56 XL |
87 | Dyn: "dyn", // >= 2018 Edition only |
88 | ||
89 | // Edition-specific keywords that are used in unstable Rust or reserved for future use. | |
48663c56 XL |
90 | Try: "try", // >= 2018 Edition only |
91 | ||
92 | // Special lifetime names | |
93 | UnderscoreLifetime: "'_", | |
94 | StaticLifetime: "'static", | |
95 | ||
96 | // Weak keywords, have special meaning only in specific contexts. | |
97 | Auto: "auto", | |
98 | Catch: "catch", | |
99 | Default: "default", | |
74b04a01 | 100 | MacroRules: "macro_rules", |
60c5eb7d | 101 | Raw: "raw", |
48663c56 XL |
102 | Union: "union", |
103 | } | |
104 | ||
3dfed10e XL |
105 | // Pre-interned symbols that can be referred to with `rustc_span::sym::*`. |
106 | // | |
107 | // The symbol is the stringified identifier unless otherwise specified, in | |
108 | // which case the name should mention the non-identifier punctuation. | |
109 | // E.g. `sym::proc_dash_macro` represents "proc-macro", and it shouldn't be | |
110 | // called `sym::proc_macro` because then it's easy to mistakenly think it | |
111 | // represents "proc_macro". | |
dc9dc135 | 112 | // |
1b1a35ee | 113 | // As well as the symbols listed, there are symbols for the strings |
dc9dc135 | 114 | // "0", "1", ..., "9", which are accessible via `sym::integer`. |
3dfed10e XL |
115 | // |
116 | // The proc macro will abort if symbols are not in alphabetical order (as | |
117 | // defined by `impl Ord for str`) or if any symbols are duplicated. Vim | |
118 | // users can sort the list by selecting it and executing the command | |
119 | // `:'<,'>!LC_ALL=C sort`. | |
120 | // | |
121 | // There is currently no checking that all symbols are used; that would be | |
122 | // nice to have. | |
48663c56 | 123 | Symbols { |
3dfed10e | 124 | Alignment, |
136023e0 | 125 | Any, |
3dfed10e XL |
126 | Arc, |
127 | Argument, | |
128 | ArgumentV1, | |
129 | Arguments, | |
136023e0 XL |
130 | AsMut, |
131 | AsRef, | |
132 | BTreeEntry, | |
6a06907d XL |
133 | BTreeMap, |
134 | BTreeSet, | |
135 | BinaryHeap, | |
136 | Borrow, | |
17df50a5 | 137 | Break, |
3dfed10e | 138 | C, |
17df50a5 | 139 | CStr, |
29967ef6 | 140 | CString, |
3dfed10e XL |
141 | Center, |
142 | Clone, | |
17df50a5 | 143 | Continue, |
3dfed10e XL |
144 | Copy, |
145 | Count, | |
136023e0 | 146 | Cow, |
3dfed10e | 147 | Debug, |
5869c6ff XL |
148 | DebugStruct, |
149 | DebugTuple, | |
3dfed10e XL |
150 | Decodable, |
151 | Decoder, | |
152 | Default, | |
6a06907d | 153 | Deref, |
136023e0 XL |
154 | DirBuilder, |
155 | DoubleEndedIterator, | |
156 | Duration, | |
3dfed10e XL |
157 | Encodable, |
158 | Encoder, | |
159 | Eq, | |
160 | Equal, | |
161 | Err, | |
162 | Error, | |
136023e0 XL |
163 | File, |
164 | FileType, | |
3dfed10e XL |
165 | FormatSpec, |
166 | Formatter, | |
167 | From, | |
136023e0 | 168 | FromIterator, |
3dfed10e XL |
169 | Future, |
170 | FxHashMap, | |
171 | FxHashSet, | |
172 | GlobalAlloc, | |
173 | Hash, | |
174 | HashMap, | |
136023e0 | 175 | HashMapEntry, |
3dfed10e XL |
176 | HashSet, |
177 | Hasher, | |
178 | Implied, | |
179 | Input, | |
180 | IntoIterator, | |
136023e0 XL |
181 | IoRead, |
182 | IoWrite, | |
3dfed10e XL |
183 | Is, |
184 | ItemContext, | |
185 | Iterator, | |
186 | Layout, | |
187 | Left, | |
6a06907d | 188 | LinkedList, |
3dfed10e XL |
189 | LintPass, |
190 | None, | |
191 | Ok, | |
192 | Option, | |
193 | Ord, | |
194 | Ordering, | |
6a06907d XL |
195 | OsStr, |
196 | OsString, | |
3dfed10e XL |
197 | Output, |
198 | Param, | |
199 | PartialEq, | |
200 | PartialOrd, | |
6a06907d XL |
201 | Path, |
202 | PathBuf, | |
3dfed10e XL |
203 | Pending, |
204 | Pin, | |
205 | Poll, | |
206 | ProcMacro, | |
207 | ProcMacroHack, | |
208 | ProceduralMasqueradeDummyType, | |
209 | Range, | |
210 | RangeFrom, | |
211 | RangeFull, | |
212 | RangeInclusive, | |
213 | RangeTo, | |
214 | RangeToInclusive, | |
215 | Rc, | |
216 | Ready, | |
6a06907d | 217 | Receiver, |
3dfed10e XL |
218 | Result, |
219 | Return, | |
220 | Right, | |
221 | RustcDecodable, | |
222 | RustcEncodable, | |
223 | Send, | |
224 | Some, | |
225 | StructuralEq, | |
226 | StructuralPartialEq, | |
227 | Sync, | |
228 | Target, | |
6a06907d XL |
229 | ToOwned, |
230 | ToString, | |
3dfed10e XL |
231 | Try, |
232 | Ty, | |
233 | TyCtxt, | |
234 | TyKind, | |
235 | Unknown, | |
236 | Vec, | |
237 | Yield, | |
238 | _DECLS, | |
239 | _Self, | |
240 | __D, | |
241 | __H, | |
242 | __S, | |
243 | __next, | |
244 | __try_var, | |
245 | _d, | |
246 | _e, | |
247 | _task_context, | |
29967ef6 | 248 | a32, |
48663c56 XL |
249 | aarch64_target_feature, |
250 | abi, | |
251 | abi_amdgpu_kernel, | |
3dfed10e | 252 | abi_avr_interrupt, |
5869c6ff | 253 | abi_c_cmse_nonsecure_call, |
e74abb32 | 254 | abi_efiapi, |
48663c56 XL |
255 | abi_msp430_interrupt, |
256 | abi_ptx, | |
257 | abi_sysv64, | |
258 | abi_thiscall, | |
259 | abi_unadjusted, | |
260 | abi_vectorcall, | |
261 | abi_x86_interrupt, | |
ba9703b0 | 262 | abort, |
48663c56 | 263 | aborts, |
3dfed10e XL |
264 | add, |
265 | add_assign, | |
60c5eb7d | 266 | add_with_overflow, |
3dfed10e | 267 | address, |
48663c56 XL |
268 | advanced_slice_patterns, |
269 | adx_target_feature, | |
270 | alias, | |
271 | align, | |
3dfed10e | 272 | align_offset, |
48663c56 XL |
273 | alignstack, |
274 | all, | |
3dfed10e XL |
275 | alloc, |
276 | alloc_error_handler, | |
277 | alloc_layout, | |
278 | alloc_zeroed, | |
48663c56 XL |
279 | allocator, |
280 | allocator_internals, | |
48663c56 | 281 | allow, |
48663c56 XL |
282 | allow_fail, |
283 | allow_internal_unsafe, | |
284 | allow_internal_unstable, | |
3dfed10e | 285 | allowed, |
48663c56 | 286 | always, |
dc9dc135 | 287 | and, |
3dfed10e | 288 | and_then, |
48663c56 | 289 | any, |
dc9dc135 | 290 | arbitrary_enum_discriminant, |
48663c56 | 291 | arbitrary_self_types, |
f9f354fc | 292 | arith_offset, |
29967ef6 | 293 | arm, |
48663c56 | 294 | arm_target_feature, |
3dfed10e XL |
295 | array, |
296 | arrays, | |
29967ef6 | 297 | as_ptr, |
3dfed10e | 298 | as_str, |
48663c56 | 299 | asm, |
416331ca | 300 | assert, |
f035d41b | 301 | assert_inhabited, |
fc512014 | 302 | assert_macro, |
3dfed10e | 303 | assert_receiver_is_total_eq, |
f035d41b XL |
304 | assert_uninit_valid, |
305 | assert_zero_valid, | |
48663c56 | 306 | associated_consts, |
dc9dc135 | 307 | associated_type_bounds, |
48663c56 XL |
308 | associated_type_defaults, |
309 | associated_types, | |
f035d41b | 310 | assume, |
60c5eb7d | 311 | assume_init, |
48663c56 | 312 | async_await, |
416331ca | 313 | async_closure, |
f035d41b | 314 | atomics, |
3dfed10e | 315 | att_syntax, |
48663c56 | 316 | attr, |
48663c56 | 317 | attr_literals, |
3dfed10e | 318 | attributes, |
48663c56 | 319 | augmented_assignments, |
fc512014 | 320 | auto_traits, |
48663c56 XL |
321 | automatically_derived, |
322 | avx512_target_feature, | |
323 | await_macro, | |
3dfed10e | 324 | bang, |
dc9dc135 XL |
325 | begin_panic, |
326 | bench, | |
48663c56 XL |
327 | bin, |
328 | bind_by_move_pattern_guards, | |
dfeec247 | 329 | bindings_after_at, |
3dfed10e XL |
330 | bitand, |
331 | bitand_assign, | |
332 | bitor, | |
333 | bitor_assign, | |
334 | bitreverse, | |
335 | bitxor, | |
336 | bitxor_assign, | |
48663c56 | 337 | block, |
dc9dc135 | 338 | bool, |
dfeec247 | 339 | borrowck_graphviz_format, |
48663c56 XL |
340 | borrowck_graphviz_postflow, |
341 | borrowck_graphviz_preflow, | |
3dfed10e | 342 | box_free, |
48663c56 XL |
343 | box_patterns, |
344 | box_syntax, | |
17df50a5 | 345 | bpf_target_feature, |
48663c56 | 346 | braced_empty_structs, |
17df50a5 | 347 | branch, |
f035d41b | 348 | breakpoint, |
3dfed10e | 349 | bridge, |
60c5eb7d | 350 | bswap, |
29967ef6 | 351 | c_str, |
6a06907d | 352 | c_unwind, |
3dfed10e XL |
353 | c_variadic, |
354 | call, | |
355 | call_mut, | |
356 | call_once, | |
60c5eb7d | 357 | caller_location, |
fc512014 | 358 | capture_disjoint_fields, |
48663c56 | 359 | cdylib, |
f035d41b XL |
360 | ceilf32, |
361 | ceilf64, | |
48663c56 | 362 | cfg, |
ba9703b0 | 363 | cfg_accessible, |
48663c56 XL |
364 | cfg_attr, |
365 | cfg_attr_multi, | |
416331ca | 366 | cfg_doctest, |
6a06907d | 367 | cfg_eval, |
29967ef6 | 368 | cfg_panic, |
60c5eb7d | 369 | cfg_sanitize, |
136023e0 | 370 | cfg_target_abi, |
48663c56 XL |
371 | cfg_target_feature, |
372 | cfg_target_has_atomic, | |
373 | cfg_target_thread_local, | |
374 | cfg_target_vendor, | |
f9f354fc | 375 | cfg_version, |
dc9dc135 | 376 | char, |
3dfed10e | 377 | client, |
416331ca | 378 | clippy, |
48663c56 XL |
379 | clone, |
380 | clone_closures, | |
381 | clone_from, | |
1b1a35ee | 382 | closure, |
48663c56 | 383 | closure_to_fn_coercion, |
dc9dc135 | 384 | cmp, |
136023e0 XL |
385 | cmp_max, |
386 | cmp_min, | |
48663c56 | 387 | cmpxchg16b_target_feature, |
1b1a35ee | 388 | cmse_nonsecure_entry, |
3dfed10e | 389 | coerce_unsized, |
48663c56 | 390 | cold, |
416331ca | 391 | column, |
48663c56 XL |
392 | compile_error, |
393 | compiler_builtins, | |
416331ca | 394 | concat, |
48663c56 XL |
395 | concat_idents, |
396 | conservative_impl_trait, | |
397 | console, | |
fc512014 | 398 | const_allocate, |
17df50a5 | 399 | const_async_blocks, |
48663c56 | 400 | const_compare_raw_pointers, |
dc9dc135 | 401 | const_constructor, |
74b04a01 | 402 | const_eval_limit, |
1b1a35ee | 403 | const_evaluatable_checked, |
e74abb32 | 404 | const_extern_fn, |
48663c56 | 405 | const_fn, |
1b1a35ee XL |
406 | const_fn_floating_point_arithmetic, |
407 | const_fn_fn_ptr_basics, | |
cdc7bbd5 | 408 | const_fn_trait_bound, |
f035d41b | 409 | const_fn_transmute, |
48663c56 | 410 | const_fn_union, |
cdc7bbd5 XL |
411 | const_fn_unsize, |
412 | const_generic_defaults, | |
48663c56 | 413 | const_generics, |
5869c6ff | 414 | const_generics_defaults, |
60c5eb7d | 415 | const_if_match, |
29967ef6 | 416 | const_impl_trait, |
416331ca | 417 | const_in_array_repeat_expressions, |
3dfed10e | 418 | const_indexing, |
48663c56 | 419 | const_let, |
60c5eb7d XL |
420 | const_loop, |
421 | const_mut_refs, | |
48663c56 | 422 | const_panic, |
f035d41b | 423 | const_precise_live_drops, |
3dfed10e | 424 | const_ptr, |
48663c56 XL |
425 | const_raw_ptr_deref, |
426 | const_raw_ptr_to_usize_cast, | |
5869c6ff | 427 | const_refs_to_cell, |
3dfed10e | 428 | const_slice_ptr, |
dfeec247 XL |
429 | const_trait_bound_opt_out, |
430 | const_trait_impl, | |
3dfed10e | 431 | const_transmute, |
1b1a35ee XL |
432 | constant, |
433 | constructor, | |
48663c56 | 434 | contents, |
dc9dc135 | 435 | context, |
48663c56 | 436 | convert, |
f035d41b | 437 | copy, |
3dfed10e | 438 | copy_closures, |
f035d41b XL |
439 | copy_nonoverlapping, |
440 | copysignf32, | |
441 | copysignf64, | |
48663c56 XL |
442 | core, |
443 | core_intrinsics, | |
5869c6ff XL |
444 | core_panic, |
445 | core_panic_2015_macro, | |
fc512014 | 446 | core_panic_macro, |
f035d41b XL |
447 | cosf32, |
448 | cosf64, | |
48663c56 XL |
449 | crate_id, |
450 | crate_in_paths, | |
dc9dc135 | 451 | crate_local, |
48663c56 XL |
452 | crate_name, |
453 | crate_type, | |
454 | crate_visibility_modifier, | |
3dfed10e | 455 | crt_dash_static: "crt-static", |
29967ef6 | 456 | cstring_type, |
3dfed10e XL |
457 | ctlz, |
458 | ctlz_nonzero, | |
60c5eb7d XL |
459 | ctpop, |
460 | cttz, | |
461 | cttz_nonzero, | |
48663c56 XL |
462 | custom_attribute, |
463 | custom_derive, | |
464 | custom_inner_attributes, | |
465 | custom_test_frameworks, | |
3dfed10e XL |
466 | d, |
467 | dead_code, | |
468 | dealloc, | |
469 | debug, | |
fc512014 | 470 | debug_assert_macro, |
3dfed10e XL |
471 | debug_assertions, |
472 | debug_struct, | |
e1599b0c | 473 | debug_trait, |
3dfed10e XL |
474 | debug_trait_builder, |
475 | debug_tuple, | |
48663c56 | 476 | decl_macro, |
3dfed10e XL |
477 | declare_lint_pass, |
478 | decode, | |
29967ef6 | 479 | default_alloc_error_handler, |
48663c56 | 480 | default_lib_allocator, |
136023e0 | 481 | default_method_body_is_const, |
48663c56 XL |
482 | default_type_parameter_fallback, |
483 | default_type_params, | |
60c5eb7d | 484 | delay_span_bug_from_inside_query, |
48663c56 XL |
485 | deny, |
486 | deprecated, | |
dc9dc135 | 487 | deref, |
1b1a35ee | 488 | deref_method, |
dc9dc135 | 489 | deref_mut, |
1b1a35ee | 490 | deref_target, |
48663c56 | 491 | derive, |
29967ef6 | 492 | destructuring_assignment, |
e1599b0c | 493 | diagnostic, |
dc9dc135 | 494 | direct, |
3dfed10e XL |
495 | discriminant_kind, |
496 | discriminant_type, | |
ba9703b0 | 497 | discriminant_value, |
3dfed10e | 498 | dispatch_from_dyn, |
136023e0 | 499 | display_trait, |
3dfed10e XL |
500 | div, |
501 | div_assign, | |
48663c56 XL |
502 | doc, |
503 | doc_alias, | |
504 | doc_cfg, | |
505 | doc_keyword, | |
506 | doc_masked, | |
cdc7bbd5 | 507 | doc_notable_trait, |
3dfed10e | 508 | doc_spotlight, |
416331ca | 509 | doctest, |
48663c56 | 510 | document_private_items, |
48663c56 | 511 | dotdot_in_tuple_patterns, |
3dfed10e | 512 | dotdoteq_in_patterns, |
fc512014 XL |
513 | dreg, |
514 | dreg_low16, | |
515 | dreg_low8, | |
3dfed10e XL |
516 | drop, |
517 | drop_in_place, | |
518 | drop_types_in_const, | |
48663c56 XL |
519 | dropck_eyepatch, |
520 | dropck_parametricity, | |
48663c56 | 521 | dylib, |
6a06907d | 522 | dyn_metadata, |
48663c56 | 523 | dyn_trait, |
5869c6ff | 524 | edition_macro_pats, |
3dfed10e | 525 | eh_catch_typeinfo, |
48663c56 | 526 | eh_personality, |
3dfed10e XL |
527 | emit_enum, |
528 | emit_enum_variant, | |
529 | emit_enum_variant_arg, | |
530 | emit_struct, | |
531 | emit_struct_field, | |
48663c56 | 532 | enable, |
3dfed10e XL |
533 | enclosing_scope, |
534 | encode, | |
416331ca | 535 | env, |
dc9dc135 | 536 | eq, |
29967ef6 | 537 | ermsb_target_feature, |
f035d41b | 538 | exact_div, |
48663c56 | 539 | except, |
3dfed10e | 540 | exchange_malloc, |
48663c56 XL |
541 | exclusive_range_pattern, |
542 | exhaustive_integer_patterns, | |
543 | exhaustive_patterns, | |
544 | existential_type, | |
f035d41b XL |
545 | exp2f32, |
546 | exp2f64, | |
29967ef6 | 547 | expect, |
48663c56 | 548 | expected, |
3dfed10e XL |
549 | expf32, |
550 | expf64, | |
48663c56 | 551 | export_name, |
dc9dc135 | 552 | expr, |
fc512014 | 553 | extended_key_value_attributes, |
48663c56 | 554 | extern_absolute_paths, |
48663c56 XL |
555 | extern_crate_item_prelude, |
556 | extern_crate_self, | |
557 | extern_in_paths, | |
558 | extern_prelude, | |
559 | extern_types, | |
3dfed10e XL |
560 | external_doc, |
561 | f, | |
48663c56 | 562 | f16c_target_feature, |
dc9dc135 | 563 | f32, |
3dfed10e | 564 | f32_runtime, |
dc9dc135 | 565 | f64, |
3dfed10e | 566 | f64_runtime, |
f035d41b XL |
567 | fabsf32, |
568 | fabsf64, | |
3dfed10e | 569 | fadd_fast, |
f035d41b | 570 | fdiv_fast, |
48663c56 | 571 | feature, |
29967ef6 | 572 | ffi, |
f9f354fc XL |
573 | ffi_const, |
574 | ffi_pure, | |
48663c56 | 575 | ffi_returns_twice, |
dc9dc135 | 576 | field, |
48663c56 XL |
577 | field_init_shorthand, |
578 | file, | |
3dfed10e XL |
579 | fill, |
580 | finish, | |
581 | flags, | |
f035d41b | 582 | float_to_int_unchecked, |
f035d41b | 583 | floorf32, |
3dfed10e | 584 | floorf64, |
f035d41b XL |
585 | fmaf32, |
586 | fmaf64, | |
dc9dc135 XL |
587 | fmt, |
588 | fmt_internals, | |
f035d41b | 589 | fmul_fast, |
136023e0 | 590 | fn_align, |
48663c56 | 591 | fn_must_use, |
3dfed10e XL |
592 | fn_mut, |
593 | fn_once, | |
594 | fn_once_output, | |
48663c56 | 595 | forbid, |
f035d41b | 596 | forget, |
3dfed10e | 597 | format, |
416331ca | 598 | format_args, |
f035d41b | 599 | format_args_capture, |
3dfed10e | 600 | format_args_nl, |
6a06907d | 601 | format_macro, |
3dfed10e | 602 | freeze, |
fc512014 | 603 | freg, |
f035d41b | 604 | frem_fast, |
48663c56 | 605 | from, |
dc9dc135 | 606 | from_desugaring, |
48663c56 | 607 | from_generator, |
136023e0 | 608 | from_iter, |
dc9dc135 | 609 | from_method, |
17df50a5 XL |
610 | from_output, |
611 | from_residual, | |
3dfed10e | 612 | from_size_align_unchecked, |
f035d41b | 613 | from_trait, |
3dfed10e | 614 | from_usize, |
f035d41b | 615 | fsub_fast, |
48663c56 XL |
616 | fundamental, |
617 | future, | |
3dfed10e XL |
618 | future_trait, |
619 | ge, | |
48663c56 | 620 | gen_future, |
dfeec247 | 621 | gen_kill, |
3dfed10e XL |
622 | generator, |
623 | generator_state, | |
48663c56 XL |
624 | generators, |
625 | generic_associated_types, | |
626 | generic_param_attrs, | |
ba9703b0 | 627 | get_context, |
48663c56 XL |
628 | global_allocator, |
629 | global_asm, | |
630 | globs, | |
3dfed10e | 631 | gt, |
dfeec247 | 632 | half_open_range_patterns, |
dc9dc135 | 633 | hash, |
6a06907d XL |
634 | hashmap_type, |
635 | hashset_type, | |
48663c56 XL |
636 | hexagon_target_feature, |
637 | hidden, | |
638 | homogeneous_aggregate, | |
639 | html_favicon_url, | |
640 | html_logo_url, | |
641 | html_no_source, | |
642 | html_playground_url, | |
643 | html_root_url, | |
6a06907d | 644 | hwaddress, |
3dfed10e | 645 | i, |
48663c56 XL |
646 | i128, |
647 | i128_type, | |
648 | i16, | |
649 | i32, | |
650 | i64, | |
651 | i8, | |
652 | ident, | |
653 | if_let, | |
3dfed10e | 654 | if_let_guard, |
48663c56 XL |
655 | if_while_or_patterns, |
656 | ignore, | |
657 | impl_header_lifetime_elision, | |
416331ca | 658 | impl_lint_pass, |
3dfed10e | 659 | impl_macros, |
48663c56 XL |
660 | impl_trait_in_bindings, |
661 | import_shadowing, | |
cdc7bbd5 | 662 | imported_main, |
48663c56 XL |
663 | in_band_lifetimes, |
664 | include, | |
416331ca XL |
665 | include_bytes, |
666 | include_str, | |
48663c56 | 667 | inclusive_range_syntax, |
3dfed10e XL |
668 | index, |
669 | index_mut, | |
48663c56 XL |
670 | infer_outlives_requirements, |
671 | infer_static_outlives_requirements, | |
6a06907d | 672 | inherent_associated_types, |
3dfed10e | 673 | inlateout, |
48663c56 | 674 | inline, |
29967ef6 | 675 | inline_const, |
3dfed10e | 676 | inout, |
29967ef6 | 677 | instruction_set, |
48663c56 XL |
678 | intel, |
679 | into_iter, | |
5869c6ff XL |
680 | into_trait, |
681 | intra_doc_pointers, | |
48663c56 XL |
682 | intrinsics, |
683 | irrefutable_let_patterns, | |
29967ef6 | 684 | isa_attribute, |
48663c56 XL |
685 | isize, |
686 | issue, | |
687 | issue_5723_bootstrap, | |
688 | issue_tracker_base_url, | |
dc9dc135 | 689 | item, |
48663c56 XL |
690 | item_like_imports, |
691 | iter, | |
136023e0 | 692 | iter_repeat, |
48663c56 XL |
693 | keyword, |
694 | kind, | |
fc512014 | 695 | kreg, |
48663c56 XL |
696 | label, |
697 | label_break_value, | |
698 | lang, | |
699 | lang_items, | |
cdc7bbd5 | 700 | large_assignments, |
f9f354fc | 701 | lateout, |
3dfed10e XL |
702 | lazy_normalization_consts, |
703 | le, | |
136023e0 | 704 | len, |
dc9dc135 XL |
705 | let_chains, |
706 | lhs, | |
48663c56 | 707 | lib, |
3dfed10e | 708 | libc, |
dc9dc135 | 709 | lifetime, |
f035d41b | 710 | likely, |
416331ca | 711 | line, |
48663c56 | 712 | link, |
48663c56 XL |
713 | link_args, |
714 | link_cfg, | |
715 | link_llvm_intrinsics, | |
716 | link_name, | |
e74abb32 | 717 | link_ordinal, |
48663c56 | 718 | link_section, |
3dfed10e | 719 | linkage, |
48663c56 | 720 | lint_reasons, |
dc9dc135 | 721 | literal, |
ba9703b0 | 722 | llvm_asm, |
fc512014 | 723 | local, |
48663c56 | 724 | local_inner_macros, |
f035d41b XL |
725 | log10f32, |
726 | log10f64, | |
727 | log2f32, | |
728 | log2f64, | |
3dfed10e XL |
729 | log_syntax, |
730 | logf32, | |
731 | logf64, | |
48663c56 | 732 | loop_break_value, |
3dfed10e | 733 | lt, |
48663c56 | 734 | macro_at_most_once_rep, |
6a06907d | 735 | macro_attributes_in_derive_output, |
48663c56 XL |
736 | macro_escape, |
737 | macro_export, | |
738 | macro_lifetime_matcher, | |
739 | macro_literal_matcher, | |
740 | macro_reexport, | |
48663c56 XL |
741 | macro_use, |
742 | macro_vis_matcher, | |
3dfed10e | 743 | macros_in_extern, |
48663c56 XL |
744 | main, |
745 | managed_boxes, | |
3dfed10e XL |
746 | manually_drop, |
747 | map, | |
48663c56 XL |
748 | marker, |
749 | marker_trait_attr, | |
750 | masked, | |
751 | match_beginning_vert, | |
752 | match_default_bindings, | |
3dfed10e XL |
753 | maxnumf32, |
754 | maxnumf64, | |
48663c56 | 755 | may_dangle, |
3dfed10e | 756 | maybe_uninit, |
60c5eb7d XL |
757 | maybe_uninit_uninit, |
758 | maybe_uninit_zeroed, | |
136023e0 XL |
759 | mem_discriminant, |
760 | mem_drop, | |
761 | mem_forget, | |
762 | mem_replace, | |
763 | mem_size_of, | |
764 | mem_size_of_val, | |
60c5eb7d XL |
765 | mem_uninitialized, |
766 | mem_zeroed, | |
dc9dc135 | 767 | member_constraints, |
74b04a01 | 768 | memory, |
48663c56 XL |
769 | message, |
770 | meta, | |
6a06907d | 771 | metadata_type, |
60c5eb7d | 772 | min_align_of, |
f035d41b | 773 | min_align_of_val, |
48663c56 | 774 | min_const_fn, |
3dfed10e | 775 | min_const_generics, |
48663c56 | 776 | min_const_unsafe_fn, |
ba9703b0 | 777 | min_specialization, |
6a06907d | 778 | min_type_alias_impl_trait, |
f035d41b XL |
779 | minnumf32, |
780 | minnumf64, | |
48663c56 | 781 | mips_target_feature, |
1b1a35ee | 782 | misc, |
136023e0 | 783 | mmx_reg, |
17df50a5 | 784 | modifiers, |
48663c56 | 785 | module, |
416331ca | 786 | module_path, |
17df50a5 | 787 | more_qualified_paths, |
48663c56 | 788 | more_struct_aliases, |
3dfed10e | 789 | movbe_target_feature, |
74b04a01 | 790 | move_ref_pattern, |
cdc7bbd5 | 791 | move_size_limit, |
3dfed10e XL |
792 | mul, |
793 | mul_assign, | |
60c5eb7d | 794 | mul_with_overflow, |
48663c56 | 795 | must_use, |
3dfed10e XL |
796 | mut_ptr, |
797 | mut_slice_ptr, | |
48663c56 XL |
798 | naked, |
799 | naked_functions, | |
800 | name, | |
17df50a5 XL |
801 | native_link_modifiers, |
802 | native_link_modifiers_as_needed, | |
803 | native_link_modifiers_bundle, | |
804 | native_link_modifiers_verbatim, | |
805 | native_link_modifiers_whole_archive, | |
3dfed10e | 806 | ne, |
f035d41b XL |
807 | nearbyintf32, |
808 | nearbyintf64, | |
48663c56 | 809 | needs_allocator, |
60c5eb7d | 810 | needs_drop, |
48663c56 | 811 | needs_panic_runtime, |
3dfed10e | 812 | neg, |
48663c56 | 813 | negate_unsigned, |
ba9703b0 | 814 | negative_impls, |
48663c56 XL |
815 | never, |
816 | never_type, | |
60c5eb7d | 817 | never_type_fallback, |
dc9dc135 | 818 | new, |
3dfed10e | 819 | new_unchecked, |
48663c56 | 820 | next, |
48663c56 | 821 | nll, |
3dfed10e | 822 | no, |
48663c56 XL |
823 | no_builtins, |
824 | no_core, | |
cdc7bbd5 | 825 | no_coverage, |
48663c56 XL |
826 | no_crate_inject, |
827 | no_debug, | |
828 | no_default_passes, | |
829 | no_implicit_prelude, | |
830 | no_inline, | |
831 | no_link, | |
832 | no_main, | |
833 | no_mangle, | |
3dfed10e XL |
834 | no_niche, |
835 | no_sanitize, | |
836 | no_stack_check, | |
837 | no_start, | |
838 | no_std, | |
f9f354fc | 839 | nomem, |
48663c56 | 840 | non_ascii_idents, |
48663c56 XL |
841 | non_exhaustive, |
842 | non_modrs_mods, | |
3dfed10e | 843 | none_error, |
f035d41b | 844 | nontemporal_store, |
6a06907d XL |
845 | noop_method_borrow, |
846 | noop_method_clone, | |
847 | noop_method_deref, | |
f9f354fc | 848 | noreturn, |
f9f354fc | 849 | nostack, |
48663c56 | 850 | not, |
cdc7bbd5 | 851 | notable_trait, |
48663c56 | 852 | note, |
e74abb32 | 853 | object_safe_for_dispatch, |
3dfed10e | 854 | of, |
f9f354fc | 855 | offset, |
48663c56 XL |
856 | omit_gdb_pretty_printer_section, |
857 | on, | |
858 | on_unimplemented, | |
859 | oom, | |
3dfed10e | 860 | opaque, |
48663c56 | 861 | ops, |
3dfed10e | 862 | opt_out_copy, |
48663c56 XL |
863 | optimize, |
864 | optimize_attribute, | |
865 | optin_builtin_traits, | |
866 | option, | |
416331ca | 867 | option_env, |
3dfed10e | 868 | option_type, |
f9f354fc | 869 | options, |
dc9dc135 | 870 | or, |
e1599b0c | 871 | or_patterns, |
3dfed10e | 872 | other, |
f9f354fc | 873 | out, |
48663c56 | 874 | overlapping_marker_traits, |
3dfed10e | 875 | owned_box, |
48663c56 | 876 | packed, |
dc9dc135 | 877 | panic, |
5869c6ff XL |
878 | panic_2015, |
879 | panic_2021, | |
3dfed10e XL |
880 | panic_abort, |
881 | panic_bounds_check, | |
48663c56 XL |
882 | panic_handler, |
883 | panic_impl, | |
884 | panic_implementation, | |
3dfed10e XL |
885 | panic_info, |
886 | panic_location, | |
48663c56 | 887 | panic_runtime, |
29967ef6 | 888 | panic_str, |
3dfed10e | 889 | panic_unwind, |
fc512014 | 890 | panicking, |
3dfed10e | 891 | param_attrs, |
dc9dc135 XL |
892 | parent_trait, |
893 | partial_cmp, | |
3dfed10e | 894 | partial_ord, |
48663c56 | 895 | passes, |
dc9dc135 | 896 | pat, |
cdc7bbd5 | 897 | pat_param, |
48663c56 XL |
898 | path, |
899 | pattern_parentheses, | |
3dfed10e | 900 | phantom_data, |
48663c56 | 901 | pin, |
48663c56 XL |
902 | pinned, |
903 | platform_intrinsics, | |
904 | plugin, | |
905 | plugin_registrar, | |
906 | plugins, | |
6a06907d | 907 | pointee_trait, |
3dfed10e | 908 | pointer, |
29967ef6 XL |
909 | pointer_trait, |
910 | pointer_trait_fmt, | |
ba9703b0 | 911 | poll, |
3dfed10e XL |
912 | position, |
913 | post_dash_lto: "post-lto", | |
48663c56 | 914 | powerpc_target_feature, |
f035d41b XL |
915 | powf32, |
916 | powf64, | |
917 | powif32, | |
918 | powif64, | |
3dfed10e | 919 | pre_dash_lto: "pre-lto", |
48663c56 | 920 | precise_pointer_size_matching, |
3dfed10e | 921 | precision, |
60c5eb7d | 922 | pref_align_of, |
f035d41b XL |
923 | prefetch_read_data, |
924 | prefetch_read_instruction, | |
925 | prefetch_write_data, | |
926 | prefetch_write_instruction, | |
136023e0 | 927 | preg, |
48663c56 XL |
928 | prelude, |
929 | prelude_import, | |
f9f354fc | 930 | preserves_flags, |
48663c56 XL |
931 | primitive, |
932 | proc_dash_macro: "proc-macro", | |
933 | proc_macro, | |
934 | proc_macro_attribute, | |
dc9dc135 | 935 | proc_macro_def_site, |
48663c56 XL |
936 | proc_macro_derive, |
937 | proc_macro_expr, | |
938 | proc_macro_gen, | |
939 | proc_macro_hygiene, | |
416331ca | 940 | proc_macro_internals, |
48663c56 XL |
941 | proc_macro_mod, |
942 | proc_macro_non_items, | |
943 | proc_macro_path_invoc, | |
f035d41b | 944 | profiler_builtins, |
48663c56 | 945 | profiler_runtime, |
f035d41b XL |
946 | ptr_guaranteed_eq, |
947 | ptr_guaranteed_ne, | |
cdc7bbd5 XL |
948 | ptr_null, |
949 | ptr_null_mut, | |
60c5eb7d | 950 | ptr_offset_from, |
6a06907d | 951 | pub_macro_rules, |
48663c56 | 952 | pub_restricted, |
f9f354fc | 953 | pure, |
48663c56 | 954 | pushpop_unsafe, |
fc512014 XL |
955 | qreg, |
956 | qreg_low4, | |
957 | qreg_low8, | |
48663c56 XL |
958 | quad_precision_float, |
959 | question_mark, | |
960 | quote, | |
3dfed10e | 961 | range_inclusive_new, |
e74abb32 | 962 | raw_dylib, |
136023e0 | 963 | raw_eq, |
48663c56 | 964 | raw_identifiers, |
60c5eb7d | 965 | raw_ref_op, |
3dfed10e XL |
966 | re_rebalance_coherence, |
967 | read_enum, | |
968 | read_enum_variant, | |
969 | read_enum_variant_arg, | |
970 | read_struct, | |
971 | read_struct_field, | |
f9f354fc | 972 | readonly, |
3dfed10e | 973 | realloc, |
48663c56 | 974 | reason, |
3dfed10e | 975 | receiver, |
48663c56 XL |
976 | recursion_limit, |
977 | reexport_test_harness_main, | |
136023e0 | 978 | ref_unwind_safe_trait, |
3dfed10e | 979 | reference, |
48663c56 | 980 | reflect, |
fc512014 XL |
981 | reg, |
982 | reg16, | |
983 | reg32, | |
984 | reg64, | |
985 | reg_abcd, | |
986 | reg_byte, | |
17df50a5 | 987 | reg_nonzero, |
fc512014 | 988 | reg_thumb, |
60c5eb7d XL |
989 | register_attr, |
990 | register_tool, | |
48663c56 | 991 | relaxed_adts, |
5869c6ff | 992 | relaxed_struct_unsize, |
3dfed10e XL |
993 | rem, |
994 | rem_assign, | |
48663c56 XL |
995 | repr, |
996 | repr128, | |
997 | repr_align, | |
998 | repr_align_enum, | |
74b04a01 | 999 | repr_no_niche, |
48663c56 XL |
1000 | repr_packed, |
1001 | repr_simd, | |
1002 | repr_transparent, | |
17df50a5 | 1003 | residual, |
48663c56 | 1004 | result, |
3dfed10e | 1005 | result_type, |
dc9dc135 | 1006 | rhs, |
f035d41b XL |
1007 | rintf32, |
1008 | rintf64, | |
f9f354fc | 1009 | riscv_target_feature, |
48663c56 | 1010 | rlib, |
60c5eb7d XL |
1011 | rotate_left, |
1012 | rotate_right, | |
f035d41b XL |
1013 | roundf32, |
1014 | roundf64, | |
dc9dc135 | 1015 | rt, |
48663c56 XL |
1016 | rtm_target_feature, |
1017 | rust, | |
6a06907d | 1018 | rust_2015, |
48663c56 | 1019 | rust_2015_preview, |
6a06907d | 1020 | rust_2018, |
48663c56 | 1021 | rust_2018_preview, |
6a06907d | 1022 | rust_2021, |
5869c6ff | 1023 | rust_2021_preview, |
48663c56 | 1024 | rust_begin_unwind, |
1b1a35ee | 1025 | rust_eh_catch_typeinfo, |
3dfed10e XL |
1026 | rust_eh_personality, |
1027 | rust_eh_register_frames, | |
1028 | rust_eh_unregister_frames, | |
1029 | rust_oom, | |
dc9dc135 XL |
1030 | rustc, |
1031 | rustc_allocator, | |
48663c56 | 1032 | rustc_allocator_nounwind, |
29967ef6 | 1033 | rustc_allow_const_fn_unstable, |
48663c56 | 1034 | rustc_attrs, |
416331ca | 1035 | rustc_builtin_macro, |
fc512014 | 1036 | rustc_capture_analysis, |
48663c56 | 1037 | rustc_clean, |
60c5eb7d | 1038 | rustc_const_stable, |
3dfed10e | 1039 | rustc_const_unstable, |
48663c56 | 1040 | rustc_conversion_suggestion, |
48663c56 XL |
1041 | rustc_def_path, |
1042 | rustc_deprecated, | |
e1599b0c | 1043 | rustc_diagnostic_item, |
48663c56 XL |
1044 | rustc_diagnostic_macros, |
1045 | rustc_dirty, | |
dc9dc135 | 1046 | rustc_dummy, |
48663c56 XL |
1047 | rustc_dump_env_program_clauses, |
1048 | rustc_dump_program_clauses, | |
1049 | rustc_dump_user_substs, | |
1050 | rustc_error, | |
17df50a5 | 1051 | rustc_evaluate_where_clauses, |
48663c56 XL |
1052 | rustc_expected_cgu_reuse, |
1053 | rustc_if_this_changed, | |
1054 | rustc_inherit_overflow_checks, | |
17df50a5 | 1055 | rustc_insignificant_dtor, |
48663c56 XL |
1056 | rustc_layout, |
1057 | rustc_layout_scalar_valid_range_end, | |
1058 | rustc_layout_scalar_valid_range_start, | |
6a06907d | 1059 | rustc_legacy_const_generics, |
416331ca | 1060 | rustc_macro_transparency, |
cdc7bbd5 | 1061 | rustc_main, |
48663c56 | 1062 | rustc_mir, |
dc9dc135 | 1063 | rustc_nonnull_optimization_guaranteed, |
48663c56 XL |
1064 | rustc_object_lifetime_default, |
1065 | rustc_on_unimplemented, | |
1066 | rustc_outlives, | |
1067 | rustc_paren_sugar, | |
1068 | rustc_partition_codegened, | |
1069 | rustc_partition_reused, | |
1070 | rustc_peek, | |
1071 | rustc_peek_definite_init, | |
3dfed10e | 1072 | rustc_peek_indirectly_mutable, |
f9f354fc | 1073 | rustc_peek_liveness, |
48663c56 XL |
1074 | rustc_peek_maybe_init, |
1075 | rustc_peek_maybe_uninit, | |
3dfed10e | 1076 | rustc_polymorphize_error, |
48663c56 XL |
1077 | rustc_private, |
1078 | rustc_proc_macro_decls, | |
1079 | rustc_promotable, | |
1080 | rustc_regions, | |
3dfed10e XL |
1081 | rustc_reservation_impl, |
1082 | rustc_serialize, | |
cdc7bbd5 | 1083 | rustc_skip_array_during_method_dispatch, |
ba9703b0 | 1084 | rustc_specialization_trait, |
48663c56 XL |
1085 | rustc_stable, |
1086 | rustc_std_internal_symbol, | |
1087 | rustc_symbol_name, | |
1088 | rustc_synthetic, | |
1089 | rustc_test_marker, | |
1090 | rustc_then_this_would_need, | |
3dfed10e | 1091 | rustc_unsafe_specialization_marker, |
48663c56 | 1092 | rustc_variance, |
6a06907d | 1093 | rustdoc, |
416331ca | 1094 | rustfmt, |
48663c56 | 1095 | rvalue_static_promotion, |
136023e0 | 1096 | s, |
60c5eb7d | 1097 | sanitize, |
48663c56 | 1098 | sanitizer_runtime, |
60c5eb7d XL |
1099 | saturating_add, |
1100 | saturating_sub, | |
48663c56 XL |
1101 | self_in_typedefs, |
1102 | self_struct_ctor, | |
3dfed10e | 1103 | semitransparent, |
60c5eb7d | 1104 | send_trait, |
3dfed10e XL |
1105 | shl, |
1106 | shl_assign, | |
48663c56 | 1107 | should_panic, |
3dfed10e XL |
1108 | shr, |
1109 | shr_assign, | |
48663c56 | 1110 | simd, |
3dfed10e XL |
1111 | simd_add, |
1112 | simd_and, | |
1113 | simd_bitmask, | |
1114 | simd_cast, | |
1115 | simd_ceil, | |
1116 | simd_div, | |
1117 | simd_eq, | |
60c5eb7d | 1118 | simd_extract, |
3dfed10e XL |
1119 | simd_fabs, |
1120 | simd_fcos, | |
1121 | simd_fexp, | |
1122 | simd_fexp2, | |
48663c56 | 1123 | simd_ffi, |
3dfed10e XL |
1124 | simd_flog, |
1125 | simd_flog10, | |
1126 | simd_flog2, | |
1127 | simd_floor, | |
1128 | simd_fma, | |
1129 | simd_fmax, | |
1130 | simd_fmin, | |
1131 | simd_fpow, | |
1132 | simd_fpowi, | |
1133 | simd_fsin, | |
1134 | simd_fsqrt, | |
1135 | simd_gather, | |
1136 | simd_ge, | |
1137 | simd_gt, | |
60c5eb7d | 1138 | simd_insert, |
3dfed10e XL |
1139 | simd_le, |
1140 | simd_lt, | |
1141 | simd_mul, | |
1142 | simd_ne, | |
6a06907d | 1143 | simd_neg, |
3dfed10e XL |
1144 | simd_or, |
1145 | simd_reduce_add_ordered, | |
1146 | simd_reduce_add_unordered, | |
1147 | simd_reduce_all, | |
1148 | simd_reduce_and, | |
1149 | simd_reduce_any, | |
1150 | simd_reduce_max, | |
1151 | simd_reduce_max_nanless, | |
1152 | simd_reduce_min, | |
1153 | simd_reduce_min_nanless, | |
1154 | simd_reduce_mul_ordered, | |
1155 | simd_reduce_mul_unordered, | |
1156 | simd_reduce_or, | |
1157 | simd_reduce_xor, | |
1158 | simd_rem, | |
cdc7bbd5 | 1159 | simd_round, |
3dfed10e XL |
1160 | simd_saturating_add, |
1161 | simd_saturating_sub, | |
1162 | simd_scatter, | |
1163 | simd_select, | |
1164 | simd_select_bitmask, | |
1165 | simd_shl, | |
1166 | simd_shr, | |
1167 | simd_sub, | |
cdc7bbd5 | 1168 | simd_trunc, |
3dfed10e | 1169 | simd_xor, |
48663c56 | 1170 | since, |
f035d41b XL |
1171 | sinf32, |
1172 | sinf64, | |
48663c56 | 1173 | size, |
60c5eb7d | 1174 | size_of, |
f035d41b | 1175 | size_of_val, |
3dfed10e | 1176 | sized, |
6a06907d | 1177 | skip, |
3dfed10e XL |
1178 | slice, |
1179 | slice_alloc, | |
136023e0 | 1180 | slice_len_fn, |
48663c56 | 1181 | slice_patterns, |
3dfed10e XL |
1182 | slice_u8, |
1183 | slice_u8_alloc, | |
48663c56 | 1184 | slicing_syntax, |
416331ca | 1185 | soft, |
48663c56 XL |
1186 | specialization, |
1187 | speed, | |
3dfed10e | 1188 | spotlight, |
f035d41b XL |
1189 | sqrtf32, |
1190 | sqrtf64, | |
fc512014 XL |
1191 | sreg, |
1192 | sreg_low16, | |
48663c56 XL |
1193 | sse4a_target_feature, |
1194 | stable, | |
1195 | staged_api, | |
1196 | start, | |
3dfed10e | 1197 | state, |
48663c56 | 1198 | static_in_const, |
48663c56 XL |
1199 | static_nobundle, |
1200 | static_recursion, | |
3dfed10e | 1201 | staticlib, |
48663c56 | 1202 | std, |
416331ca | 1203 | std_inject, |
5869c6ff XL |
1204 | std_panic, |
1205 | std_panic_2015_macro, | |
fc512014 | 1206 | std_panic_macro, |
dc9dc135 | 1207 | stmt, |
48663c56 XL |
1208 | stmt_expr_attributes, |
1209 | stop_after_dataflow, | |
3dfed10e XL |
1210 | str, |
1211 | str_alloc, | |
1212 | string_type, | |
1213 | stringify, | |
48663c56 XL |
1214 | struct_field_attributes, |
1215 | struct_inherit, | |
48663c56 | 1216 | struct_variant, |
3dfed10e XL |
1217 | structural_match, |
1218 | structural_peq, | |
1219 | structural_teq, | |
dc9dc135 | 1220 | sty, |
3dfed10e XL |
1221 | sub, |
1222 | sub_assign, | |
60c5eb7d | 1223 | sub_with_overflow, |
48663c56 | 1224 | suggestion, |
f9f354fc | 1225 | sym, |
3dfed10e | 1226 | sync, |
60c5eb7d | 1227 | sync_trait, |
29967ef6 | 1228 | t32, |
136023e0 | 1229 | target_abi, |
3dfed10e XL |
1230 | target_arch, |
1231 | target_endian, | |
1232 | target_env, | |
1233 | target_family, | |
48663c56 | 1234 | target_feature, |
f9f354fc | 1235 | target_feature_11, |
48663c56 | 1236 | target_has_atomic, |
1b1a35ee | 1237 | target_has_atomic_equal_alignment, |
e74abb32 | 1238 | target_has_atomic_load_store, |
3dfed10e XL |
1239 | target_os, |
1240 | target_pointer_width, | |
1241 | target_target_vendor, | |
48663c56 | 1242 | target_thread_local, |
3dfed10e | 1243 | target_vendor, |
48663c56 XL |
1244 | task, |
1245 | tbm_target_feature, | |
3dfed10e | 1246 | termination, |
48663c56 XL |
1247 | termination_trait, |
1248 | termination_trait_test, | |
1249 | test, | |
1250 | test_2018_feature, | |
1251 | test_accepted_feature, | |
dc9dc135 | 1252 | test_case, |
48663c56 XL |
1253 | test_removed_feature, |
1254 | test_runner, | |
dc9dc135 | 1255 | then_with, |
74b04a01 | 1256 | thread, |
48663c56 XL |
1257 | thread_local, |
1258 | tool_attributes, | |
1259 | tool_lints, | |
1260 | trace_macros, | |
e74abb32 | 1261 | track_caller, |
48663c56 XL |
1262 | trait_alias, |
1263 | transmute, | |
1264 | transparent, | |
dc9dc135 XL |
1265 | transparent_enums, |
1266 | transparent_unions, | |
48663c56 | 1267 | trivial_bounds, |
f035d41b XL |
1268 | truncf32, |
1269 | truncf64, | |
48663c56 | 1270 | try_blocks, |
136023e0 | 1271 | try_from, |
5869c6ff | 1272 | try_from_trait, |
136023e0 | 1273 | try_into, |
5869c6ff | 1274 | try_into_trait, |
17df50a5 | 1275 | try_trait_v2, |
dc9dc135 | 1276 | tt, |
3dfed10e | 1277 | tuple, |
29967ef6 | 1278 | tuple_from_req, |
48663c56 | 1279 | tuple_indexing, |
dfeec247 | 1280 | two_phase, |
48663c56 XL |
1281 | ty, |
1282 | type_alias_enum_variants, | |
3dfed10e | 1283 | type_alias_impl_trait, |
48663c56 | 1284 | type_ascription, |
3dfed10e | 1285 | type_id, |
48663c56 XL |
1286 | type_length_limit, |
1287 | type_macros, | |
3dfed10e | 1288 | type_name, |
48663c56 XL |
1289 | u128, |
1290 | u16, | |
1291 | u32, | |
1292 | u64, | |
1293 | u8, | |
f035d41b XL |
1294 | unaligned_volatile_load, |
1295 | unaligned_volatile_store, | |
48663c56 | 1296 | unboxed_closures, |
74b04a01 XL |
1297 | unchecked_add, |
1298 | unchecked_div, | |
1299 | unchecked_mul, | |
1300 | unchecked_rem, | |
60c5eb7d XL |
1301 | unchecked_shl, |
1302 | unchecked_shr, | |
74b04a01 | 1303 | unchecked_sub, |
48663c56 XL |
1304 | underscore_const_names, |
1305 | underscore_imports, | |
1306 | underscore_lifetimes, | |
1307 | uniform_paths, | |
3dfed10e | 1308 | unit, |
48663c56 | 1309 | universal_impl_trait, |
3dfed10e | 1310 | unix, |
f035d41b | 1311 | unlikely, |
48663c56 | 1312 | unmarked_api, |
17df50a5 | 1313 | unnamed_fields, |
3dfed10e | 1314 | unpin, |
f035d41b | 1315 | unreachable, |
48663c56 XL |
1316 | unreachable_code, |
1317 | unrestricted_attribute_tokens, | |
f9f354fc | 1318 | unsafe_block_in_unsafe_fn, |
3dfed10e | 1319 | unsafe_cell, |
48663c56 | 1320 | unsafe_no_drop_flag, |
3dfed10e | 1321 | unsize, |
29967ef6 | 1322 | unsized_fn_params, |
48663c56 XL |
1323 | unsized_locals, |
1324 | unsized_tuple_coercion, | |
1325 | unstable, | |
1326 | untagged_unions, | |
3dfed10e | 1327 | unused_qualifications, |
48663c56 XL |
1328 | unwind, |
1329 | unwind_attributes, | |
136023e0 | 1330 | unwind_safe_trait, |
29967ef6 | 1331 | unwrap, |
dc9dc135 | 1332 | unwrap_or, |
48663c56 XL |
1333 | use_extern_macros, |
1334 | use_nested_groups, | |
3dfed10e | 1335 | used, |
48663c56 XL |
1336 | usize, |
1337 | v1, | |
f035d41b XL |
1338 | va_arg, |
1339 | va_copy, | |
1340 | va_end, | |
3dfed10e | 1341 | va_list, |
f035d41b | 1342 | va_start, |
3dfed10e XL |
1343 | val, |
1344 | var, | |
1345 | variant_count, | |
dc9dc135 | 1346 | vec, |
3dfed10e | 1347 | vec_type, |
6a06907d | 1348 | vecdeque_type, |
f9f354fc | 1349 | version, |
48663c56 XL |
1350 | vis, |
1351 | visible_private_types, | |
1352 | volatile, | |
f035d41b XL |
1353 | volatile_copy_memory, |
1354 | volatile_copy_nonoverlapping_memory, | |
1355 | volatile_load, | |
1356 | volatile_set_memory, | |
1357 | volatile_store, | |
fc512014 XL |
1358 | vreg, |
1359 | vreg_low16, | |
48663c56 | 1360 | warn, |
cdc7bbd5 | 1361 | wasm_abi, |
48663c56 XL |
1362 | wasm_import_module, |
1363 | wasm_target_feature, | |
1364 | while_let, | |
3dfed10e | 1365 | width, |
48663c56 XL |
1366 | windows, |
1367 | windows_subsystem, | |
60c5eb7d | 1368 | wrapping_add, |
60c5eb7d | 1369 | wrapping_mul, |
3dfed10e | 1370 | wrapping_sub, |
17df50a5 | 1371 | wreg, |
f035d41b | 1372 | write_bytes, |
136023e0 | 1373 | x87_reg, |
fc512014 XL |
1374 | xmm_reg, |
1375 | ymm_reg, | |
1376 | zmm_reg, | |
48663c56 XL |
1377 | } |
1378 | } | |
1379 | ||
3dfed10e | 1380 | #[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)] |
cc61c64b XL |
1381 | pub struct Ident { |
1382 | pub name: Symbol, | |
83c7162d | 1383 | pub span: Span, |
cc61c64b XL |
1384 | } |
1385 | ||
1386 | impl Ident { | |
83c7162d | 1387 | #[inline] |
dc9dc135 | 1388 | /// Constructs a new identifier from a symbol and a span. |
83c7162d XL |
1389 | pub const fn new(name: Symbol, span: Span) -> Ident { |
1390 | Ident { name, span } | |
1391 | } | |
0731742a | 1392 | |
e1599b0c | 1393 | /// Constructs a new identifier with a dummy span. |
83c7162d | 1394 | #[inline] |
e1599b0c | 1395 | pub const fn with_dummy_span(name: Symbol) -> Ident { |
83c7162d XL |
1396 | Ident::new(name, DUMMY_SP) |
1397 | } | |
1398 | ||
dc9dc135 XL |
1399 | #[inline] |
1400 | pub fn invalid() -> Ident { | |
5869c6ff | 1401 | Ident::with_dummy_span(kw::Empty) |
dc9dc135 XL |
1402 | } |
1403 | ||
e1599b0c | 1404 | /// Maps a string to an identifier with a dummy span. |
cc61c64b | 1405 | pub fn from_str(string: &str) -> Ident { |
e1599b0c | 1406 | Ident::with_dummy_span(Symbol::intern(string)) |
cc61c64b XL |
1407 | } |
1408 | ||
dc9dc135 XL |
1409 | /// Maps a string and a span to an identifier. |
1410 | pub fn from_str_and_span(string: &str, span: Span) -> Ident { | |
1411 | Ident::new(Symbol::intern(string), span) | |
1412 | } | |
1413 | ||
9fa01778 | 1414 | /// Replaces `lo` and `hi` with those from `span`, but keep hygiene context. |
83c7162d XL |
1415 | pub fn with_span_pos(self, span: Span) -> Ident { |
1416 | Ident::new(self.name, span.with_ctxt(self.span.ctxt())) | |
1417 | } | |
1418 | ||
1419 | pub fn without_first_quote(self) -> Ident { | |
0731742a | 1420 | Ident::new(Symbol::intern(self.as_str().trim_start_matches('\'')), self.span) |
ff7c6d11 XL |
1421 | } |
1422 | ||
8faf50e0 | 1423 | /// "Normalize" ident for use in comparisons using "item hygiene". |
ba9703b0 | 1424 | /// Identifiers with same string value become same if they came from the same macro 2.0 macro |
0731742a | 1425 | /// (e.g., `macro` item, but not `macro_rules` item) and stay different if they came from |
ba9703b0 | 1426 | /// different macro 2.0 macros. |
8faf50e0 | 1427 | /// Technically, this operation strips all non-opaque marks from ident's syntactic context. |
ba9703b0 XL |
1428 | pub fn normalize_to_macros_2_0(self) -> Ident { |
1429 | Ident::new(self.name, self.span.normalize_to_macros_2_0()) | |
83c7162d XL |
1430 | } |
1431 | ||
8faf50e0 XL |
1432 | /// "Normalize" ident for use in comparisons using "local variable hygiene". |
1433 | /// Identifiers with same string value become same if they came from the same non-transparent | |
0731742a | 1434 | /// macro (e.g., `macro` or `macro_rules!` items) and stay different if they came from different |
8faf50e0 XL |
1435 | /// non-transparent macros. |
1436 | /// Technically, this operation strips all transparent marks from ident's syntactic context. | |
ba9703b0 XL |
1437 | pub fn normalize_to_macro_rules(self) -> Ident { |
1438 | Ident::new(self.name, self.span.normalize_to_macro_rules()) | |
8faf50e0 XL |
1439 | } |
1440 | ||
60c5eb7d XL |
1441 | /// Convert the name to a `SymbolStr`. This is a slowish operation because |
1442 | /// it requires locking the symbol interner. | |
1443 | pub fn as_str(self) -> SymbolStr { | |
94b46f34 XL |
1444 | self.name.as_str() |
1445 | } | |
83c7162d XL |
1446 | } |
1447 | ||
1448 | impl PartialEq for Ident { | |
1449 | fn eq(&self, rhs: &Self) -> bool { | |
1450 | self.name == rhs.name && self.span.ctxt() == rhs.span.ctxt() | |
1451 | } | |
1452 | } | |
1453 | ||
1454 | impl Hash for Ident { | |
1455 | fn hash<H: Hasher>(&self, state: &mut H) { | |
1456 | self.name.hash(state); | |
1457 | self.span.ctxt().hash(state); | |
cc61c64b XL |
1458 | } |
1459 | } | |
1460 | ||
1461 | impl fmt::Debug for Ident { | |
9fa01778 | 1462 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
74b04a01 XL |
1463 | fmt::Display::fmt(self, f)?; |
1464 | fmt::Debug::fmt(&self.span.ctxt(), f) | |
cc61c64b XL |
1465 | } |
1466 | } | |
1467 | ||
74b04a01 XL |
1468 | /// This implementation is supposed to be used in error messages, so it's expected to be identical |
1469 | /// to printing the original identifier token written in source code (`token_to_string`), | |
1470 | /// except that AST identifiers don't keep the rawness flag, so we have to guess it. | |
cc61c64b | 1471 | impl fmt::Display for Ident { |
9fa01778 | 1472 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
74b04a01 | 1473 | fmt::Display::fmt(&IdentPrinter::new(self.name, self.is_raw_guess(), None), f) |
cc61c64b XL |
1474 | } |
1475 | } | |
1476 | ||
74b04a01 XL |
1477 | /// This is the most general way to print identifiers. |
1478 | /// AST pretty-printer is used as a fallback for turning AST structures into token streams for | |
1479 | /// proc macros. Additionally, proc macros may stringify their input and expect it survive the | |
1480 | /// stringification (especially true for proc macro derives written between Rust 1.15 and 1.30). | |
1481 | /// So we need to somehow pretty-print `$crate` in a way preserving at least some of its | |
1482 | /// hygiene data, most importantly name of the crate it refers to. | |
1483 | /// As a result we print `$crate` as `crate` if it refers to the local crate | |
1484 | /// and as `::other_crate_name` if it refers to some other crate. | |
1485 | /// Note, that this is only done if the ident token is printed from inside of AST pretty-pringing, | |
1486 | /// but not otherwise. Pretty-printing is the only way for proc macros to discover token contents, | |
1487 | /// so we should not perform this lossy conversion if the top level call to the pretty-printer was | |
1488 | /// done for a token stream or a single token. | |
1489 | pub struct IdentPrinter { | |
1490 | symbol: Symbol, | |
1491 | is_raw: bool, | |
1492 | /// Span used for retrieving the crate name to which `$crate` refers to, | |
1493 | /// if this field is `None` then the `$crate` conversion doesn't happen. | |
1494 | convert_dollar_crate: Option<Span>, | |
1495 | } | |
1496 | ||
1497 | impl IdentPrinter { | |
1498 | /// The most general `IdentPrinter` constructor. Do not use this. | |
1499 | pub fn new(symbol: Symbol, is_raw: bool, convert_dollar_crate: Option<Span>) -> IdentPrinter { | |
1500 | IdentPrinter { symbol, is_raw, convert_dollar_crate } | |
1501 | } | |
1502 | ||
1503 | /// This implementation is supposed to be used when printing identifiers | |
1504 | /// as a part of pretty-printing for larger AST pieces. | |
1505 | /// Do not use this either. | |
1506 | pub fn for_ast_ident(ident: Ident, is_raw: bool) -> IdentPrinter { | |
1507 | IdentPrinter::new(ident.name, is_raw, Some(ident.span)) | |
1508 | } | |
1509 | } | |
1510 | ||
1511 | impl fmt::Display for IdentPrinter { | |
1512 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
1513 | if self.is_raw { | |
1514 | f.write_str("r#")?; | |
fc512014 XL |
1515 | } else if self.symbol == kw::DollarCrate { |
1516 | if let Some(span) = self.convert_dollar_crate { | |
1517 | let converted = span.ctxt().dollar_crate_name(); | |
1518 | if !converted.is_path_segment_keyword() { | |
1519 | f.write_str("::")?; | |
74b04a01 | 1520 | } |
fc512014 | 1521 | return fmt::Display::fmt(&converted, f); |
74b04a01 XL |
1522 | } |
1523 | } | |
1524 | fmt::Display::fmt(&self.symbol, f) | |
1525 | } | |
1526 | } | |
1527 | ||
ba9703b0 XL |
1528 | /// An newtype around `Ident` that calls [Ident::normalize_to_macro_rules] on |
1529 | /// construction. | |
1530 | // FIXME(matthewj, petrochenkov) Use this more often, add a similar | |
1531 | // `ModernIdent` struct and use that as well. | |
1532 | #[derive(Copy, Clone, Eq, PartialEq, Hash)] | |
1533 | pub struct MacroRulesNormalizedIdent(Ident); | |
1534 | ||
1535 | impl MacroRulesNormalizedIdent { | |
1536 | pub fn new(ident: Ident) -> Self { | |
1537 | Self(ident.normalize_to_macro_rules()) | |
1538 | } | |
1539 | } | |
1540 | ||
1541 | impl fmt::Debug for MacroRulesNormalizedIdent { | |
1542 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
1543 | fmt::Debug::fmt(&self.0, f) | |
1544 | } | |
1545 | } | |
1546 | ||
1547 | impl fmt::Display for MacroRulesNormalizedIdent { | |
1548 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
1549 | fmt::Display::fmt(&self.0, f) | |
1550 | } | |
1551 | } | |
1552 | ||
e74abb32 | 1553 | /// An interned string. |
48663c56 | 1554 | /// |
e74abb32 | 1555 | /// Internally, a `Symbol` is implemented as an index, and all operations |
48663c56 | 1556 | /// (including hashing, equality, and ordering) operate on that index. The use |
e74abb32 XL |
1557 | /// of `rustc_index::newtype_index!` means that `Option<Symbol>` only takes up 4 bytes, |
1558 | /// because `rustc_index::newtype_index!` reserves the last 256 values for tagging purposes. | |
0731742a | 1559 | /// |
e74abb32 | 1560 | /// Note that `Symbol` cannot directly be a `rustc_index::newtype_index!` because it |
dc9dc135 | 1561 | /// implements `fmt::Debug`, `Encodable`, and `Decodable` in special ways. |
476ff2be | 1562 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
0731742a XL |
1563 | pub struct Symbol(SymbolIndex); |
1564 | ||
e74abb32 | 1565 | rustc_index::newtype_index! { |
0731742a XL |
1566 | pub struct SymbolIndex { .. } |
1567 | } | |
476ff2be | 1568 | |
476ff2be | 1569 | impl Symbol { |
0731742a | 1570 | const fn new(n: u32) -> Self { |
ba9703b0 | 1571 | Symbol(SymbolIndex::from_u32(n)) |
0731742a XL |
1572 | } |
1573 | ||
476ff2be SL |
1574 | /// Maps a string to its interned representation. |
1575 | pub fn intern(string: &str) -> Self { | |
1576 | with_interner(|interner| interner.intern(string)) | |
1577 | } | |
1578 | ||
60c5eb7d XL |
1579 | /// Convert to a `SymbolStr`. This is a slowish operation because it |
1580 | /// requires locking the symbol interner. | |
1581 | pub fn as_str(self) -> SymbolStr { | |
476ff2be | 1582 | with_interner(|interner| unsafe { |
dfeec247 | 1583 | SymbolStr { string: std::mem::transmute::<&str, &str>(interner.get(self)) } |
476ff2be SL |
1584 | }) |
1585 | } | |
1586 | ||
83c7162d | 1587 | pub fn as_u32(self) -> u32 { |
0731742a | 1588 | self.0.as_u32() |
ea8adc8c | 1589 | } |
74b04a01 | 1590 | |
fc512014 | 1591 | pub fn is_empty(self) -> bool { |
5869c6ff | 1592 | self == kw::Empty |
fc512014 XL |
1593 | } |
1594 | ||
74b04a01 XL |
1595 | /// This method is supposed to be used in error messages, so it's expected to be |
1596 | /// identical to printing the original identifier token written in source code | |
1597 | /// (`token_to_string`, `Ident::to_string`), except that symbols don't keep the rawness flag | |
1598 | /// or edition, so we have to guess the rawness using the global edition. | |
1599 | pub fn to_ident_string(self) -> String { | |
1600 | Ident::with_dummy_span(self).to_string() | |
1601 | } | |
ea8adc8c XL |
1602 | } |
1603 | ||
476ff2be | 1604 | impl fmt::Debug for Symbol { |
9fa01778 | 1605 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
5869c6ff | 1606 | fmt::Debug::fmt(&self.as_str(), f) |
476ff2be SL |
1607 | } |
1608 | } | |
1609 | ||
1610 | impl fmt::Display for Symbol { | |
9fa01778 | 1611 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
5869c6ff | 1612 | fmt::Display::fmt(&self.as_str(), f) |
476ff2be SL |
1613 | } |
1614 | } | |
1615 | ||
3dfed10e XL |
1616 | impl<S: Encoder> Encodable<S> for Symbol { |
1617 | fn encode(&self, s: &mut S) -> Result<(), S::Error> { | |
5869c6ff | 1618 | s.emit_str(&self.as_str()) |
476ff2be SL |
1619 | } |
1620 | } | |
1621 | ||
3dfed10e | 1622 | impl<D: Decoder> Decodable<D> for Symbol { |
74b04a01 | 1623 | #[inline] |
3dfed10e | 1624 | fn decode(d: &mut D) -> Result<Symbol, D::Error> { |
476ff2be SL |
1625 | Ok(Symbol::intern(&d.read_str()?)) |
1626 | } | |
1627 | } | |
1628 | ||
60c5eb7d XL |
1629 | impl<CTX> HashStable<CTX> for Symbol { |
1630 | #[inline] | |
1631 | fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { | |
1632 | self.as_str().hash_stable(hcx, hasher); | |
1633 | } | |
1634 | } | |
1635 | ||
1636 | impl<CTX> ToStableHashKey<CTX> for Symbol { | |
1637 | type KeyType = SymbolStr; | |
1638 | ||
1639 | #[inline] | |
1640 | fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr { | |
1641 | self.as_str() | |
1642 | } | |
1643 | } | |
1644 | ||
0731742a | 1645 | // The `&'static str`s in this type actually point into the arena. |
3dfed10e XL |
1646 | // |
1647 | // The `FxHashMap`+`Vec` pair could be replaced by `FxIndexSet`, but #75278 | |
1648 | // found that to regress performance up to 2% in some cases. This might be | |
1649 | // revisited after further improvements to `indexmap`. | |
0bf4aa26 | 1650 | #[derive(Default)] |
476ff2be | 1651 | pub struct Interner { |
94b46f34 XL |
1652 | arena: DroplessArena, |
1653 | names: FxHashMap<&'static str, Symbol>, | |
1654 | strings: Vec<&'static str>, | |
476ff2be SL |
1655 | } |
1656 | ||
1657 | impl Interner { | |
dc9dc135 XL |
1658 | fn prefill(init: &[&'static str]) -> Self { |
1659 | Interner { | |
1660 | strings: init.into(), | |
1661 | names: init.iter().copied().zip((0..).map(Symbol::new)).collect(), | |
1662 | ..Default::default() | |
476ff2be | 1663 | } |
476ff2be SL |
1664 | } |
1665 | ||
74b04a01 | 1666 | #[inline] |
476ff2be SL |
1667 | pub fn intern(&mut self, string: &str) -> Symbol { |
1668 | if let Some(&name) = self.names.get(string) { | |
1669 | return name; | |
1670 | } | |
1671 | ||
0731742a | 1672 | let name = Symbol::new(self.strings.len() as u32); |
94b46f34 | 1673 | |
0731742a XL |
1674 | // `from_utf8_unchecked` is safe since we just allocated a `&str` which is known to be |
1675 | // UTF-8. | |
dfeec247 XL |
1676 | let string: &str = |
1677 | unsafe { str::from_utf8_unchecked(self.arena.alloc_slice(string.as_bytes())) }; | |
0731742a XL |
1678 | // It is safe to extend the arena allocation to `'static` because we only access |
1679 | // these while the arena is still alive. | |
dfeec247 | 1680 | let string: &'static str = unsafe { &*(string as *const str) }; |
94b46f34 | 1681 | self.strings.push(string); |
476ff2be SL |
1682 | self.names.insert(string, name); |
1683 | name | |
1684 | } | |
60c5eb7d | 1685 | |
48663c56 XL |
1686 | // Get the symbol as a string. `Symbol::as_str()` should be used in |
1687 | // preference to this function. | |
7cac9316 | 1688 | pub fn get(&self, symbol: Symbol) -> &str { |
e74abb32 | 1689 | self.strings[symbol.0.as_usize()] |
476ff2be SL |
1690 | } |
1691 | } | |
1692 | ||
dc9dc135 | 1693 | // This module has a very short name because it's used a lot. |
ba9703b0 XL |
1694 | /// This module contains all the defined keyword `Symbol`s. |
1695 | /// | |
1696 | /// Given that `kw` is imported, use them like `kw::keyword_name`. | |
1697 | /// For example `kw::Loop` or `kw::Break`. | |
dc9dc135 | 1698 | pub mod kw { |
fc512014 | 1699 | pub use super::kw_generated::*; |
48663c56 XL |
1700 | } |
1701 | ||
1702 | // This module has a very short name because it's used a lot. | |
ba9703b0 XL |
1703 | /// This module contains all the defined non-keyword `Symbol`s. |
1704 | /// | |
1705 | /// Given that `sym` is imported, use them like `sym::symbol_name`. | |
1706 | /// For example `sym::rustfmt` or `sym::u8`. | |
48663c56 XL |
1707 | pub mod sym { |
1708 | use super::Symbol; | |
dfeec247 | 1709 | use std::convert::TryInto; |
dc9dc135 | 1710 | |
6a06907d | 1711 | #[doc(inline)] |
fc512014 | 1712 | pub use super::sym_generated::*; |
74b04a01 XL |
1713 | |
1714 | // Used from a macro in `librustc_feature/accepted.rs` | |
1715 | pub use super::kw::MacroRules as macro_rules; | |
dc9dc135 | 1716 | |
fc512014 XL |
1717 | /// Get the symbol for an integer. |
1718 | /// | |
1719 | /// The first few non-negative integers each have a static symbol and therefore | |
1720 | /// are fast. | |
dc9dc135 XL |
1721 | pub fn integer<N: TryInto<usize> + Copy + ToString>(n: N) -> Symbol { |
1722 | if let Result::Ok(idx) = n.try_into() { | |
fc512014 XL |
1723 | if idx < 10 { |
1724 | return Symbol::new(super::SYMBOL_DIGITS_BASE + idx as u32); | |
dc9dc135 XL |
1725 | } |
1726 | } | |
1727 | Symbol::intern(&n.to_string()) | |
1728 | } | |
94b46f34 XL |
1729 | } |
1730 | ||
1731 | impl Symbol { | |
fc512014 XL |
1732 | fn is_special(self) -> bool { |
1733 | self <= kw::Underscore | |
1734 | } | |
1735 | ||
1736 | fn is_used_keyword_always(self) -> bool { | |
1737 | self >= kw::As && self <= kw::While | |
0731742a XL |
1738 | } |
1739 | ||
fc512014 XL |
1740 | fn is_used_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool { |
1741 | (self >= kw::Async && self <= kw::Dyn) && edition() >= Edition::Edition2018 | |
dc9dc135 XL |
1742 | } |
1743 | ||
fc512014 XL |
1744 | fn is_unused_keyword_always(self) -> bool { |
1745 | self >= kw::Abstract && self <= kw::Yield | |
1746 | } | |
1747 | ||
1748 | fn is_unused_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool { | |
1749 | self == kw::Try && edition() >= Edition::Edition2018 | |
1750 | } | |
1751 | ||
1752 | pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool { | |
1753 | self.is_special() | |
1754 | || self.is_used_keyword_always() | |
1755 | || self.is_unused_keyword_always() | |
1756 | || self.is_used_keyword_conditional(edition) | |
1757 | || self.is_unused_keyword_conditional(edition) | |
dc9dc135 XL |
1758 | } |
1759 | ||
1760 | /// A keyword or reserved identifier that can be used as a path segment. | |
1761 | pub fn is_path_segment_keyword(self) -> bool { | |
dfeec247 XL |
1762 | self == kw::Super |
1763 | || self == kw::SelfLower | |
1764 | || self == kw::SelfUpper | |
1765 | || self == kw::Crate | |
1766 | || self == kw::PathRoot | |
1767 | || self == kw::DollarCrate | |
dc9dc135 XL |
1768 | } |
1769 | ||
e1599b0c XL |
1770 | /// Returns `true` if the symbol is `true` or `false`. |
1771 | pub fn is_bool_lit(self) -> bool { | |
1772 | self == kw::True || self == kw::False | |
1773 | } | |
1774 | ||
fc512014 | 1775 | /// Returns `true` if this symbol can be a raw identifier. |
dc9dc135 | 1776 | pub fn can_be_raw(self) -> bool { |
5869c6ff | 1777 | self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword() |
94b46f34 XL |
1778 | } |
1779 | } | |
1780 | ||
1781 | impl Ident { | |
0731742a | 1782 | // Returns `true` for reserved identifiers used internally for elided lifetimes, |
94b46f34 XL |
1783 | // unnamed method parameters, crate root module, error recovery etc. |
1784 | pub fn is_special(self) -> bool { | |
fc512014 | 1785 | self.name.is_special() |
94b46f34 XL |
1786 | } |
1787 | ||
1788 | /// Returns `true` if the token is a keyword used in the language. | |
1789 | pub fn is_used_keyword(self) -> bool { | |
0731742a | 1790 | // Note: `span.edition()` is relatively expensive, don't call it unless necessary. |
fc512014 XL |
1791 | self.name.is_used_keyword_always() |
1792 | || self.name.is_used_keyword_conditional(|| self.span.edition()) | |
94b46f34 XL |
1793 | } |
1794 | ||
1795 | /// Returns `true` if the token is a keyword reserved for possible future use. | |
1796 | pub fn is_unused_keyword(self) -> bool { | |
1797 | // Note: `span.edition()` is relatively expensive, don't call it unless necessary. | |
fc512014 XL |
1798 | self.name.is_unused_keyword_always() |
1799 | || self.name.is_unused_keyword_conditional(|| self.span.edition()) | |
94b46f34 XL |
1800 | } |
1801 | ||
1802 | /// Returns `true` if the token is either a special identifier or a keyword. | |
1803 | pub fn is_reserved(self) -> bool { | |
fc512014 XL |
1804 | // Note: `span.edition()` is relatively expensive, don't call it unless necessary. |
1805 | self.name.is_reserved(|| self.span.edition()) | |
94b46f34 XL |
1806 | } |
1807 | ||
1808 | /// A keyword or reserved identifier that can be used as a path segment. | |
1809 | pub fn is_path_segment_keyword(self) -> bool { | |
dc9dc135 | 1810 | self.name.is_path_segment_keyword() |
532ac7d7 XL |
1811 | } |
1812 | ||
1813 | /// We see this identifier in a normal identifier position, like variable name or a type. | |
1814 | /// How was it written originally? Did it use the raw form? Let's try to guess. | |
1815 | pub fn is_raw_guess(self) -> bool { | |
dc9dc135 | 1816 | self.name.can_be_raw() && self.is_reserved() |
94b46f34 | 1817 | } |
476ff2be SL |
1818 | } |
1819 | ||
0531ce1d | 1820 | #[inline] |
476ff2be | 1821 | fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T { |
136023e0 | 1822 | with_session_globals(|session_globals| f(&mut *session_globals.symbol_interner.lock())) |
476ff2be SL |
1823 | } |
1824 | ||
fc512014 | 1825 | /// An alternative to [`Symbol`], useful when the chars within the symbol need to |
e74abb32 XL |
1826 | /// be accessed. It deliberately has limited functionality and should only be |
1827 | /// used for temporary values. | |
48663c56 XL |
1828 | /// |
1829 | /// Because the interner outlives any thread which uses this type, we can | |
1830 | /// safely treat `string` which points to interner data, as an immortal string, | |
1831 | /// as long as this type never crosses between threads. | |
1832 | // | |
60c5eb7d XL |
1833 | // FIXME: ensure that the interner outlives any thread which uses `SymbolStr`, |
1834 | // by creating a new thread right after constructing the interner. | |
e74abb32 | 1835 | #[derive(Clone, Eq, PartialOrd, Ord)] |
60c5eb7d | 1836 | pub struct SymbolStr { |
476ff2be SL |
1837 | string: &'static str, |
1838 | } | |
1839 | ||
60c5eb7d XL |
1840 | // This impl allows a `SymbolStr` to be directly equated with a `String` or |
1841 | // `&str`. | |
1842 | impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr { | |
cc61c64b XL |
1843 | fn eq(&self, other: &T) -> bool { |
1844 | self.string == other.deref() | |
1845 | } | |
1846 | } | |
1847 | ||
60c5eb7d XL |
1848 | impl !Send for SymbolStr {} |
1849 | impl !Sync for SymbolStr {} | |
476ff2be | 1850 | |
60c5eb7d XL |
1851 | /// This impl means that if `ss` is a `SymbolStr`: |
1852 | /// - `*ss` is a `str`; | |
3dfed10e | 1853 | /// - `&*ss` is a `&str` (and `match &*ss { ... }` is a common pattern). |
60c5eb7d XL |
1854 | /// - `&ss as &str` is a `&str`, which means that `&ss` can be passed to a |
1855 | /// function expecting a `&str`. | |
1856 | impl std::ops::Deref for SymbolStr { | |
476ff2be | 1857 | type Target = str; |
dc9dc135 | 1858 | #[inline] |
dfeec247 XL |
1859 | fn deref(&self) -> &str { |
1860 | self.string | |
1861 | } | |
476ff2be SL |
1862 | } |
1863 | ||
60c5eb7d | 1864 | impl fmt::Debug for SymbolStr { |
9fa01778 | 1865 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
476ff2be SL |
1866 | fmt::Debug::fmt(self.string, f) |
1867 | } | |
1868 | } | |
1869 | ||
60c5eb7d | 1870 | impl fmt::Display for SymbolStr { |
9fa01778 | 1871 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
476ff2be SL |
1872 | fmt::Display::fmt(self.string, f) |
1873 | } | |
1874 | } | |
60c5eb7d XL |
1875 | |
1876 | impl<CTX> HashStable<CTX> for SymbolStr { | |
1877 | #[inline] | |
1878 | fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { | |
1879 | self.string.hash_stable(hcx, hasher) | |
1880 | } | |
1881 | } | |
1882 | ||
1883 | impl<CTX> ToStableHashKey<CTX> for SymbolStr { | |
1884 | type KeyType = SymbolStr; | |
1885 | ||
1886 | #[inline] | |
1887 | fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr { | |
1888 | self.clone() | |
1889 | } | |
1890 | } |