mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 14:11:05 +01:00
Clean up node kind information for namespaces (#5120)
This flows out of #5084 and trying to reduce UnsafeMake use. It turns out imports and namespaces were using unexpected node kinds (previously ImportIntroducer instead of ImportDecl, for example). This fixes and adds validation. I was uncertain about whether to just remove the is_convertible check, since I don't see it as motivating creation of a conversion between NodeIdOneOf types. So I've just left a TODO for now.
This commit is contained in:
@@ -99,8 +99,9 @@ static auto AddNamespace(Context& context, PackageNameId cpp_package_id,
|
||||
auto& import_cpps = context.sem_ir().import_cpps();
|
||||
import_cpps.Reserve(imports.size());
|
||||
for (const Parse::Tree::PackagingNames& import : imports) {
|
||||
import_cpps.Add(
|
||||
{.node_id = import.node_id, .library_id = import.library_id});
|
||||
import_cpps.Add({.node_id = context.parse_tree().As<Parse::ImportDeclId>(
|
||||
import.node_id),
|
||||
.library_id = import.library_id});
|
||||
}
|
||||
|
||||
return AddImportNamespaceToScope(
|
||||
@@ -111,7 +112,10 @@ static auto AddNamespace(Context& context, PackageNameId cpp_package_id,
|
||||
/*diagnose_duplicate_namespace=*/false,
|
||||
[&]() {
|
||||
return AddInst<SemIR::ImportCppDecl>(
|
||||
context, imports.front().node_id, {});
|
||||
context,
|
||||
context.parse_tree().As<Parse::ImportDeclId>(
|
||||
imports.front().node_id),
|
||||
{});
|
||||
})
|
||||
.add_result.name_scope_id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user