diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-12 15:47:16 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-19 15:25:54 +1000 |
| commit | 757f73f506a48ff96de54c0cb8c79a25ffbc70d9 (patch) | |
| tree | f92ed5e6ac886abff68e4bd18955dc3dc918c5b7 /compiler/rustc_parse/src/parser/attr.rs | |
| parent | 3d68afc9e821b00d59058abc9bda670b07639955 (diff) | |
| download | rust-757f73f506a48ff96de54c0cb8c79a25ffbc70d9.tar.gz rust-757f73f506a48ff96de54c0cb8c79a25ffbc70d9.zip | |
Simplify `CaptureState::inner_attr_ranges`.
The `Option`s within the `ReplaceRange`s within the hashmap are always `None`. This PR omits them and inserts them when they are extracted from the hashmap.
Diffstat (limited to 'compiler/rustc_parse/src/parser/attr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index a8fe35f45b3..aeef6e62fda 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -303,7 +303,6 @@ impl<'a> Parser<'a> { None }; if let Some(attr) = attr { - let end_pos = self.num_bump_calls; // If we are currently capturing tokens, mark the location of this inner attribute. // If capturing ends up creating a `LazyAttrTokenStream`, we will include // this replace range with it, removing the inner attribute from the final @@ -311,9 +310,10 @@ impl<'a> Parser<'a> { // During macro expansion, they are selectively inserted back into the // token stream (the first inner attribute is removed each time we invoke the // corresponding macro). - let range = start_pos..end_pos; if let Capturing::Yes = self.capture_state.capturing { - self.capture_state.inner_attr_ranges.insert(attr.id, (range, None)); + let end_pos = self.num_bump_calls; + let range = start_pos..end_pos; + self.capture_state.inner_attr_ranges.insert(attr.id, range); } attrs.push(attr); } else { |
