]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_save_analysis/span_utils.rs
Rollup merge of #68515 - Wind-River:master_2020, r=alexcrichton
[rust.git] / src / librustc_save_analysis / span_utils.rs
index 4d0780cf94df002ed4eeb2ddc8e0d6ca0005db7a..f904a0bb9f8066857289be1eeeffd5bf9e049073 100644 (file)
@@ -1,10 +1,8 @@
-use rustc::session::Session;
-
 use crate::generated_code;
-
-use syntax::parse::lexer::{self, StringReader};
+use rustc::session::Session;
+use rustc_parse::lexer::{self, StringReader};
+use rustc_span::*;
 use syntax::token::{self, TokenKind};
-use syntax_pos::*;
 
 #[derive(Clone)]
 pub struct SpanUtils<'a> {
@@ -13,29 +11,27 @@ pub struct SpanUtils<'a> {
 
 impl<'a> SpanUtils<'a> {
     pub fn new(sess: &'a Session) -> SpanUtils<'a> {
-        SpanUtils {
-            sess,
-        }
+        SpanUtils { sess }
     }
 
     pub fn make_filename_string(&self, file: &SourceFile) -> String {
         match &file.name {
             FileName::Real(path) if !file.name_was_remapped => {
                 if path.is_absolute() {
-                    self.sess.source_map().path_mapping()
-                        .map_prefix(path.clone()).0
+                    self.sess
+                        .source_map()
+                        .path_mapping()
+                        .map_prefix(path.clone())
+                        .0
                         .display()
                         .to_string()
                 } else {
-                    self.sess.working_dir.0
-                        .join(&path)
-                        .display()
-                        .to_string()
+                    self.sess.working_dir.0.join(&path).display().to_string()
                 }
-            },
+            }
             // If the file name is already remapped, we assume the user
             // configured it the way they wanted to, so use that directly
-            filename => filename.to_string()
+            filename => filename.to_string(),
         }
     }
 
@@ -113,11 +109,7 @@ pub fn filter_generated(&self, span: Span) -> bool {
         }
 
         //If the span comes from a fake source_file, filter it.
-        !self.sess
-            .source_map()
-            .lookup_char_pos(span.lo())
-            .file
-            .is_real_file()
+        !self.sess.source_map().lookup_char_pos(span.lo()).file.is_real_file()
     }
 }