@@ -75,6 +75,7 @@ pub enum lint {
7575 type_limits,
7676 type_overflow,
7777 unused_unsafe,
78+ unsafe_block,
7879
7980 managed_heap_memory,
8081 owned_heap_memory,
@@ -236,6 +237,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
236237 default : warn
237238 } ) ,
238239
240+ ( "unsafe_block" ,
241+ LintSpec {
242+ lint : unsafe_block,
243+ desc : "usage of an `unsafe` block" ,
244+ default : allow
245+ } ) ,
246+
239247 ( "unused_variable" ,
240248 LintSpec {
241249 lint : unused_variable,
@@ -870,8 +878,7 @@ fn check_pat_non_uppercase_statics(cx: &Context, p: &ast::Pat) {
870878
871879fn check_unused_unsafe ( cx : & Context , e : & ast:: Expr ) {
872880 match e. node {
873- // Don't warn about generated blocks, that'll just pollute the
874- // output.
881+ // Don't warn about generated blocks, that'll just pollute the output.
875882 ast:: ExprBlock ( ref blk) => {
876883 if blk. rules == ast:: UnsafeBlock ( ast:: UserProvided ) &&
877884 !cx. tcx . used_unsafe . contains ( & blk. id ) {
@@ -883,6 +890,16 @@ fn check_unused_unsafe(cx: &Context, e: &ast::Expr) {
883890 }
884891}
885892
893+ fn check_unsafe_block ( cx : & Context , e : & ast:: Expr ) {
894+ match e. node {
895+ // Don't warn about generated blocks, that'll just pollute the output.
896+ ast:: ExprBlock ( ref blk) if blk. rules == ast:: UnsafeBlock ( ast:: UserProvided ) => {
897+ cx. span_lint ( unsafe_block, blk. span , "usage of an `unsafe` block" ) ;
898+ }
899+ _ => ( )
900+ }
901+ }
902+
886903fn check_unused_mut_pat ( cx : & Context , p : @ast:: Pat ) {
887904 match p. node {
888905 ast:: PatIdent ( ast:: BindByValue ( ast:: MutMutable ) ,
@@ -1126,6 +1143,7 @@ impl<'self> Visitor<()> for Context<'self> {
11261143 check_while_true_expr ( self , e) ;
11271144 check_stability ( self , e) ;
11281145 check_unused_unsafe ( self , e) ;
1146+ check_unsafe_block ( self , e) ;
11291147 check_unnecessary_allocation ( self , e) ;
11301148 check_heap_expr ( self , e) ;
11311149
0 commit comments