]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs
Stabilize `param_attrs` in Rust 1.39.0
[rust.git] / src / test / ui / rfc-2565-param-attrs / param-attrs-allowed.rs
index e796e37bbaa4524460f76e36cba87244594ab500..1217f89cb316863d0ea3e802faed1d591c776353 100644 (file)
+// check-pass
 // compile-flags: --cfg something
-// build-pass (FIXME(62277): could be check-pass?)
 
-#![feature(param_attrs)]
+#![deny(unused_mut)]
 
 extern "C" {
     fn ffi(
-        #[allow(C)] a: i32,
+        #[allow(unused_mut)] a: i32,
         #[cfg(something)] b: i32,
         #[cfg_attr(something, cfg(nothing))] c: i32,
-        #[deny(C)] d: i32,
-        #[forbid(C)] #[warn(C)] ...
+        #[deny(unused_mut)] d: i32,
+        #[forbid(unused_mut)] #[warn(unused_mut)] ...
     );
 }
 
 type FnType = fn(
-    #[allow(C)] a: i32,
+    #[allow(unused_mut)] a: i32,
     #[cfg(something)] b: i32,
     #[cfg_attr(something, cfg(nothing))] c: i32,
-    #[deny(C)] d: i32,
-    #[forbid(C)] #[warn(C)] e: i32
+    #[deny(unused_mut)] d: i32,
+    #[forbid(unused_mut)] #[warn(unused_mut)] e: i32
 );
 
 pub fn foo(
-    #[allow(C)] a: i32,
+    #[allow(unused_mut)] a: i32,
     #[cfg(something)] b: i32,
     #[cfg_attr(something, cfg(nothing))] c: i32,
-    #[deny(C)] d: i32,
-    #[forbid(C)] #[warn(C)] e: i32
+    #[deny(unused_mut)] d: i32,
+    #[forbid(unused_mut)] #[warn(unused_mut)] _e: i32
 ) {}
 
