mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 17:13:48 +00:00
Merge #4941
4941: Simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
1e35c74055
@ -119,13 +119,6 @@ impl Default for ModuleOrigin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ModuleOrigin {
|
impl ModuleOrigin {
|
||||||
pub(crate) fn not_sure_file(file: Option<FileId>, declaration: AstId<ast::Module>) -> Self {
|
|
||||||
match file {
|
|
||||||
None => ModuleOrigin::Inline { definition: declaration },
|
|
||||||
Some(definition) => ModuleOrigin::File { declaration, definition },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn declaration(&self) -> Option<AstId<ast::Module>> {
|
fn declaration(&self) -> Option<AstId<ast::Module>> {
|
||||||
match self {
|
match self {
|
||||||
ModuleOrigin::File { declaration: module, .. }
|
ModuleOrigin::File { declaration: module, .. }
|
||||||
|
@ -825,7 +825,10 @@ impl ModCollector<'_, '_> {
|
|||||||
let modules = &mut self.def_collector.def_map.modules;
|
let modules = &mut self.def_collector.def_map.modules;
|
||||||
let res = modules.alloc(ModuleData::default());
|
let res = modules.alloc(ModuleData::default());
|
||||||
modules[res].parent = Some(self.module_id);
|
modules[res].parent = Some(self.module_id);
|
||||||
modules[res].origin = ModuleOrigin::not_sure_file(definition, declaration);
|
modules[res].origin = match definition {
|
||||||
|
None => ModuleOrigin::Inline { definition: declaration },
|
||||||
|
Some(definition) => ModuleOrigin::File { declaration, definition },
|
||||||
|
};
|
||||||
for (name, mac) in modules[self.module_id].scope.collect_legacy_macros() {
|
for (name, mac) in modules[self.module_id].scope.collect_legacy_macros() {
|
||||||
modules[res].scope.define_legacy_macro(name, mac)
|
modules[res].scope.define_legacy_macro(name, mac)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user