Resolve lang items from extern crate#4694
Open
P-E-P wants to merge 3 commits into
Open
Conversation
The metadata format will likely change over the upcoming month and right now it doesn't support trait impl. This commit simplifies metadata export by dumping the whole AST within metadatas. This is slower but it should be more complete and correct. gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (CollectLangItems::visit): Visit extern crate's content when collecting lang items. * ast/rust-collect-lang-items.h: Add function protototype. * metadata/rust-export-metadata.cc (ExportContext::push_module_scope): Remove. (ExportContext::emit_crate): Add a function to export the whole crate. (ExportContext::pop_module_scope): Remove. (ExportContext::emit_trait): Likewise. (ExportContext::emit_use_declaration): Likewise. (ExportContext::emit_function): Likewise. (ExportContext::emit_extern_block): Likewise. (ExportContext::emit_module): Likewise. (class ExportVisItems): Likewise. (PublicInterface::gather_export_data): Dump the AST. * metadata/rust-export-metadata.h: Update prototypes. gcc/testsuite/ChangeLog: * rust/link/simple_function_0.rs: Remove bogus match. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Those metadata files are meant to be read by the parser and not by humans Although it may help during compiler development, they could still get expanded by any rust pretty printer. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::Dump): Add a default indentation level of four and dump newlines. * ast/rust-ast-dump.h: Add newline and indentation level configuration options. * metadata/rust-export-metadata.cc (ExportContext::emit_crate): Do not export indentation and newlines. * rust-session-manager.cc (Session::dump_ast_pretty_internal): Use an indentation level of 4 and dump newlines. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Using the local path for the Clone trait cannot be used with the core library. This broke most test that "emulate core" with a Clone trait placed outside a "clone" module. gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (DeriveClone::clone_call): Use the canonical path to Clone. gcc/testsuite/ChangeLog: * rust/compile/derive_clone_enum2.rs: Fix test with a clone module to mimic the core library. * rust/compile/derive_clone_enum3.rs: Likewise. * rust/compile/issue-3139-1.rs: Likewise. * rust/compile/issue-3144.rs: Likewise. * rust/execute/torture/derive_clone_enum1.rs: Likewise. * rust/execute/torture/derive_macro3.rs: Likewise. * rust/execute/torture/derive_macro4.rs: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
CohenArthur
reviewed
Jul 8, 2026
| Dump, | ||
| Hide, | ||
| } newline; | ||
| size_t indentation; |
Member
There was a problem hiding this comment.
I think we should have an enum here as well
enum class Indentation {
None,
Spaces4,
}or something like that if we want more option. If we just want standard implementation then I would do
enum class Indentation {
None,
Standard,
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've decided we should keep the current behavior of not visiting extern crate through their extern crate declaration and have an exception for the lang item collector.