From 19a6fabad8e43a81617182eba24fb80e33da8e52 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 28 Aug 2013 23:47:26 -0700 Subject: Implement the notion of a "generated unsafe block" This way syntax extensions can generate unsafe blocks without worrying about them generating unnecessary unsafe warnings. Perhaps a special keyword could be added to be used in macros, but I don't think that's the best solution. --- src/libsyntax/ast.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/print/pprust.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 8d557125d37..63a6e936550 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -479,7 +479,7 @@ pub struct Field { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum BlockCheckMode { DefaultBlock, - UnsafeBlock, + UnsafeBlock(/* generated internally */ bool), } #[deriving(Clone, Eq, Encodable, Decodable,IterBytes)] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4adc34d75a7..b0bcc91f962 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1792,7 +1792,7 @@ impl Parser { } else if self.eat_keyword(keywords::Match) { return self.parse_match_expr(); } else if self.eat_keyword(keywords::Unsafe) { - return self.parse_block_expr(lo, UnsafeBlock); + return self.parse_block_expr(lo, UnsafeBlock(false)); } else if *self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 55f052d769d..9b9b157c9d8 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -951,7 +951,7 @@ pub fn print_possibly_embedded_block_(s: @ps, attrs: &[ast::Attribute], close_box: bool) { match blk.rules { - ast::UnsafeBlock => word_space(s, "unsafe"), + ast::UnsafeBlock(*) => word_space(s, "unsafe"), ast::DefaultBlock => () } maybe_print_comment(s, blk.span.lo); -- cgit 1.4.1-3-g733a5