Document token spacing
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 28/100
- Issue 类型
- 文档
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- rust
调研方向
先从 lexer 章节和现有的 macro.proc.token.conversion.from-proc_macro 小节开始,然后检查 rustc_parse/src/parser/mod.rs 中 break_and_eat 附近的内容。将语法摘要中对连接 token 的处理与参考模式和借用运算符进行比较,并查看关联的 issue 和 pull request。当 Reference 明确定义 token 的间距、拆分或粘合方式,以及 lexer/parser 的边界时,即可视为完成。
由索引模型根据 Issue 内容生成。
描述
I think the behavior around token splitting should be documented in some way, though I'm uncertain exactly how. The general idea is that the lexer chapter defines tokens, such as <-, which are then split in certain situations to smaller tokens. AFAIK, the reference doesn't really define how this works. I also don't know how much of this is part of the lexer versus the parser. I suspect it needs to be addressed in both depending on which approach we take.
A question I have is whether it should be documented as tokens being split, or tokens being glued, since I could imagine either approach is viable.
I think in rustc, currently the primary method that is used to handle this is break_and_eat. However, I may be misremembering if there are other places where this is handled.
IIUC, the places where this splitting happens is somewhat arbitrary, in terms of places where people thought it would be helpful. There's nothing that prevents the parser from avoiding those splitting methods.
There is a brief mention in macro.proc.token.conversion.from-proc_macro how proc-macro output is glued/split. The proc-macro Spacing type briefly touches on it as well.
Note that reference patterns and borrow operators specifically include the && token in their grammar. I don't remember the exact details about why we did it that way (that is, why did we do this just for && and no other token?). Depending on how we approach this, we may need to consider how that might need to change.
Note that I included some of the jointed tokens in the syntax summary. We may want to remove some. For example, I have >>= and >= linking to generics.
Some relevant links:
- 主要语言
- Rust
- 星标
- 1.6k
- 派生
- 618
- 平均合并
- 5 小时 48 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-lang/reference 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
A-const-eval A-undefined-behavior
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
rust-lang/reference#2266 · 1 条评论 ·
维护者通常 1 天内回复
-
A-resolve
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
查看 rust-lang/reference 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 78/100
CakeRepository/agentshangout#995 ·
-
area:frontend kind:bug priority:p3 ready
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复