-// self, &self and &mut self
+// self
 
 struct SelfStruct {}
 impl SelfStruct {
     fn foo(
-        #[allow(C)] self,
+        #[allow(unused_mut)] self,
         #[cfg(something)] a: i32,
         #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
+        #[deny(unused_mut)] b: i32,
     ) {}
 }
 
 struct RefStruct {}
 impl RefStruct {
     fn foo(
-        #[allow(C)] &self,
+        #[allow(unused_mut)] &self,
         #[cfg(something)] a: i32,
         #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
+        #[deny(unused_mut)] b: i32,
     ) {}
 }
 trait RefTrait {
     fn foo(
-        #[forbid(C)] &self,
-        #[warn(C)] a: i32
+        #[forbid(unused_mut)] &self,
+        #[warn(unused_mut)] a: i32
     ) {}
 }
 impl RefTrait for RefStruct {
     fn foo(
-        #[forbid(C)] &self,
-        #[warn(C)] a: i32
-    ) {}
-}
-
-struct MutStruct {}
-impl MutStruct {
-    fn foo(
-        #[allow(C)] &mut self,
-        #[cfg(something)] a: i32,
-        #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
-    ) {}
-}
-trait MutTrait {
-    fn foo(
-        #[forbid(C)] &mut self,
-        #[warn(C)] a: i32
-    ) {}
-}
-impl MutTrait for MutStruct {
-    fn foo(
-        #[forbid(C)] &mut self,
-        #[warn(C)] a: i32
-    ) {}
-}
-
-// self: Self, self: &Self and self: &mut Self
-
-struct NamedSelfSelfStruct {}
-impl NamedSelfSelfStruct {
-    fn foo(
-        #[allow(C)] self: Self,
-        #[cfg(something)] a: i32,
-        #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
-    ) {}
-}
-
-struct NamedSelfRefStruct {}
-impl NamedSelfRefStruct {
-    fn foo(
-        #[allow(C)] self: &Self,
-        #[cfg(something)] a: i32,
-        #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
-    ) {}
-}
-trait NamedSelfRefTrait {
-    fn foo(
-        #[forbid(C)] self: &Self,
-        #[warn(C)] a: i32
-    ) {}
-}
-impl NamedSelfRefTrait for NamedSelfRefStruct {
-    fn foo(
-        #[forbid(C)] self: &Self,
-        #[warn(C)] a: i32
-    ) {}
-}
-
-struct NamedSelfMutStruct {}
-impl NamedSelfMutStruct {
-    fn foo(
-        #[allow(C)] self: &mut Self,
-        #[cfg(something)] a: i32,
-        #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
-    ) {}
-}
-trait NamedSelfMutTrait {
-    fn foo(
-        #[forbid(C)] self: &mut Self,
-        #[warn(C)] a: i32
-    ) {}
-}
-impl NamedSelfMutTrait for NamedSelfMutStruct {
-    fn foo(
-        #[forbid(C)] self: &mut Self,
-        #[warn(C)] a: i32
-    ) {}
-}
-
-// &'a self and &'a mut self
-
-struct NamedLifetimeRefStruct {}
-impl NamedLifetimeRefStruct {
-    fn foo<'a>(
-        #[allow(C)] self: &'a Self,
-        #[cfg(something)] a: i32,
-        #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
-    ) {}
-}
-trait NamedLifetimeRefTrait {
-    fn foo<'a>(
-        #[forbid(C)] &'a self,
-        #[warn(C)] a: i32
-    ) {}
-}
-impl NamedLifetimeRefTrait for NamedLifetimeRefStruct {
-    fn foo<'a>(
-        #[forbid(C)] &'a self,
-        #[warn(C)] a: i32
-    ) {}
-}
-
-struct NamedLifetimeMutStruct {}
-impl NamedLifetimeMutStruct {
-    fn foo<'a>(
-        #[allow(C)] self: &'a mut Self,
-        #[cfg(something)] a: i32,
-        #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
-    ) {}
-}
-trait NamedLifetimeMutTrait {
-    fn foo<'a>(
-        #[forbid(C)] &'a mut self,
-        #[warn(C)] a: i32
-    ) {}
-}
-impl NamedLifetimeMutTrait for NamedLifetimeMutStruct {
-    fn foo<'a>(
-        #[forbid(C)] &'a mut self,
-        #[warn(C)] a: i32
+        #[forbid(unused_mut)] &self,
+        #[warn(unused_mut)] a: i32
     ) {}
 }
 
@@ -192,22 +68,22 @@ fn foo<'a>(
 struct BoxSelfStruct {}
 impl BoxSelfStruct {
     fn foo(
-        #[allow(C)] self: Box<Self>,
+        #[allow(unused_mut)] self: Box<Self>,
         #[cfg(something)] a: i32,
         #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] b: i32,
+        #[deny(unused_mut)] b: i32,
     ) {}
 }
 trait BoxSelfTrait {
     fn foo(
-        #[forbid(C)] self: Box<Self>,
-        #[warn(C)] a: i32
+        #[forbid(unused_mut)] self: Box<Self>,
+        #[warn(unused_mut)] a: i32
     ) {}
 }
 impl BoxSelfTrait for BoxSelfStruct {
     fn foo(
-        #[forbid(C)] self: Box<Self>,
-        #[warn(C)] a: i32
+        #[forbid(unused_mut)] self: Box<Self>,
+        #[warn(unused_mut)] a: i32
     ) {}
 }
 
@@ -216,10 +92,10 @@ fn main() {
     let _: fn(_, _, _, _) = foo;
     let _: FnType = |_, _, _, _| {};
     let c = |
-        #[allow(C)] a: u32,
+        #[allow(unused_mut)] a: u32,
         #[cfg(something)] b: i32,
         #[cfg_attr(something, cfg(nothing))]
-        #[deny(C)] c: i32,
+        #[deny(unused_mut)] c: i32,
     | {};
     let _ = c(1, 2);
 }