Skip to content

Commit 66e9b11

Browse files
committed
Rearrange TokenTreesReader::parse_token_tree.
`parse_token_tree` is basically a match with four arms: `Eof`, `OpenDelim`, `CloseDelim`, and "other". It has two call sites, and at each call site one of the arms is unreachable. It's also not inlined. This commit removes `parse_token_tree` by splitting it into four functions and inlining them. This avoids some repeated conditional tests and also some non-inlined function calls on the hot path.
1 parent f3fafbb commit 66e9b11

File tree

2 files changed

+170
-179
lines changed

2 files changed

+170
-179
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ pub mod translation;
6363
pub use diagnostic_builder::IntoDiagnostic;
6464
pub use snippet::Style;
6565

66-
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorGuaranteed>>;
66+
pub type PErr<'a> = DiagnosticBuilder<'a, ErrorGuaranteed>;
67+
pub type PResult<'a, T> = Result<T, PErr<'a>>;
6768

6869
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
6970
// (See also the comment on `DiagnosticBuilder`'s `diagnostic` field.)

0 commit comments

Comments
 (0)