2121//! as a `LintPass`.
2222//!
2323//! 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()`.
2627
2728use metadata:: csearch;
2829use middle:: def:: * ;
@@ -45,7 +46,6 @@ use std::u16;
4546use std:: u32;
4647use std:: u64;
4748use std:: u8;
48- use std:: default:: Default ;
4949use syntax:: abi;
5050use syntax:: ast_map;
5151use syntax:: attr:: AttrMetaMethods ;
@@ -57,7 +57,6 @@ use syntax::{ast, ast_util, visit};
5757declare_lint ! ( while_true, Warn ,
5858 "suggest using `loop { }` instead of `while true { }`" )
5959
60- #[ deriving( Default ) ]
6160pub struct WhileTrue ;
6261
6362impl LintPass for WhileTrue {
@@ -90,7 +89,6 @@ impl LintPass for WhileTrue {
9089declare_lint ! ( unnecessary_typecast, Allow ,
9190 "detects unnecessary type casts, that can be removed" )
9291
93- #[ deriving( Default ) ]
9492pub struct UnusedCasts ;
9593
9694impl LintPass for UnusedCasts {
@@ -125,8 +123,8 @@ pub struct TypeLimits {
125123 negated_expr_id : ast:: NodeId ,
126124}
127125
128- impl Default for TypeLimits {
129- fn default ( ) -> TypeLimits {
126+ impl TypeLimits {
127+ pub fn new ( ) -> TypeLimits {
130128 TypeLimits {
131129 negated_expr_id : -1 ,
132130 }
@@ -320,7 +318,6 @@ impl LintPass for TypeLimits {
320318declare_lint ! ( ctypes, Warn ,
321319 "proper use of libc types in foreign modules" )
322320
323- #[ deriving( Default ) ]
324321pub struct CTypes ;
325322
326323impl LintPass for CTypes {
@@ -389,7 +386,6 @@ declare_lint!(owned_heap_memory, Allow,
389386declare_lint ! ( heap_memory, Allow ,
390387 "use of any (Box type or @ type) heap memory" )
391388
392- #[ deriving( Default ) ]
393389pub struct HeapMemory ;
394390
395391impl HeapMemory {
@@ -492,8 +488,8 @@ pub struct RawPointerDeriving {
492488 checked_raw_pointers : NodeSet ,
493489}
494490
495- impl Default for RawPointerDeriving {
496- fn default ( ) -> RawPointerDeriving {
491+ impl RawPointerDeriving {
492+ pub fn new ( ) -> RawPointerDeriving {
497493 RawPointerDeriving {
498494 checked_raw_pointers : NodeSet :: new ( ) ,
499495 }
@@ -538,7 +534,6 @@ impl LintPass for RawPointerDeriving {
538534declare_lint ! ( unused_attribute, Warn ,
539535 "detects attributes that were not used by the compiler" )
540536
541- #[ deriving( Default ) ]
542537pub struct UnusedAttribute ;
543538
544539impl LintPass for UnusedAttribute {
@@ -620,7 +615,6 @@ impl LintPass for UnusedAttribute {
620615declare_lint ! ( path_statement, Warn ,
621616 "path statements with no effect" )
622617
623- #[ deriving( Default ) ]
624618pub struct PathStatement ;
625619
626620impl LintPass for PathStatement {
@@ -648,7 +642,6 @@ declare_lint!(unused_must_use, Warn,
648642declare_lint ! ( unused_result, Allow ,
649643 "unused result of an expression in a statement" )
650644
651- #[ deriving( Default ) ]
652645pub struct UnusedResult ;
653646
654647impl LintPass for UnusedResult {
@@ -709,7 +702,6 @@ impl LintPass for UnusedResult {
709702declare_lint ! ( deprecated_owned_vector, Allow ,
710703 "use of a `~[T]` vector" )
711704
712- #[ deriving( Default ) ]
713705pub struct DeprecatedOwnedVector ;
714706
715707impl LintPass for DeprecatedOwnedVector {
@@ -735,7 +727,6 @@ impl LintPass for DeprecatedOwnedVector {
735727declare_lint ! ( non_camel_case_types, Warn ,
736728 "types, variants and traits should have camel case names" )
737729
738- #[ deriving( Default ) ]
739730pub struct NonCamelCaseTypes ;
740731
741732impl LintPass for NonCamelCaseTypes {
@@ -821,7 +812,6 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext {
821812declare_lint ! ( non_snake_case_functions, Warn ,
822813 "methods and functions should have snake case names" )
823814
824- #[ deriving( Default ) ]
825815pub struct NonSnakeCaseFunctions ;
826816
827817impl NonSnakeCaseFunctions {
@@ -899,7 +889,6 @@ impl LintPass for NonSnakeCaseFunctions {
899889declare_lint ! ( non_uppercase_statics, Allow ,
900890 "static constants should have uppercase identifiers" )
901891
902- #[ deriving( Default ) ]
903892pub struct NonUppercaseStatics ;
904893
905894impl LintPass for NonUppercaseStatics {
@@ -931,7 +920,6 @@ impl LintPass for NonUppercaseStatics {
931920declare_lint ! ( non_uppercase_pattern_statics, Warn ,
932921 "static constants in match patterns should be all caps" )
933922
934- #[ deriving( Default ) ]
935923pub struct NonUppercasePatternStatics ;
936924
937925impl LintPass for NonUppercasePatternStatics {
@@ -962,7 +950,6 @@ impl LintPass for NonUppercasePatternStatics {
962950declare_lint ! ( uppercase_variables, Warn ,
963951 "variable and structure field names should start with a lowercase character" )
964952
965- #[ deriving( Default ) ]
966953pub struct UppercaseVariables ;
967954
968955impl LintPass for UppercaseVariables {
@@ -1011,7 +998,6 @@ impl LintPass for UppercaseVariables {
1011998declare_lint ! ( unnecessary_parens, Warn ,
1012999 "`if`, `match`, `while` and `return` do not need parentheses" )
10131000
1014- #[ deriving( Default ) ]
10151001pub struct UnnecessaryParens ;
10161002
10171003impl UnnecessaryParens {
@@ -1062,7 +1048,6 @@ impl LintPass for UnnecessaryParens {
10621048declare_lint ! ( unused_unsafe, Warn ,
10631049 "unnecessary use of an `unsafe` block" )
10641050
1065- #[ deriving( Default ) ]
10661051pub struct UnusedUnsafe ;
10671052
10681053impl LintPass for UnusedUnsafe {
@@ -1087,7 +1072,6 @@ impl LintPass for UnusedUnsafe {
10871072declare_lint ! ( unsafe_block, Allow ,
10881073 "usage of an `unsafe` block" )
10891074
1090- #[ deriving( Default ) ]
10911075pub struct UnsafeBlock ;
10921076
10931077impl LintPass for UnsafeBlock {
@@ -1109,7 +1093,6 @@ impl LintPass for UnsafeBlock {
11091093declare_lint ! ( unused_mut, Warn ,
11101094 "detect mut variables which don't need to be mutable" )
11111095
1112- #[ deriving( Default ) ]
11131096pub struct UnusedMut ;
11141097
11151098impl UnusedMut {
@@ -1195,7 +1178,6 @@ enum Allocation {
11951178declare_lint ! ( unnecessary_allocation, Warn ,
11961179 "detects unnecessary allocations that can be eliminated" )
11971180
1198- #[ deriving( Default ) ]
11991181pub struct UnnecessaryAllocation ;
12001182
12011183impl LintPass for UnnecessaryAllocation {
@@ -1267,17 +1249,15 @@ pub struct MissingDoc {
12671249 doc_hidden_stack : Vec < bool > ,
12681250}
12691251
1270- impl Default for MissingDoc {
1271- fn default ( ) -> MissingDoc {
1252+ impl MissingDoc {
1253+ pub fn new ( ) -> MissingDoc {
12721254 MissingDoc {
12731255 exported_items : None ,
12741256 struct_def_stack : vec ! ( ) ,
12751257 doc_hidden_stack : vec ! ( false ) ,
12761258 }
12771259 }
1278- }
12791260
1280- impl MissingDoc {
12811261 fn doc_hidden ( & self ) -> bool {
12821262 * self . doc_hidden_stack . last ( ) . expect ( "empty doc_hidden_stack" )
12831263 }
@@ -1419,7 +1399,6 @@ declare_lint!(unstable, Allow,
14191399
14201400/// Checks for use of items with `#[deprecated]`, `#[experimental]` and
14211401/// `#[unstable]` attributes, or no stability attribute.
1422- #[ deriving( Default ) ]
14231402pub struct Stability ;
14241403
14251404impl LintPass for Stability {
@@ -1554,7 +1533,6 @@ declare_lint!(pub variant_size_difference, Allow,
15541533
15551534/// Does nothing as a lint pass, but registers some `Lint`s
15561535/// which are used by other parts of the compiler.
1557- #[ deriving( Default ) ]
15581536pub struct HardwiredLints ;
15591537
15601538impl LintPass for HardwiredLints {
0 commit comments