Stream: t-compiler/help

Topic: Documenting rustc_ast::ast::Pat


pierwill (Jul 02 2020 at 06:05, on Zulip):

Hello! (Not sure in this qualifies as a 'topic' on here, but...)

I noticed that this struct https://github.com/rust-lang/rust/blob/master/src/librustc_ast/ast.rs#L515 is undocumented. Would it makes to describe this as "A pattern is a syntax element for matching against the structure of types"? This is close to how the the book describes patterns https://doc.rust-lang.org/book/ch18-00-patterns.html. Does it make sense in this context?

pierwill (Jul 02 2020 at 06:37, on Zulip):

Or is it too high-level? :thinking:

nikomatsakis (Jul 02 2020 at 15:36, on Zulip):

I think that's too oriented at teaching Rust the language and less at documenting the compiler

nikomatsakis (Jul 02 2020 at 15:36, on Zulip):

e.g., I think it's not our job to explain what a pattern is

nikomatsakis (Jul 02 2020 at 15:36, on Zulip):

though I do think giving examples from Rust code is good

nikomatsakis (Jul 02 2020 at 15:36, on Zulip):

maybe something like

// AST for a match pattern. Patterns appear in match statements and some other contexts, such as let and if let.

nikomatsakis (Jul 02 2020 at 15:36, on Zulip):

Example:

nikomatsakis (Jul 02 2020 at 15:37, on Zulip):
nikomatsakis (Jul 02 2020 at 15:37, on Zulip):

etc

pierwill (Jul 02 2020 at 22:09, on Zulip):

Thanks, @nikomatsakis ! I'll submit a PR along these lines.

Last update: Sep 27 2020 at 14:00UTC