1 //! FIXME: write short doc here
5 pub(super) const PATH_FIRST: TokenSet =
6 token_set![IDENT, T![self], T![super], T![crate], T![:], T![<]];
8 pub(super) fn is_path_start(p: &Parser) -> bool {
9 is_use_path_start(p) || p.at(T![<])
12 pub(super) fn is_use_path_start(p: &Parser) -> bool {
14 IDENT | T![self] | T![super] | T![crate] => true,
15 T![:] if p.at(T![::]) => true,
20 pub(super) fn use_path(p: &mut Parser) {
24 pub(crate) fn type_path(p: &mut Parser) {
28 pub(super) fn expr_path(p: &mut Parser) {
32 #[derive(Clone, Copy, Eq, PartialEq)]
39 fn path(p: &mut Parser, mode: Mode) {
41 path_segment(p, mode, true);
42 let mut qual = path.complete(p, PATH);
44 let use_tree = matches!(p.nth(2), T![*] | T!['{']);
45 if p.at(T![::]) && !use_tree {
46 let path = qual.precede(p);
48 path_segment(p, mode, false);
49 let path = path.complete(p, PATH);
57 fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
60 // type X = <A as B>::Output;
61 // fn foo() { <usize as Default>::default(); }
62 if first && p.eat(T![<]) {
65 if is_use_path_start(p) {
68 p.error("expected a trait");
81 opt_path_type_args(p, mode);
85 T![self] | T![super] | T![crate] => p.bump_any(),
87 p.err_recover("expected identifier", items::ITEM_RECOVERY_SET);
89 // test_err empty_segment
97 m.complete(p, PATH_SEGMENT);
100 fn opt_path_type_args(p: &mut Parser, mode: Mode) {
104 // test path_fn_trait_args
105 // type F = Box<Fn(i32) -> ()>;
107 params::param_list_fn_trait(p);
110 type_args::opt_type_arg_list(p, false)
113 Mode::Expr => type_args::opt_type_arg_list(p, true),