Skip to content

Commit b28fd5f

Browse files
deps: apply upstream rustc-* changes
1 parent de4ff81 commit b28fd5f

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

src/config/file_lines.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum FileName {
2727
impl From<rustc_span::FileName> for FileName {
2828
fn from(name: rustc_span::FileName) -> FileName {
2929
match name {
30-
rustc_span::FileName::Real(p) => FileName::Real(p),
30+
rustc_span::FileName::Real(p) => FileName::Real(p.into_local_path()),
3131
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
3232
_ => unreachable!(),
3333
}

src/expr.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,11 @@ pub(crate) fn format_expr(
322322
}
323323
// We do not format these expressions yet, but they should still
324324
// satisfy our width restrictions.
325-
ast::ExprKind::LlvmInlineAsm(..) => Some(context.snippet(expr.span).to_owned()),
325+
// Style Guide RFC for InlineAsm variant pending
326+
// https://github.com/rust-dev-tools/fmt-rfcs/issues/152
327+
ast::ExprKind::LlvmInlineAsm(..) | ast::ExprKind::InlineAsm(..) => {
328+
Some(context.snippet(expr.span).to_owned())
329+
}
326330
ast::ExprKind::TryBlock(ref block) => {
327331
if let rw @ Some(_) =
328332
rewrite_single_line_block(context, "try ", block, Some(&expr.attrs), None, shape)

src/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ pub(crate) fn convert_try_mac(
12041204
kind: ast::ExprKind::Try(parser.parse_expr().ok()?),
12051205
span: mac.span(), // incorrect span, but shouldn't matter too much
12061206
attrs: ast::AttrVec::new(),
1207+
tokens: Some(ts),
12071208
})
12081209
} else {
12091210
None

src/source_file.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ where
6868
impl From<&FileName> for rustc_span::FileName {
6969
fn from(filename: &FileName) -> rustc_span::FileName {
7070
match filename {
71-
FileName::Real(path) => rustc_span::FileName::Real(path.to_owned()),
71+
FileName::Real(path) => {
72+
rustc_span::FileName::Real(rustc_span::RealFileName::Named(path.to_owned()))
73+
}
7274
FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()),
7375
}
7476
}

src/syntux/session.rs

+27-11
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
6666
}
6767
if let Some(primary_span) = &db.span.primary_span() {
6868
let file_name = self.source_map.span_to_filename(*primary_span);
69-
if let rustc_span::FileName::Real(ref path) = file_name {
69+
if let rustc_span::FileName::Real(rustc_span::RealFileName::Named(ref path)) = file_name
70+
{
7071
if self
7172
.ignore_path_set
7273
.is_match(&FileName::Real(path.to_path_buf()))
@@ -162,7 +163,9 @@ impl ParseSess {
162163
pub(crate) fn is_file_parsed(&self, path: &Path) -> bool {
163164
self.parse_sess
164165
.source_map()
165-
.get_source_file(&rustc_span::FileName::Real(path.to_path_buf()))
166+
.get_source_file(&rustc_span::FileName::Real(
167+
rustc_span::RealFileName::Named(path.to_path_buf()),
168+
))
166169
.is_some()
167170
}
168171

@@ -277,7 +280,7 @@ mod tests {
277280
use crate::config::IgnoreList;
278281
use crate::is_nightly_channel;
279282
use crate::utils::mk_sp;
280-
use rustc_span::{FileName as SourceMapFileName, MultiSpan, DUMMY_SP};
283+
use rustc_span::{FileName as SourceMapFileName, MultiSpan, RealFileName, DUMMY_SP};
281284
use std::path::PathBuf;
282285

283286
struct TestEmitter {
@@ -337,7 +340,10 @@ mod tests {
337340
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
338341
let source =
339342
String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#);
340-
source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source);
343+
source_map.new_source_file(
344+
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
345+
source,
346+
);
341347
let mut emitter = build_emitter(
342348
Rc::clone(&num_emitted_errors),
343349
Rc::clone(&can_reset_errors),
@@ -361,7 +367,10 @@ mod tests {
361367
let ignore_list = get_ignore_list(r#"ignore = ["foo.rs"]"#);
362368
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
363369
let source = String::from(r#"pub fn bar() { 1x; }"#);
364-
source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source);
370+
source_map.new_source_file(
371+
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
372+
source,
373+
);
365374
let mut emitter = build_emitter(
366375
Rc::clone(&num_emitted_errors),
367376
Rc::clone(&can_reset_errors),
@@ -384,7 +393,10 @@ mod tests {
384393
let can_reset_errors = Rc::new(RefCell::new(false));
385394
let source_map = Rc::new(SourceMap::new(FilePathMapping::empty()));
386395
let source = String::from(r#"pub fn bar() { 1x; }"#);
387-
source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source);
396+
source_map.new_source_file(
397+
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
398+
source,
399+
);
388400
let mut emitter = build_emitter(
389401
Rc::clone(&num_emitted_errors),
390402
Rc::clone(&can_reset_errors),
@@ -411,12 +423,16 @@ mod tests {
411423
let foo_source = String::from(r#"pub fn foo() { 1x; }"#);
412424
let fatal_source =
413425
String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#);
414-
source_map
415-
.new_source_file(SourceMapFileName::Real(PathBuf::from("bar.rs")), bar_source);
416-
source_map
417-
.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), foo_source);
418426
source_map.new_source_file(
419-
SourceMapFileName::Real(PathBuf::from("fatal.rs")),
427+
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("bar.rs"))),
428+
bar_source,
429+
);
430+
source_map.new_source_file(
431+
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("foo.rs"))),
432+
foo_source,
433+
);
434+
source_map.new_source_file(
435+
SourceMapFileName::Real(RealFileName::Named(PathBuf::from("fatal.rs"))),
420436
fatal_source,
421437
);
422438
let mut emitter = build_emitter(

src/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
487487
| ast::ExprKind::Continue(..)
488488
| ast::ExprKind::Err
489489
| ast::ExprKind::Field(..)
490+
| ast::ExprKind::InlineAsm(..)
490491
| ast::ExprKind::LlvmInlineAsm(..)
491492
| ast::ExprKind::Let(..)
492493
| ast::ExprKind::Path(..)

0 commit comments

Comments
 (0)