Skip to content

Commit

Permalink
Prepend crate name to functions with nr2
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
P-E-P committed Nov 27, 2024
1 parent 8d40193 commit 79e4295
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 10 additions & 1 deletion gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -39,6 +40,9 @@
#include "tree.h"
#include "print-tree.h"

// rust-name-resolution-2.0
#include "options.h"

namespace Rust {
namespace Compile {

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79e4295

Please sign in to comment.