diff options
| author | bors <bors@rust-lang.org> | 2024-03-16 04:35:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-16 04:35:02 +0000 |
| commit | c563f2ee799b285067124b516ce99f26063f8351 (patch) | |
| tree | 91895e6faf0242cc634ab7041171ae4b603052fc /tests/codegen | |
| parent | c03ea3dfd907e7dc6305ebf20c94f3a1f1d9fed7 (diff) | |
| parent | 746e4eff263527ba8960552ea62db11ab9821644 (diff) | |
| download | rust-c563f2ee799b285067124b516ce99f26063f8351.tar.gz rust-c563f2ee799b285067124b516ce99f26063f8351.zip | |
Auto merge of #122371 - oli-obk:visit_nested_body, r=tmiasko
Stop walking the bodies of statics for reachability, and evaluate them instead cc `@saethlin` `@RalfJung` cc #119214 This reuses the `DefIdVisitor` from `rustc_privacy`, because they basically try to do the same thing. This PR's changes can probably be extended to constants, too, but let's tackle that separately, it's likely more involved.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/dont_codegen_private_const_fn_only_used_in_const_eval.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/codegen/dont_codegen_private_const_fn_only_used_in_const_eval.rs b/tests/codegen/dont_codegen_private_const_fn_only_used_in_const_eval.rs new file mode 100644 index 00000000000..eeeaebe52dd --- /dev/null +++ b/tests/codegen/dont_codegen_private_const_fn_only_used_in_const_eval.rs @@ -0,0 +1,10 @@ +//! This test checks that we do not monomorphize functions that are only +//! used to evaluate static items, but never used in runtime code. + +//@compile-flags: --crate-type=lib -Copt-level=0 + +const fn foo() {} + +pub static FOO: () = foo(); + +// CHECK-NOT: define{{.*}}foo{{.*}} |
