rust/tests/codegen-units/item-collection/cross-crate-trait-method.rs
Tomasz Miąsko 8c8225afe8 Remove mono item collection strategy override from -Zprint-mono-items
Previously `-Zprint-mono-items` would override the mono item collection
strategy. When debugging one doesn't want to change the behaviour, so
this was counter productive. Additionally, the produced behaviour was
artificial and might never arise without using the option in the first
place (`-Zprint-mono-items=eager` without `-Clink-dead-code`).  Finally,
the option was incorrectly marked as `UNTRACKED`.

Resolve those issues, by turning `-Zprint-mono-items` into a boolean
flag that prints results of mono item collection without changing the
behaviour of mono item collection.

For codegen-units test incorporate `-Zprint-mono-items` flag directly
into compiletest tool.

Test changes are mechanical. `-Zprint-mono-items=lazy` was removed
without additional changes, and `-Zprint-mono-items=eager` was turned
into `-Clink-dead-code`.  Linking dead code disables internalization, so
tests have been updated accordingly.
2025-05-09 12:19:09 +02:00

49 lines
2.3 KiB
Rust

//@ compile-flags:-Clink-dead-code -Zinline-mir=no -Copt-level=0
#![deny(dead_code)]
#![crate_type = "lib"]
//@ aux-build:cgu_export_trait_method.rs
extern crate cgu_export_trait_method;
use cgu_export_trait_method::Trait;
//~ MONO_ITEM fn start
#[no_mangle]
pub fn start(_: isize, _: *const *const u8) -> isize {
// The object code of these methods is contained in the external crate, so
// calling them should *not* introduce codegen items in the current crate.
let _: (u32, u32) = Trait::without_default_impl(0);
let _: (char, u32) = Trait::without_default_impl(0);
// Currently, no object code is generated for trait methods with default
// implementations, unless they are actually called from somewhere. Therefore
// we cannot import the implementations and have to create our own inline.
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl
let _ = Trait::with_default_impl(0u32);
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl
let _ = Trait::with_default_impl('c');
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str>
let _ = Trait::with_default_impl_generic(0u32, "abc");
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool>
let _ = Trait::with_default_impl_generic(0u32, false);
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl_generic::<i16>
let _ = Trait::with_default_impl_generic('x', 1i16);
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl_generic::<i32>
let _ = Trait::with_default_impl_generic('y', 0i32);
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::without_default_impl_generic::<char>
let _: (u32, char) = Trait::without_default_impl_generic('c');
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::without_default_impl_generic::<bool>
let _: (u32, bool) = Trait::without_default_impl_generic(false);
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::without_default_impl_generic::<char>
let _: (char, char) = Trait::without_default_impl_generic('c');
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::without_default_impl_generic::<bool>
let _: (char, bool) = Trait::without_default_impl_generic(false);
0
}