summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-06 18:43:56 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-06 21:03:59 -0700
commit08237cad8d2ce9287aedf99e57384407cc9dc42d (patch)
treeaca7e5b64833b1216f0a747308533657255e1c1e /src/libsyntax/print
parentcf6857b9e9427f14d383ae2924555bedc251fa02 (diff)
downloadrust-08237cad8d2ce9287aedf99e57384407cc9dc42d.tar.gz
rust-08237cad8d2ce9287aedf99e57384407cc9dc42d.zip
rustc: Enable writing "unsafe extern fn() {}"
Previously, the parser would not allow you to simultaneously implement a
function with a different abi as well as being unsafe at the same time. This
extends the parser to allow functions of the form:

    unsafe extern fn foo() {
        // ...
    }

The closure type grammar was also changed to reflect this reversal, types
previously written as "extern unsafe fn()" must now be written as
"unsafe extern fn()". The parser currently has a hack which allows the old
style, but this will go away once a snapshot has landed.

Closes #10025

[breaking-change]
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index fb823522612..adaf1364e33 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -2372,16 +2372,10 @@ impl<'a> State<'a> {
                                 abi: abi::Abi,
                                 vis: ast::Visibility) -> IoResult<()> {
         try!(word(&mut self.s, visibility_qualified(vis, "")));
-
+        try!(self.print_opt_fn_style(opt_fn_style));
         if abi != abi::Rust {
             try!(self.word_nbsp("extern"));
             try!(self.word_nbsp(abi.to_str()));
-
-            if opt_fn_style != Some(ast::ExternFn) {
-                try!(self.print_opt_fn_style(opt_fn_style));
-            }
-        } else {
-            try!(self.print_opt_fn_style(opt_fn_style));
         }
 
         word(&mut self.s, "fn")
@@ -2391,7 +2385,6 @@ impl<'a> State<'a> {
         match s {
             ast::NormalFn => Ok(()),
             ast::UnsafeFn => self.word_nbsp("unsafe"),
-            ast::ExternFn => self.word_nbsp("extern")
         }
     }