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]
This commit is contained in:
parent
cf6857b9e9
commit
08237cad8d
15 changed files with 59 additions and 49 deletions
|
|
@ -1200,7 +1200,7 @@ impl Clean<Item> for ast::ForeignItem {
|
|||
ForeignFunctionItem(Function {
|
||||
decl: decl.clean(),
|
||||
generics: generics.clean(),
|
||||
fn_style: ast::ExternFn,
|
||||
fn_style: ast::NormalFn,
|
||||
})
|
||||
}
|
||||
ast::ForeignItemStatic(ref ty, mutbl) => {
|
||||
|
|
|
|||
|
|
@ -397,10 +397,10 @@ impl fmt::Show for clean::Type {
|
|||
clean::BareFunction(ref decl) => {
|
||||
write!(f.buf, "{}{}fn{}{}",
|
||||
FnStyleSpace(decl.fn_style),
|
||||
match decl.abi {
|
||||
ref x if "" == *x => "".to_owned(),
|
||||
ref x if "\"Rust\"" == *x => "".to_owned(),
|
||||
ref s => " " + *s + " ",
|
||||
match decl.abi.as_slice() {
|
||||
"" => " extern ".to_owned(),
|
||||
"\"Rust\"" => "".to_owned(),
|
||||
s => format!(" extern {} ", s)
|
||||
},
|
||||
decl.generics,
|
||||
decl.decl)
|
||||
|
|
@ -517,7 +517,6 @@ impl fmt::Show for FnStyleSpace {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.get() {
|
||||
ast::UnsafeFn => write!(f.buf, "unsafe "),
|
||||
ast::ExternFn => write!(f.buf, "extern "),
|
||||
ast::NormalFn => Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue