about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-08-02 09:39:28 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-08-16 09:07:31 +1000
commit5aaa2f92ee050dadca1c3639dc9283971a7b4e8b (patch)
tree163aa5e9a9b4e0f8c3e7cbdf8edde13da19f4963 /compiler/rustc_parse/src/parser
parentc8098be41fa767a96cfb3665147fabf06f456be9 (diff)
downloadrust-5aaa2f92ee050dadca1c3639dc9283971a7b4e8b.tar.gz
rust-5aaa2f92ee050dadca1c3639dc9283971a7b4e8b.zip
Add an assertion to `NodeRange::new`.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs1
1 files changed, 1 insertions, 0 deletions
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))
     }
 }