From f807b9cad43bf05870adb0b618ef6e6b51a4b0d4 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 25 Nov 2024 14:24:21 +0100 Subject: [PATCH] Prepend crate name to functions with nr2 gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Prepend crate name to function's ir name. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove passing tests from exclude list. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/backend/rust-compile-base.cc | 11 ++++++++++- gcc/testsuite/rust/compile/nr2/exclude | 6 ------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index d272374cadc3..e39c2a993257 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -25,7 +25,8 @@ #include "rust-compile-type.h" #include "rust-constexpr.h" #include "rust-diagnostics.h" -#include "rust-expr.h" // for AST::AttrInputLiteral +#include "rust-expr.h" // for AST::AttrInputLiteral +#include "rust-hir-map.h" #include "rust-macro.h" // for AST::MetaNameValueStr #include "rust-hir-path-probe.h" #include "rust-type-util.h" @@ -39,6 +40,9 @@ #include "tree.h" #include "print-tree.h" +// rust-name-resolution-2.0 +#include "options.h" + namespace Rust { namespace Compile { @@ -667,6 +671,11 @@ HIRCompileBase::compile_function ( } std::string asm_name = fn_name; + auto &mappings = Analysis::Mappings::get (); + + if (flag_name_resolution_2_0) + ir_symbol_name = mappings.get_current_crate_name () + "::" + ir_symbol_name; + unsigned int flags = 0; tree fndecl = Backend::function (compiled_fn_type, ir_symbol_name, "" /* asm_name */, flags, locus); diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 6c589e4ab4e5..b282f05637d2 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -1,7 +1,3 @@ -attr-mismatch-crate-name.rs -attr_deprecated.rs -attr_deprecated_2.rs -bad=file-name.rs bounds1.rs break-rust2.rs break-rust3.rs @@ -45,7 +41,6 @@ generics6.rs generics8.rs generics9.rs if_let_expr.rs -infer-crate-name.rs issue-1019.rs issue-1031.rs issue-1034.rs @@ -156,7 +151,6 @@ redef_error6.rs self-path1.rs self-path2.rs sizeof-stray-infer-var-bug.rs -specify-crate-name.rs stmt_with_block_dot.rs struct-expr-parse.rs traits1.rs