]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/sugg.rs
Merge pull request #3288 from devonhollowood/pedantic-dogfood-casts
[rust.git] / clippy_lints / src / utils / sugg.rs
index fecfc0c0789ff4ca5d0625f48ca91dc7e4a17de1..eb67838f1d188e58ba6f89d6e66942f0856e5a47 100644 (file)
@@ -16,6 +16,7 @@
 use crate::rustc::lint::{EarlyContext, LateContext, LintContext};
 use crate::rustc_errors;
 use std::borrow::Cow;
+use std::convert::TryInto;
 use std::fmt::Display;
 use std;
 use crate::syntax::source_map::{CharPos, Span};
@@ -551,7 +552,7 @@ fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability:
             let non_whitespace_offset = src[fmpos.pos.to_usize()..].find(|c| c != ' ' && c != '\t' && c != '\n');
 
             if let Some(non_whitespace_offset) = non_whitespace_offset {
-                remove_span = remove_span.with_hi(remove_span.hi() + BytePos(non_whitespace_offset as u32))
+                remove_span = remove_span.with_hi(remove_span.hi() + BytePos(non_whitespace_offset.try_into().expect("offset too large")))
             }
         }