From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../item-collection/cross-crate-trait-method.rs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/test/codegen-units/item-collection/cross-crate-trait-method.rs (limited to 'src/test/codegen-units/item-collection/cross-crate-trait-method.rs') diff --git a/src/test/codegen-units/item-collection/cross-crate-trait-method.rs b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs new file mode 100644 index 000000000..dc0984c8a --- /dev/null +++ b/src/test/codegen-units/item-collection/cross-crate-trait-method.rs @@ -0,0 +1,50 @@ +// compile-flags:-Zprint-mono-items=eager + +#![deny(dead_code)] +#![feature(start)] + +// aux-build:cgu_export_trait_method.rs +extern crate cgu_export_trait_method; + +use cgu_export_trait_method::Trait; + +//~ MONO_ITEM fn start +#[start] +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 ::with_default_impl + let _ = Trait::with_default_impl(0u32); + //~ MONO_ITEM fn ::with_default_impl + let _ = Trait::with_default_impl('c'); + + + + //~ MONO_ITEM fn ::with_default_impl_generic::<&str> + let _ = Trait::with_default_impl_generic(0u32, "abc"); + //~ MONO_ITEM fn ::with_default_impl_generic:: + let _ = Trait::with_default_impl_generic(0u32, false); + + //~ MONO_ITEM fn ::with_default_impl_generic:: + let _ = Trait::with_default_impl_generic('x', 1i16); + //~ MONO_ITEM fn ::with_default_impl_generic:: + let _ = Trait::with_default_impl_generic('y', 0i32); + + //~ MONO_ITEM fn ::without_default_impl_generic:: + let _: (u32, char) = Trait::without_default_impl_generic('c'); + //~ MONO_ITEM fn ::without_default_impl_generic:: + let _: (u32, bool) = Trait::without_default_impl_generic(false); + + //~ MONO_ITEM fn ::without_default_impl_generic:: + let _: (char, char) = Trait::without_default_impl_generic('c'); + //~ MONO_ITEM fn ::without_default_impl_generic:: + let _: (char, bool) = Trait::without_default_impl_generic(false); + + 0 +} -- cgit v1.2.3