1
Fork 0

refactor: prepare to associate multiple spans with a module.

This commit is contained in:
Felix S. Klock II 2022-01-20 11:06:45 -05:00
parent 4566094913
commit e9035f7bef
9 changed files with 30 additions and 14 deletions

View file

@ -12,8 +12,8 @@ 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, NestedMetaItem};
use rustc_ast::{NodeId, PatKind, StmtKind, TyKind};
use rustc_ast::{Inline, ItemKind, MacArgs, MacStmtStyle, MetaItemKind, ModKind, ModSpans};
use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind};
use rustc_ast_pretty::pprust;
use rustc_data_structures::map_in_place::MapInPlace;
use rustc_data_structures::sync::Lrc;
@ -1112,7 +1112,7 @@ impl InvocationCollectorNode for P<ast::Item> {
);
}
*mod_kind = ModKind::Loaded(items, Inline::No, inner_span);
*mod_kind = ModKind::Loaded(items, Inline::No, ModSpans { inner_span });
node.attrs = attrs;
if node.attrs.len() > old_attrs_len {
// If we loaded an out-of-line module and added some inner attributes,

View file

@ -1,6 +1,6 @@
use crate::base::ModuleData;
use rustc_ast::ptr::P;
use rustc_ast::{token, Attribute, Inline, Item};
use rustc_ast::{token, Attribute, Inline, Item, ModSpans};
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorGuaranteed};
use rustc_parse::new_parser_from_file;
use rustc_parse::validate_attr;
@ -69,7 +69,7 @@ crate fn parse_external_mod(
(items, inner_span, mp.file_path)
};
// (1) ...instead, we return a dummy module.
let (items, inner_span, file_path) =
let (items, ModSpans { inner_span }, file_path) =
result.map_err(|err| err.report(sess, span)).unwrap_or_default();
// Extract the directory path for submodules of the module.