Skip to content

Commit

Permalink
deps: apply upstream rustc-* changes
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed Jun 11, 2020
1 parent de4ff81 commit b28fd5f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum FileName {
impl From<rustc_span::FileName> for FileName {
fn from(name: rustc_span::FileName) -> FileName {
match name {
rustc_span::FileName::Real(p) => FileName::Real(p),
rustc_span::FileName::Real(p) => FileName::Real(p.into_local_path()),
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
_ => unreachable!(),
}
Expand Down
6 changes: 5 additions & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ pub(crate) fn format_expr(
}
// We do not format these expressions yet, but they should still
// satisfy our width restrictions.
ast::ExprKind::LlvmInlineAsm(..) => Some(context.snippet(expr.span).to_owned()),
// Style Guide RFC for InlineAsm variant pending
// https://github.com/rust-dev-tools/fmt-rfcs/issues/152
ast::ExprKind::LlvmInlineAsm(..) | ast::ExprKind::InlineAsm(..) => {
Some(context.snippet(expr.span).to_owned())
}
ast::ExprKind::TryBlock(ref block) => {
if let rw @ Some(_) =
rewrite_single_line_block(context, "try ", block, Some(&expr.attrs), None, shape)
Expand Down
1 change: 1 addition & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ pub(crate) fn convert_try_mac(
kind: ast::ExprKind::Try(parser.parse_expr().ok()?),
span: mac.span(), // incorrect span, but shouldn't matter too much
attrs: ast::AttrVec::new(),
tokens: Some(ts),
})
} else {
None
Expand Down
4 changes: 3 additions & 1 deletion src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ where
impl From<&FileName> for rustc_span::FileName {
fn from(filename: &FileName) -> rustc_span::FileName {
match filename {
FileName::Real(path) => rustc_span::FileName::Real(path.to_owned()),
FileName::Real(path) => {
rustc_span::FileName::Real(rustc_span::RealFileName::Named(path.to_owned()))
}
FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()),
}
}
Expand Down
38 changes: 27 additions & 11 deletions src/syntux/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
}
if let Some(primary_span) = &db.span.primary_span() {
let file_name = self.source_map.span_to_filename(*primary_span);
if let rustc_span::FileName::Real(ref path) = file_name {
if let rustc_span::FileName::Real(rustc_span::RealFileName::Named(ref path)) = file_name
{
if self
.ignore_path_set
.is_match(&FileName::Real(path.to_path_buf()))
Expand Down Expand Up @@ -162,7 +163,9 @@ impl ParseSess {
pub(crate) fn is_file_parsed(&self, path: &Path) -> bool {
self.parse_sess
.source_map()
.get_source_file(&rustc_span::FileName::Real(path.to_path_buf()))
.get_source_file(&rustc_span::FileName::Real(
rustc_span::RealFileName::Named(path.to_path_buf()),
))
.is_some()
}

Expand Down Expand Up @@ -277,7 +280,7 @@ mod tests {
use crate::config::IgnoreList;
use crate::is_nightly_channel;
use crate::utils::mk_sp;
use rustc_span::{FileName as SourceMapFileName, MultiSpan, DUMMY_SP};
use rustc_span::{FileName as SourceMapFileName, MultiSpan, RealFileName, DUMMY_SP};
use std::path::PathBuf;

struct TestEmitter {
Expand Down Expand Up @@ -337,7 +340,10 @@ mod tests {
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
let source =
String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#);
source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
source,
);
let mut emitter = build_emitter(
Rc::clone(&num_emitted_errors),
Rc::clone(&can_reset_errors),
Expand All @@ -361,7 +367,10 @@ mod tests {
let ignore_list = get_ignore_list(r#"ignore = ["foo.rs"]"#);
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
let source = String::from(r#"pub fn bar() { 1x; }"#);
source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
source,
);
let mut emitter = build_emitter(
Rc::clone(&num_emitted_errors),
Rc::clone(&can_reset_errors),
Expand All @@ -384,7 +393,10 @@ mod tests {
let can_reset_errors = Rc::new(RefCell::new(false));
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
let source = String::from(r#"pub fn bar() { 1x; }"#);
source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
source,
);
let mut emitter = build_emitter(
Rc::clone(&num_emitted_errors),
Rc::clone(&can_reset_errors),
Expand All @@ -411,12 +423,16 @@ mod tests {
let foo_source = String::from(r#"pub fn foo() { 1x; }"#);
let fatal_source =
String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#);
source_map
.new_source_file(SourceMapFileName::Real(PathBuf::from("bar.rs")), bar_source);
source_map
.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), foo_source);
source_map.new_source_file(
SourceMapFileName::Real(PathBuf::from("fatal.rs")),
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("bar.rs"))),
bar_source,
);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
foo_source,
);
source_map.new_source_file(
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("fatal.rs"))),
fatal_source,
);
let mut emitter = build_emitter(
Expand Down
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
| ast::ExprKind::Continue(..)
| ast::ExprKind::Err
| ast::ExprKind::Field(..)
| ast::ExprKind::InlineAsm(..)
| ast::ExprKind::LlvmInlineAsm(..)
| ast::ExprKind::Let(..)
| ast::ExprKind::Path(..)
Expand Down

0 comments on commit b28fd5f

Please sign in to comment.