]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/lint/lint-unsafe-code.rs
Adjust `#[no_mangle]`-related checks and lints for `impl` items
[rust.git] / src / test / ui / lint / lint-unsafe-code.rs
index 4ac02b51f62fec0e687cab1a9d75eeec6cac2c60..c30f21bbf8fb17725e66c44bbede04bd849aa449 100644 (file)
@@ -31,9 +31,33 @@ macro_rules! unsafe_in_macro {
 #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` function
 #[no_mangle] static FOO: u32 = 5; //~ ERROR: declaration of a `no_mangle` static
 
+trait AssocFnTrait {
+    fn foo();
+}
+
+struct AssocFnFoo;
+
+impl AssocFnFoo {
+    #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` method
+}
+
+impl AssocFnTrait for AssocFnFoo {
+    #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` method
+}
+
 #[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a function with `export_name`
 #[export_name = "BAR"] static BAR: u32 = 5; //~ ERROR: declaration of a static with `export_name`
 
+struct AssocFnBar;
+
+impl AssocFnBar {
+    #[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a method with `export_name`
+}
+
+impl AssocFnTrait for AssocFnBar {
+    #[export_name = "bar"] fn foo() {} //~ ERROR: declaration of a method with `export_name`
+}
+
 unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function
 unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait
 unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait