File tree 2 files changed +45
-2
lines changed
libsyntax/ext/deriving/generic
2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
335
335
impl < ' a > TraitDef < ' a > {
336
336
pub fn expand ( & self ,
337
337
cx : & mut ExtCtxt ,
338
- _mitem : & ast:: MetaItem ,
338
+ mitem : & ast:: MetaItem ,
339
339
item : & ast:: Item ,
340
340
push: |P < ast:: Item > |) {
341
341
let newitem = match item. node {
@@ -351,7 +351,10 @@ impl<'a> TraitDef<'a> {
351
351
item. ident ,
352
352
generics)
353
353
}
354
- _ => return
354
+ _ => {
355
+ cx. span_err ( mitem. span , "`deriving` may only be applied to structs and enums" ) ;
356
+ return ;
357
+ }
355
358
} ;
356
359
// Keep the lint attributes of the previous item to control how the
357
360
// generated implementations are linted
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ allow( dead_code) ]
12
+
13
+ struct S ;
14
+
15
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
16
+ trait T { }
17
+
18
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
19
+ impl S { }
20
+
21
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
22
+ impl T for S { }
23
+
24
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
25
+ static s: uint = 0 u;
26
+
27
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
28
+ const c: uint = 0 u;
29
+
30
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
31
+ mod m { }
32
+
33
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
34
+ extern "C" { }
35
+
36
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
37
+ type A = uint ;
38
+
39
+ #[ deriving( PartialEq ) ] //~ ERROR: `deriving` may only be applied to structs and enums
40
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments