A leaf of a use tree: `full` is the whole path, `alias` the name after * `as` (NULL when there is none). `a::b::self` imports `b` itself, in the type * namespace only. */
| 2944 | * `as` (NULL when there is none). `a::b::self` imports `b` itself, in the type |
| 2945 | * namespace only. */ |
| 2946 | static void rs_use_leaf(rs_scan_t *s, int mod, TSNode decl, const char *full, const char *alias) { |
| 2947 | static const char self_seg[] = "::self"; |
| 2948 | const size_t sl = sizeof(self_seg) - SKIP_ONE; |
| 2949 | char path[RS_SCAN_PATH_CAP]; |
| 2950 | snprintf(path, sizeof(path), "%s", full); |
| 2951 | size_t n = strlen(path); |
| 2952 | char kind = 'b'; |
| 2953 | if (n > sl && strcmp(path + n - sl, self_seg) == 0) { |
| 2954 | path[n - sl] = '\0'; |
| 2955 | kind = 's'; |
| 2956 | } |
| 2957 | const char *last = strrchr(path, ':'); |
| 2958 | const char *local = alias ? alias : (last ? last + SKIP_ONE : path); |
| 2959 | bool keyword = |
| 2960 | strcmp(local, "crate") == 0 || strcmp(local, "super") == 0 || strcmp(local, "self") == 0; |
| 2961 | if (!local[0] || (keyword && !alias)) { |
| 2962 | return; /* `use crate;` binds nothing */ |
| 2963 | } |
| 2964 | rs_rec_use(s, mod, decl, kind, local, path); |
| 2965 | } |
| 2966 | |
| 2967 | /* The bindings of one `use` declaration: its tree is walked with a stack. */ |
| 2968 | static void rs_item_use(rs_scan_t *s, TSNode decl, int mod) { |
no test coverage detected