File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
tests/ui/compile-fail/pin_data Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,13 @@ pub(crate) fn pin_data(
7979 . map ( |field| {
8080 let len = field. attrs . len ( ) ;
8181 field. attrs . retain ( |a| !a. path ( ) . is_ident ( "pin" ) ) ;
82- ( len != field. attrs . len ( ) , & * field)
82+ let diff = len - field. attrs . len ( ) ;
83+ if diff > 1 {
84+ return Err ( dcx. error ( field, "#[pin] attribute set twice" ) ) ;
85+ }
86+ Ok ( ( diff > 0 , & * field) )
8387 } )
84- . collect ( ) ;
88+ . collect :: < Result < _ , _ > > ( ) ? ;
8589
8690 for ( pinned, field) in & fields {
8791 if !pinned && is_phantom_pinned ( & field. ty ) {
Original file line number Diff line number Diff line change 1+ use pin_init:: * ;
2+
3+ #[ pin_data]
4+ struct Foo {
5+ #[ pin]
6+ #[ pin]
7+ a : usize ,
8+ }
9+
10+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: #[pin] attribute set twice
2+ --> tests/ui/compile-fail/pin_data/twice_pin.rs:7:5
3+ |
4+ 7 | a: usize,
5+ | ^^^^^^^^
You can’t perform that action at this time.
0 commit comments