@@ -65,6 +65,7 @@ enum lint {
65
65
non_camel_case_types,
66
66
structural_records,
67
67
type_limits,
68
+ default_methods,
68
69
69
70
managed_heap_memory,
70
71
owned_heap_memory,
@@ -200,7 +201,12 @@ fn get_lint_dict() -> lint_dict {
200
201
( ~"type_limits",
201
202
@{ lint: type_limits,
202
203
desc: ~"comparisons made useless by limits of the types involved",
203
- default : warn} )
204
+ default : warn} ) ,
205
+
206
+ ( ~"default_methods",
207
+ @{ lint: default_methods,
208
+ desc: ~"allow default methods",
209
+ default : forbid} ) ,
204
210
205
211
/* FIXME(#3266)--make liveness warnings lintable
206
212
(~"unused_variable",
@@ -414,6 +420,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
414
420
check_item_structural_records( cx, i) ;
415
421
check_item_deprecated_modes( cx, i) ;
416
422
check_item_type_limits( cx, i) ;
423
+ check_item_default_methods( cx, i) ;
417
424
}
418
425
419
426
// Take a visitor, and modify it so that it will not proceed past subitems.
@@ -563,6 +570,27 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
563
570
visit:: visit_item( it, ( ) , visit) ;
564
571
}
565
572
573
+ fn check_item_default_methods( cx: ty:: ctxt, item: @ast:: item) {
574
+ match item. node {
575
+ ast:: item_trait( _, _, methods) => {
576
+ for methods. each |method| {
577
+ match * method {
578
+ ast:: required( * ) => { }
579
+ ast:: provided( * ) => {
580
+ cx. sess. span_lint(
581
+ default_methods,
582
+ item. id,
583
+ item. id,
584
+ item. span,
585
+ ~"default methods are experimental") ;
586
+ }
587
+ }
588
+ }
589
+ }
590
+ _ => { }
591
+ }
592
+ }
593
+
566
594
fn check_item_structural_records( cx: ty:: ctxt, it: @ast:: item) {
567
595
let visit = item_stopping_visitor( visit:: mk_simple_visitor( @{
568
596
visit_expr: fn @( e: @ast:: expr) {
0 commit comments