use crate::generated_code;
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> {
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(),
}
}
}
//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()
}
}