]> git.lizzy.rs Git - rust.git/commitdiff
Fix issue-1116
authorSergey Pepyakin <s.pepyakin@gmail.com>
Tue, 2 Aug 2016 22:25:54 +0000 (01:25 +0300)
committerSergey Pepyakin <s.pepyakin@gmail.com>
Thu, 4 Aug 2016 05:54:40 +0000 (08:54 +0300)
src/imports.rs

index a9d56878ea6a7f35c64bdf65b430dee0be539eee..d82e09343604ea8206400d2121edc7fc902effcc 100644 (file)
@@ -159,8 +159,10 @@ fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Opt
 
 impl<'a> FmtVisitor<'a> {
     pub fn format_imports(&mut self, use_items: &[ptr::P<ast::Item>]) {
-        let mut last_pos =
-            use_items.first().map(|p_i| p_i.span.lo - BytePos(1)).unwrap_or(self.last_pos);
+        let mut last_pos = use_items.first()
+            .and_then(|p_i| p_i.span.lo.0.checked_sub(1))
+            .map(|span_lo| BytePos(span_lo))
+            .unwrap_or(self.last_pos);
         let prefix = codemap::mk_sp(self.last_pos, last_pos);
         let mut ordered_use_items = use_items.iter()
             .map(|p_i| {