ast: Fix module path resolution for sibling modules in root#4406
ast: Fix module path resolution for sibling modules in root#4406P-E-P merged 1 commit intoRust-GCC:masterfrom
Conversation
|
@P-E-P ANY ISSUES , the bot removed the PR from merge queue, i guess have to make some modification accordingly with respect to your new PR that was added ? |
Yes I forgot about it again; you need to add |
16b7a99 to
1056418
Compare
|
@P-E-P Should be GTG? |
1056418 to
76972ea
Compare
|
You could use something that looks like the following: In I haven't tested it so you'll have to experiment a bit but this could do the trick |
Currently, the compiler fails to resolve module paths when a file in the root directory (e.g. 'bar.rs') attempts to load a sibling module (e.g. 'foo.rs') if a 'bar/' directory does not exist. The compiler incorrectly assumes that if 'bar.rs' is not 'mod.rs', it must look exclusively in a subdirectory. This patch adds a fallback mechanism in 'Module::process_file_path'. If the subdirectory search fails, it strips the implicit subdirectory and attempts to resolve the module in the parent directory, consistent with Rust 2018 path rules. Fixes Rust-GCC#4402 gcc/rust/ChangeLog: * ast/rust-ast.cc (Module::process_file_path): Add fallback search for sibling modules when subdirectory search fails. gcc/testsuite/ChangeLog: * rust/compile/issue-4402.rs: New test. * rust/compile/issue_4402_foo.rs: New test. * rust/compile/compile.exp:Ignore issue_4402_foo.rs Signed-off-by: Harishankar <[email protected]>
Head branch was pushed to by a user without write access
76972ea to
a3b9e54
Compare
|
@P-E-P I think it worked !! No failures when i tested it out locally |
Currently, the compiler fails to resolve module paths when a file in the root directory (e.g. 'bar.rs') attempts to load a sibling module (e.g. 'foo.rs') if a 'bar/' directory does not exist. The compiler incorrectly assumes that if 'bar.rs' is not 'mod.rs', it must look exclusively in a subdirectory.
This patch adds a fallback mechanism in 'Module::process_file_path'. If the subdirectory search fails, it strips the implicit subdirectory and attempts to resolve the module in the parent directory, consistent with Rust 2018 path rules.
Fixes #4402
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog:
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
make check-rustpasses locallyclang-formatgcc/testsuite/rust/Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
*Please write a comment explaining your change. This is the message
that will be part of the merge commit.