diff --git a/src/modules.rs b/src/modules.rs index d4bddd95785..64d96a5c6a6 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -124,7 +124,7 @@ pub(crate) fn visit_crate( mut self, krate: &'ast ast::Crate, ) -> Result, ModuleResolutionError> { - let root_filename = self.parse_sess.span_to_filename(krate.span); + let root_filename = self.parse_sess.span_to_filename(krate.spans.inner_span); self.directory.path = match root_filename { FileName::Real(ref p) => p.parent().unwrap_or(Path::new("")).to_path_buf(), _ => PathBuf::new(), @@ -135,7 +135,7 @@ pub(crate) fn visit_crate( self.visit_mod_from_ast(&krate.items)?; } - let snippet_provider = self.parse_sess.snippet_provider(krate.span); + let snippet_provider = self.parse_sess.snippet_provider(krate.spans.inner_span); self.file_map.insert( root_filename, diff --git a/src/parse/parser.rs b/src/parse/parser.rs index f0944a88d2f..268c72649a6 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -113,7 +113,7 @@ pub(crate) fn parse_file_as_module( let result = catch_unwind(AssertUnwindSafe(|| { let mut parser = new_parser_from_file(sess.inner(), path, Some(span)); match parser.parse_mod(&TokenKind::Eof) { - Ok(result) => Some(result), + Ok((a, i, spans)) => Some((a, i, spans.inner_span)), Err(mut e) => { e.emit(); if sess.can_reset_errors() { diff --git a/src/visitor.rs b/src/visitor.rs index 0177689958a..3ebfa551d1c 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -915,7 +915,11 @@ fn format_mod( let ident_str = rewrite_ident(&self.get_context(), ident).to_owned(); self.push_str(&ident_str); - if let ast::ModKind::Loaded(ref items, ast::Inline::Yes, inner_span) = mod_kind { + if let ast::ModKind::Loaded(ref items, ast::Inline::Yes, ref spans) = mod_kind { + let ast::ModSpans { + inner_span, + inject_use_span: _, + } = *spans; match self.config.brace_style() { BraceStyle::AlwaysNextLine => { let indent_str = self.block_indent.to_string_with_newline(self.config);