Crate rustc_hir_pretty[−][src]

Modules

This module contains all the defined keyword Symbols.

This pretty-printer is a direct reimplementation of Philip Karlton’s Mesa pretty-printer, as described in the appendix to Derek C. Oppen, “Pretty Printing” (1979), Stanford Computer Science Department STAN-CS-79-770, http://i.stanford.edu/pub/cstr/reports/cs/tr/79/770/CS-TR-79-770.pdf.

A contiguous growable array type with heap-allocated contents, written Vec<T>.

Macros

Creates a Vec containing the arguments.

Structs

A byte offset.

This is the most general way to print identifiers. AST pretty-printer is used as a fallback for turning AST structures into token streams for proc macros. Additionally, proc macros may stringify their input and expect it survive the stringification (especially true for proc macro derives written between Rust 1.15 and 1.30). So we need to somehow pretty-print $crate in a way preserving at least some of its hygiene data, most importantly name of the crate it refers to. As a result we print $crate as crate if it refers to the local crate and as ::other_crate_name if it refers to some other crate. Note, that this is only done if the ident token is printed from inside of AST pretty-pringing, but not otherwise. Pretty-printing is the only way for proc macros to discover token contents, so we should not perform this lossy conversion if the top level call to the pretty-printer was done for a token stream or a single token.

An interned string.

A mutable memory location.

Enums

Associative operator with precedence.

How to break. Described in more detail in the module docs.

Differentiates between real files and common virtual files.

The AST represents all type param bounds as types. typeck::collect::compute_bounds matches these against the “special” built-in traits (see middle::lang_items) and detects Copy, Send and Sync.

A modifier on a bound, currently this is only used for ?Sized, where the modifier is Maybe. Negative bounds should also be handled here.

A clone-on-write smart pointer.

Constants

Traits

Functions

Expressions that syntactically contain an “exterior” struct literal, i.e., not surrounded by any parens or other delimiters, e.g., X { y: 1 }, X { y: 1 }.method(), foo == X { y: 1 } and X { y: 1 } == foo all do, but (X { y: 1 }) == foo does not.

Does this expression require a semicolon to be treated as a statement? The negation of this: ‘can this expression be used as a statement without a semicolon’ – is used as an early-bail-out in the parser so that, for instance, if true {…} else {…} |x| 5 isn’t parsed as (if true {…} else {…} | x) | 5

Requires you to pass an input filename and reader so that it can scan the input text for comments to copy forward.

This statement requires a semicolon after it. note that in one case (stmt_semi), we’ve already seen the semicolon, and thus don’t need another.