Associate multiple with a crate too.

This commit is contained in:
Felix S. Klock II
2022-03-03 18:45:25 -05:00
parent e9035f7bef
commit b82795244e
17 changed files with 28 additions and 27 deletions

View File

@@ -12,7 +12,7 @@ use rustc_ast::token;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::visit::{self, AssocCtxt, Visitor};
use rustc_ast::{AssocItemKind, AstLike, AstLikeWrapper, AttrStyle, ExprKind, ForeignItemKind};
use rustc_ast::{Inline, ItemKind, MacArgs, MacStmtStyle, MetaItemKind, ModKind, ModSpans};
use rustc_ast::{Inline, ItemKind, MacArgs, MacStmtStyle, MetaItemKind, ModKind};
use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind};
use rustc_ast_pretty::pprust;
use rustc_data_structures::map_in_place::MapInPlace;
@@ -364,7 +364,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
pub fn expand_crate(&mut self, krate: ast::Crate) -> ast::Crate {
let file_path = match self.cx.source_map().span_to_filename(krate.span) {
let file_path = match self.cx.source_map().span_to_filename(krate.spans.inner_span) {
FileName::Real(name) => name
.into_local_path()
.expect("attempting to resolve a file path in an external file"),
@@ -1091,7 +1091,7 @@ impl InvocationCollectorNode for P<ast::Item> {
ModKind::Unloaded => {
// We have an outline `mod foo;` so we need to parse the file.
let old_attrs_len = attrs.len();
let ParsedExternalMod { items, inner_span, file_path, dir_path, dir_ownership } =
let ParsedExternalMod { items, spans, file_path, dir_path, dir_ownership } =
parse_external_mod(
&ecx.sess,
ident,
@@ -1112,7 +1112,7 @@ impl InvocationCollectorNode for P<ast::Item> {
);
}
*mod_kind = ModKind::Loaded(items, Inline::No, ModSpans { inner_span });
*mod_kind = ModKind::Loaded(items, Inline::No, spans);
node.attrs = attrs;
if node.attrs.len() > old_attrs_len {
// If we loaded an out-of-line module and added some inner attributes,