File tree Expand file tree Collapse file tree 7 files changed +48
-21
lines changed Expand file tree Collapse file tree 7 files changed +48
-21
lines changed Original file line number Diff line number Diff line change @@ -1721,7 +1721,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
17211721 where_predicates : Vec :: new ( )
17221722 } ,
17231723 decl : ( cx. map . local_def_id ( 0 ) , & fty. sig ) . clean ( cx) ,
1724- abi : fty. abi . to_string ( ) ,
1724+ abi : fty. abi ,
17251725 } ) ,
17261726 ty:: TyStruct ( def, substs) |
17271727 ty:: TyEnum ( def, substs) => {
@@ -2143,7 +2143,7 @@ pub struct BareFunctionDecl {
21432143 pub unsafety : hir:: Unsafety ,
21442144 pub generics : Generics ,
21452145 pub decl : FnDecl ,
2146- pub abi : String ,
2146+ pub abi : Abi ,
21472147}
21482148
21492149impl Clean < BareFunctionDecl > for hir:: BareFnTy {
@@ -2156,7 +2156,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy {
21562156 where_predicates : Vec :: new ( )
21572157 } ,
21582158 decl : self . decl . clean ( cx) ,
2159- abi : self . abi . to_string ( ) ,
2159+ abi : self . abi ,
21602160 }
21612161 }
21622162}
Original file line number Diff line number Diff line change @@ -451,11 +451,7 @@ impl fmt::Display for clean::Type {
451451 clean:: BareFunction ( ref decl) => {
452452 write ! ( f, "{}{}fn{}{}" ,
453453 UnsafetySpace ( decl. unsafety) ,
454- match & * decl. abi {
455- "" => " extern " . to_string( ) ,
456- "\" Rust\" " => "" . to_string( ) ,
457- s => format!( " extern {} " , s)
458- } ,
454+ AbiSpace ( decl. abi) ,
459455 decl. generics,
460456 decl. decl)
461457 }
@@ -770,8 +766,7 @@ impl fmt::Display for AbiSpace {
770766 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
771767 match self . 0 {
772768 Abi :: Rust => Ok ( ( ) ) ,
773- Abi :: C => write ! ( f, "extern " ) ,
774- abi => write ! ( f, "extern {} " , abi) ,
769+ abi => write ! ( f, "extern "{}" " , abi. name( ) ) ,
775770 }
776771 }
777772}
Original file line number Diff line number Diff line change @@ -2129,8 +2129,6 @@ fn render_assoc_item(w: &mut fmt::Formatter,
21292129 d : & clean:: FnDecl ,
21302130 link : AssocItemLink )
21312131 -> fmt:: Result {
2132- use syntax:: abi:: Abi ;
2133-
21342132 let name = meth. name . as_ref ( ) . unwrap ( ) ;
21352133 let anchor = format ! ( "#{}.{}" , shortty( meth) , name) ;
21362134 let href = match link {
@@ -2157,10 +2155,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
21572155 {generics}{decl}{where_clause}",
21582156 ConstnessSpace ( vis_constness) ,
21592157 UnsafetySpace ( unsafety) ,
2160- match abi {
2161- Abi :: Rust => String :: new( ) ,
2162- a => format!( "extern {} " , a. to_string( ) )
2163- } ,
2158+ AbiSpace ( abi) ,
21642159 href = href,
21652160 name = name,
21662161 generics = * g,
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ crate_name = "foo" ]
12+
13+ // @has foo/struct.Foo.html
14+ pub struct Foo ;
15+
16+ impl Foo {
17+ // @has - '//code' 'fn rust0()'
18+ pub fn rust0 ( ) { }
19+ // @has - '//code' 'fn rust1()'
20+ pub extern "Rust" fn rust1 ( ) { }
21+ // @has - '//code' 'extern "C" fn c0()'
22+ pub extern fn c0 ( ) { }
23+ // @has - '//code' 'extern "C" fn c1()'
24+ pub extern "C" fn c1 ( ) { }
25+ // @has - '//code' 'extern "system" fn system0()'
26+ pub extern "system" fn system0 ( ) { }
27+ }
28+
29+ // @has foo/trait.Bar.html
30+ pub trait Bar { }
31+
32+ // @has - '//code' 'impl Bar for fn()'
33+ impl Bar for fn ( ) { }
34+ // @has - '//code' 'impl Bar for extern "C" fn()'
35+ impl Bar for extern fn ( ) { }
36+ // @has - '//code' 'impl Bar for extern "system" fn()'
37+ impl Bar for extern "system" fn ( ) { }
Original file line number Diff line number Diff line change 1313
1414extern crate rustdoc_ffi as lib;
1515
16- // @has ffi/fn.foreigner.html //pre 'pub unsafe extern fn foreigner(cold_as_ice: u32)'
16+ // @has ffi/fn.foreigner.html //pre 'pub unsafe extern "C" fn foreigner(cold_as_ice: u32)'
1717pub use lib:: foreigner;
1818
1919extern "C" {
20- // @has ffi/fn.another.html //pre 'pub unsafe extern fn another(cold_as_ice: u32)'
20+ // @has ffi/fn.another.html //pre 'pub unsafe extern "C" fn another(cold_as_ice: u32)'
2121 pub fn another ( cold_as_ice : u32 ) ;
2222}
Original file line number Diff line number Diff line change 1010
1111extern {
1212 // @has issue_22038/fn.foo1.html \
13- // '//*[@class="rust fn"]' 'pub unsafe extern fn foo1()'
13+ // '//*[@class="rust fn"]' 'pub unsafe extern "C" fn foo1()'
1414 pub fn foo1 ( ) ;
1515}
1616
@@ -21,7 +21,7 @@ extern "system" {
2121}
2222
2323// @has issue_22038/fn.bar.html \
24- // '//*[@class="rust fn"]' 'pub extern fn bar()'
24+ // '//*[@class="rust fn"]' 'pub extern "C" fn bar()'
2525pub extern fn bar ( ) { }
2626
2727// @has issue_22038/fn.baz.html \
Original file line number Diff line number Diff line change 99// except according to those terms.
1010
1111extern "C" {
12- // @has variadic/fn.foo.html //pre 'pub unsafe extern fn foo(x: i32, ...)'
12+ // @has variadic/fn.foo.html //pre 'pub unsafe extern "C" fn foo(x: i32, ...)'
1313 pub fn foo ( x : i32 , ...) ;
1414}
You can’t perform that action at this time.
0 commit comments