about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-07-04 17:50:53 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-07-05 08:27:17 +1000
commitdd790ab8ef8cc2a89f04f2be73c86230595a48a3 (patch)
tree54871a12dd067cb5f44e4168c154fbff788cb231 /compiler
parentc4225812973cee4bba952cbf7a421f69871fed0d (diff)
downloadrust-dd790ab8ef8cc2a89f04f2be73c86230595a48a3.tar.gz
rust-dd790ab8ef8cc2a89f04f2be73c86230595a48a3.zip
Remove some unnecessary integer conversions.
These should have been removed in #127233 when the positions were
changed from `usize` to `u32`.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_parse/src/parser/attr.rs4
-rw-r--r--compiler/rustc_parse/src/parser/attr_wrapper.rs4
2 files changed, 3 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs
index 58fef9b6c45..1d31669d207 100644
--- a/compiler/rustc_parse/src/parser/attr.rs
+++ b/compiler/rustc_parse/src/parser/attr.rs
@@ -282,7 +282,7 @@ impl<'a> Parser<'a> {
     pub fn parse_inner_attributes(&mut self) -> PResult<'a, ast::AttrVec> {
         let mut attrs = ast::AttrVec::new();
         loop {
-            let start_pos: u32 = self.num_bump_calls.try_into().unwrap();
+            let start_pos = self.num_bump_calls;
             // Only try to parse if it is an inner attribute (has `!`).
             let attr = if self.check(&token::Pound) && self.look_ahead(1, |t| t == &token::Not) {
                 Some(self.parse_attribute(InnerAttrPolicy::Permitted)?)
@@ -303,7 +303,7 @@ impl<'a> Parser<'a> {
                 None
             };
             if let Some(attr) = attr {
-                let end_pos: u32 = self.num_bump_calls.try_into().unwrap();
+                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
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs
index 13a647adfe3..53565ffe2c9 100644
--- a/compiler/rustc_parse/src/parser/attr_wrapper.rs
+++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs
@@ -8,7 +8,6 @@ use rustc_errors::PResult;
 use rustc_session::parse::ParseSess;
 use rustc_span::{sym, Span, DUMMY_SP};
 
-use std::ops::Range;
 use std::{iter, mem};
 
 /// A wrapper type to ensure that the parser handles outer attributes correctly.
@@ -356,8 +355,7 @@ impl<'a> Parser<'a> {
             let new_tokens = vec![(FlatToken::AttrTarget(attr_data), Spacing::Alone)];
 
             assert!(!self.break_last_token, "Should not have unglued last token with cfg attr");
-            let range: Range<u32> = (start_pos.try_into().unwrap())..(end_pos.try_into().unwrap());
-            self.capture_state.replace_ranges.push((range, new_tokens));
+            self.capture_state.replace_ranges.push((start_pos..end_pos, new_tokens));
             self.capture_state.replace_ranges.extend(inner_attr_replace_ranges);
         }