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 --- src/test/ui/generics/generic-no-mangle.fixed | 159 +++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 src/test/ui/generics/generic-no-mangle.fixed (limited to 'src/test/ui/generics/generic-no-mangle.fixed') diff --git a/src/test/ui/generics/generic-no-mangle.fixed b/src/test/ui/generics/generic-no-mangle.fixed new file mode 100644 index 000000000..501acb6e1 --- /dev/null +++ b/src/test/ui/generics/generic-no-mangle.fixed @@ -0,0 +1,159 @@ +// run-rustfix + +#![deny(no_mangle_generic_items)] + + +pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled + + +pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled + +#[no_mangle] +pub fn baz(x: &i32) -> &i32 { x } + +#[no_mangle] +pub fn qux<'a>(x: &'a i32) -> &i32 { x } + +pub struct Foo; + +impl Foo { + + pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled + + + pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled + + #[no_mangle] + pub fn baz(x: &i32) -> &i32 { x } + + #[no_mangle] + pub fn qux<'a>(x: &'a i32) -> &i32 { x } +} + +trait Trait1 { + fn foo(); + extern "C" fn bar(); + fn baz(x: &i32) -> &i32; + fn qux<'a>(x: &'a i32) -> &i32; +} + +impl Trait1 for Foo { + + fn foo() {} //~ ERROR functions generic over types or consts must be mangled + + + extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled + + #[no_mangle] + fn baz(x: &i32) -> &i32 { x } + + #[no_mangle] + fn qux<'a>(x: &'a i32) -> &i32 { x } +} + +trait Trait2 { + fn foo(); + fn foo2(); + extern "C" fn bar(); + fn baz(x: &i32) -> &i32; + fn qux<'a>(x: &'a i32) -> &i32; +} + +impl Trait2 for Foo { + + fn foo() {} //~ ERROR functions generic over types or consts must be mangled + + + fn foo2() {} //~ ERROR functions generic over types or consts must be mangled + + + extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled + + + fn baz(x: &i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled + + + fn qux<'a>(x: &'a i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled +} + +pub struct Bar(#[allow(unused_tuple_struct_fields)] T); + +impl Bar { + + pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled + + + pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled + + + pub fn baz() {} //~ ERROR functions generic over types or consts must be mangled +} + +impl Bar { + #[no_mangle] + pub fn qux() {} +} + +trait Trait3 { + fn foo(); + extern "C" fn bar(); + fn baz(); +} + +impl Trait3 for Bar { + + fn foo() {} //~ ERROR functions generic over types or consts must be mangled + + + extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled + + + fn baz() {} //~ ERROR functions generic over types or consts must be mangled +} + +pub struct Baz<'a>(#[allow(unused_tuple_struct_fields)] &'a i32); + +impl<'a> Baz<'a> { + #[no_mangle] + pub fn foo() {} + + #[no_mangle] + pub fn bar<'b>(x: &'b i32) -> &i32 { x } +} + +trait Trait4 { + fn foo(); + fn bar<'a>(x: &'a i32) -> &i32; +} + +impl Trait4 for Bar { + #[no_mangle] + fn foo() {} + + #[no_mangle] + fn bar<'b>(x: &'b i32) -> &i32 { x } +} + +impl<'a> Trait4 for Baz<'a> { + #[no_mangle] + fn foo() {} + + #[no_mangle] + fn bar<'b>(x: &'b i32) -> &i32 { x } +} + +trait Trait5 { + fn foo(); +} + +impl Trait5 for Foo { + #[no_mangle] + fn foo() {} +} + +impl Trait5 for Bar { + #[no_mangle] + fn foo() {} +} + +fn main() {} -- cgit v1.2.3