From 5aaa2f92ee050dadca1c3639dc9283971a7b4e8b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 2 Aug 2024 09:39:28 +1000 Subject: [PATCH] Add an assertion to `NodeRange::new`. --- compiler/rustc_parse/src/parser/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 05758fe0624..6a3c4a0c106 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -238,6 +238,7 @@ impl NodeRange { // is the position of the function's start token. This gives // `NodeRange(10..15)`. fn new(ParserRange(parser_range): ParserRange, start_pos: u32) -> NodeRange { + assert!(parser_range.start >= start_pos && parser_range.end >= start_pos); NodeRange((parser_range.start - start_pos)..(parser_range.end - start_pos)) } }