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 f34d1a4 commit 7810e02
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl 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 All @@ -48,7 +48,9 @@ impl From<rustc_span::FileName> for FileName {
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
6 changes: 5 additions & 1 deletion src/formatting/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/formatting/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,7 @@ pub(crate) fn convert_try_mac(
kind: ast::ExprKind::Try(kind),
span: mac.span(), // incorrect span, but shouldn't matter too much
attrs: ast::AttrVec::new(),
tokens: Some(ts),
})
} else {
None
Expand Down
38 changes: 27 additions & 11 deletions src/formatting/syntux/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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 @@ -158,7 +159,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 @@ -266,7 +269,7 @@ mod tests {
use crate::config::IgnoreList;
use crate::formatting::utils::mk_sp;
use crate::is_nightly_channel;
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 @@ -326,7 +329,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 @@ -350,7 +356,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 @@ -373,7 +382,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 @@ -400,12 +412,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/formatting/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,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 7810e02

Please sign in to comment.