21
21
//! as a `LintPass`.
22
22
//!
23
23
//! If you define a new `LintPass`, you will also need to add it to the
24
- //! `add_builtin_lints!()` invocation in `context.rs`. That macro
25
- //! requires a `Default` impl for your `LintPass` type.
24
+ //! `add_builtin!` or `add_builtin_with_new!` invocation in `context.rs`.
25
+ //! Use the former for unit-like structs and the latter for structs with
26
+ //! a `pub fn new()`.
26
27
27
28
use metadata:: csearch;
28
29
use middle:: def:: * ;
@@ -45,7 +46,6 @@ use std::u16;
45
46
use std:: u32;
46
47
use std:: u64;
47
48
use std:: u8;
48
- use std:: default:: Default ;
49
49
use syntax:: abi;
50
50
use syntax:: ast_map;
51
51
use syntax:: attr:: AttrMetaMethods ;
@@ -57,7 +57,6 @@ use syntax::{ast, ast_util, visit};
57
57
declare_lint ! ( while_true, Warn ,
58
58
"suggest using `loop { }` instead of `while true { }`" )
59
59
60
- #[ deriving( Default ) ]
61
60
pub struct WhileTrue ;
62
61
63
62
impl LintPass for WhileTrue {
@@ -90,7 +89,6 @@ impl LintPass for WhileTrue {
90
89
declare_lint ! ( unnecessary_typecast, Allow ,
91
90
"detects unnecessary type casts, that can be removed" )
92
91
93
- #[ deriving( Default ) ]
94
92
pub struct UnusedCasts ;
95
93
96
94
impl LintPass for UnusedCasts {
@@ -125,8 +123,8 @@ pub struct TypeLimits {
125
123
negated_expr_id : ast:: NodeId ,
126
124
}
127
125
128
- impl Default for TypeLimits {
129
- fn default ( ) -> TypeLimits {
126
+ impl TypeLimits {
127
+ pub fn new ( ) -> TypeLimits {
130
128
TypeLimits {
131
129
negated_expr_id : -1 ,
132
130
}
@@ -320,7 +318,6 @@ impl LintPass for TypeLimits {
320
318
declare_lint ! ( ctypes, Warn ,
321
319
"proper use of libc types in foreign modules" )
322
320
323
- #[ deriving( Default ) ]
324
321
pub struct CTypes ;
325
322
326
323
impl LintPass for CTypes {
@@ -389,7 +386,6 @@ declare_lint!(owned_heap_memory, Allow,
389
386
declare_lint ! ( heap_memory, Allow ,
390
387
"use of any (Box type or @ type) heap memory" )
391
388
392
- #[ deriving( Default ) ]
393
389
pub struct HeapMemory ;
394
390
395
391
impl HeapMemory {
@@ -492,8 +488,8 @@ pub struct RawPointerDeriving {
492
488
checked_raw_pointers : NodeSet ,
493
489
}
494
490
495
- impl Default for RawPointerDeriving {
496
- fn default ( ) -> RawPointerDeriving {
491
+ impl RawPointerDeriving {
492
+ pub fn new ( ) -> RawPointerDeriving {
497
493
RawPointerDeriving {
498
494
checked_raw_pointers : NodeSet :: new ( ) ,
499
495
}
@@ -538,7 +534,6 @@ impl LintPass for RawPointerDeriving {
538
534
declare_lint ! ( unused_attribute, Warn ,
539
535
"detects attributes that were not used by the compiler" )
540
536
541
- #[ deriving( Default ) ]
542
537
pub struct UnusedAttribute ;
543
538
544
539
impl LintPass for UnusedAttribute {
@@ -620,7 +615,6 @@ impl LintPass for UnusedAttribute {
620
615
declare_lint ! ( path_statement, Warn ,
621
616
"path statements with no effect" )
622
617
623
- #[ deriving( Default ) ]
624
618
pub struct PathStatement ;
625
619
626
620
impl LintPass for PathStatement {
@@ -648,7 +642,6 @@ declare_lint!(unused_must_use, Warn,
648
642
declare_lint ! ( unused_result, Allow ,
649
643
"unused result of an expression in a statement" )
650
644
651
- #[ deriving( Default ) ]
652
645
pub struct UnusedResult ;
653
646
654
647
impl LintPass for UnusedResult {
@@ -709,7 +702,6 @@ impl LintPass for UnusedResult {
709
702
declare_lint ! ( deprecated_owned_vector, Allow ,
710
703
"use of a `~[T]` vector" )
711
704
712
- #[ deriving( Default ) ]
713
705
pub struct DeprecatedOwnedVector ;
714
706
715
707
impl LintPass for DeprecatedOwnedVector {
@@ -735,7 +727,6 @@ impl LintPass for DeprecatedOwnedVector {
735
727
declare_lint ! ( non_camel_case_types, Warn ,
736
728
"types, variants and traits should have camel case names" )
737
729
738
- #[ deriving( Default ) ]
739
730
pub struct NonCamelCaseTypes ;
740
731
741
732
impl LintPass for NonCamelCaseTypes {
@@ -821,7 +812,6 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext {
821
812
declare_lint ! ( non_snake_case_functions, Warn ,
822
813
"methods and functions should have snake case names" )
823
814
824
- #[ deriving( Default ) ]
825
815
pub struct NonSnakeCaseFunctions ;
826
816
827
817
impl NonSnakeCaseFunctions {
@@ -899,7 +889,6 @@ impl LintPass for NonSnakeCaseFunctions {
899
889
declare_lint ! ( non_uppercase_statics, Allow ,
900
890
"static constants should have uppercase identifiers" )
901
891
902
- #[ deriving( Default ) ]
903
892
pub struct NonUppercaseStatics ;
904
893
905
894
impl LintPass for NonUppercaseStatics {
@@ -931,7 +920,6 @@ impl LintPass for NonUppercaseStatics {
931
920
declare_lint ! ( non_uppercase_pattern_statics, Warn ,
932
921
"static constants in match patterns should be all caps" )
933
922
934
- #[ deriving( Default ) ]
935
923
pub struct NonUppercasePatternStatics ;
936
924
937
925
impl LintPass for NonUppercasePatternStatics {
@@ -962,7 +950,6 @@ impl LintPass for NonUppercasePatternStatics {
962
950
declare_lint ! ( uppercase_variables, Warn ,
963
951
"variable and structure field names should start with a lowercase character" )
964
952
965
- #[ deriving( Default ) ]
966
953
pub struct UppercaseVariables ;
967
954
968
955
impl LintPass for UppercaseVariables {
@@ -1011,7 +998,6 @@ impl LintPass for UppercaseVariables {
1011
998
declare_lint ! ( unnecessary_parens, Warn ,
1012
999
"`if`, `match`, `while` and `return` do not need parentheses" )
1013
1000
1014
- #[ deriving( Default ) ]
1015
1001
pub struct UnnecessaryParens ;
1016
1002
1017
1003
impl UnnecessaryParens {
@@ -1062,7 +1048,6 @@ impl LintPass for UnnecessaryParens {
1062
1048
declare_lint ! ( unused_unsafe, Warn ,
1063
1049
"unnecessary use of an `unsafe` block" )
1064
1050
1065
- #[ deriving( Default ) ]
1066
1051
pub struct UnusedUnsafe ;
1067
1052
1068
1053
impl LintPass for UnusedUnsafe {
@@ -1087,7 +1072,6 @@ impl LintPass for UnusedUnsafe {
1087
1072
declare_lint ! ( unsafe_block, Allow ,
1088
1073
"usage of an `unsafe` block" )
1089
1074
1090
- #[ deriving( Default ) ]
1091
1075
pub struct UnsafeBlock ;
1092
1076
1093
1077
impl LintPass for UnsafeBlock {
@@ -1109,7 +1093,6 @@ impl LintPass for UnsafeBlock {
1109
1093
declare_lint ! ( unused_mut, Warn ,
1110
1094
"detect mut variables which don't need to be mutable" )
1111
1095
1112
- #[ deriving( Default ) ]
1113
1096
pub struct UnusedMut ;
1114
1097
1115
1098
impl UnusedMut {
@@ -1195,7 +1178,6 @@ enum Allocation {
1195
1178
declare_lint ! ( unnecessary_allocation, Warn ,
1196
1179
"detects unnecessary allocations that can be eliminated" )
1197
1180
1198
- #[ deriving( Default ) ]
1199
1181
pub struct UnnecessaryAllocation ;
1200
1182
1201
1183
impl LintPass for UnnecessaryAllocation {
@@ -1267,17 +1249,15 @@ pub struct MissingDoc {
1267
1249
doc_hidden_stack : Vec < bool > ,
1268
1250
}
1269
1251
1270
- impl Default for MissingDoc {
1271
- fn default ( ) -> MissingDoc {
1252
+ impl MissingDoc {
1253
+ pub fn new ( ) -> MissingDoc {
1272
1254
MissingDoc {
1273
1255
exported_items : None ,
1274
1256
struct_def_stack : vec ! ( ) ,
1275
1257
doc_hidden_stack : vec ! ( false ) ,
1276
1258
}
1277
1259
}
1278
- }
1279
1260
1280
- impl MissingDoc {
1281
1261
fn doc_hidden ( & self ) -> bool {
1282
1262
* self . doc_hidden_stack . last ( ) . expect ( "empty doc_hidden_stack" )
1283
1263
}
@@ -1419,7 +1399,6 @@ declare_lint!(unstable, Allow,
1419
1399
1420
1400
/// Checks for use of items with `#[deprecated]`, `#[experimental]` and
1421
1401
/// `#[unstable]` attributes, or no stability attribute.
1422
- #[ deriving( Default ) ]
1423
1402
pub struct Stability ;
1424
1403
1425
1404
impl LintPass for Stability {
@@ -1554,7 +1533,6 @@ declare_lint!(pub variant_size_difference, Allow,
1554
1533
1555
1534
/// Does nothing as a lint pass, but registers some `Lint`s
1556
1535
/// which are used by other parts of the compiler.
1557
- #[ deriving( Default ) ]
1558
1536
pub struct HardwiredLints ;
1559
1537
1560
1538
impl LintPass for HardwiredLints {
0 commit comments