Associate multiple with a crate too.
This commit is contained in:
parent
e9035f7bef
commit
b82795244e
17 changed files with 28 additions and 27 deletions
|
@ -67,7 +67,7 @@ impl Annotatable {
|
|||
Annotatable::Param(ref p) => p.span,
|
||||
Annotatable::FieldDef(ref sf) => sf.span,
|
||||
Annotatable::Variant(ref v) => v.span,
|
||||
Annotatable::Crate(ref c) => c.span,
|
||||
Annotatable::Crate(ref c) => c.spans.inner_span,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -28,7 +28,7 @@ pub struct ModulePathSuccess {
|
|||
|
||||
crate struct ParsedExternalMod {
|
||||
pub items: Vec<P<Item>>,
|
||||
pub inner_span: Span,
|
||||
pub spans: ModSpans,
|
||||
pub file_path: PathBuf,
|
||||
pub dir_path: PathBuf,
|
||||
pub dir_ownership: DirOwnership,
|
||||
|
@ -69,13 +69,13 @@ crate fn parse_external_mod(
|
|||
(items, inner_span, mp.file_path)
|
||||
};
|
||||
// (1) ...instead, we return a dummy module.
|
||||
let (items, ModSpans { inner_span }, file_path) =
|
||||
let (items, spans, file_path) =
|
||||
result.map_err(|err| err.report(sess, span)).unwrap_or_default();
|
||||
|
||||
// Extract the directory path for submodules of the module.
|
||||
let dir_path = file_path.parent().unwrap_or(&file_path).to_owned();
|
||||
|
||||
ParsedExternalMod { items, inner_span, file_path, dir_path, dir_ownership }
|
||||
ParsedExternalMod { items, spans, file_path, dir_path, dir_ownership }
|
||||
}
|
||||
|
||||
crate fn mod_dir_path(
|
||||
|
|
|
@ -49,7 +49,7 @@ pub fn placeholder(
|
|||
AstFragmentKind::Crate => AstFragment::Crate(ast::Crate {
|
||||
attrs: Default::default(),
|
||||
items: Default::default(),
|
||||
span,
|
||||
spans: ast::ModSpans { inner_span: span, ..Default::default() },
|
||||
id,
|
||||
is_placeholder: true,
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue