diff --git a/src/config/file_lines.rs b/src/config/file_lines.rs index d0ef489e2ca9..95fc4adec8dc 100644 --- a/src/config/file_lines.rs +++ b/src/config/file_lines.rs @@ -27,7 +27,7 @@ pub enum FileName { impl From 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!(), } diff --git a/src/expr.rs b/src/expr.rs index ed10a54c2a3b..ef7278a3a873 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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) diff --git a/src/macros.rs b/src/macros.rs index cec5d873693d..77d670dca592 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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 diff --git a/src/source_file.rs b/src/source_file.rs index 4f02d8224e27..1d22c25d922c 100644 --- a/src/source_file.rs +++ b/src/source_file.rs @@ -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()), } } diff --git a/src/syntux/session.rs b/src/syntux/session.rs index 00f12b322375..5045eab29dd5 100644 --- a/src/syntux/session.rs +++ b/src/syntux/session.rs @@ -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())) @@ -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() } @@ -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 { @@ -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), @@ -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), @@ -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), @@ -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( diff --git a/src/utils.rs b/src/utils.rs index f82bdd501cf9..bb0c6b7fb227 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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(..)