1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
//@ run-rustfix
#![allow(dead_code, elided_named_lifetimes)]
#![deny(no_mangle_generic_items)]
#[no_mangle]
pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub extern "C" fn bar<T>() {} //~ 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 {
#[no_mangle]
pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub extern "C" fn bar<T>() {} //~ 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<T>();
extern "C" fn bar<T>();
fn baz(x: &i32) -> &i32;
fn qux<'a>(x: &'a i32) -> &i32;
}
impl Trait1 for Foo {
#[no_mangle]
fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
extern "C" fn bar<T>() {} //~ 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<T> {
fn foo();
fn foo2<U>();
extern "C" fn bar();
fn baz(x: &i32) -> &i32;
fn qux<'a>(x: &'a i32) -> &i32;
}
impl<T> Trait2<T> for Foo {
#[no_mangle]
fn foo() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
fn foo2<U>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
fn baz(x: &i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
fn qux<'a>(x: &'a i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled
}
pub struct Bar<T>(#[allow(dead_code)] T);
impl<T> Bar<T> {
#[no_mangle]
pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub fn baz<U>() {} //~ ERROR functions generic over types or consts must be mangled
}
impl Bar<i32> {
#[no_mangle]
pub fn qux() {}
}
trait Trait3 {
fn foo();
extern "C" fn bar();
fn baz<U>();
}
impl<T> Trait3 for Bar<T> {
#[no_mangle]
fn foo() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
fn baz<U>() {} //~ ERROR functions generic over types or consts must be mangled
}
pub struct Baz<'a>(#[allow(dead_code)] &'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<i32> {
#[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<T> {
fn foo();
}
impl Trait5<i32> for Foo {
#[no_mangle]
fn foo() {}
}
impl Trait5<i32> for Bar<i32> {
#[no_mangle]
fn foo() {}
}
fn main() {}
|