File tree 7 files changed +48
-21
lines changed
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> {
1721
1721
where_predicates : Vec :: new ( )
1722
1722
} ,
1723
1723
decl : ( cx. map . local_def_id ( 0 ) , & fty. sig ) . clean ( cx) ,
1724
- abi : fty. abi . to_string ( ) ,
1724
+ abi : fty. abi ,
1725
1725
} ) ,
1726
1726
ty:: TyStruct ( def, substs) |
1727
1727
ty:: TyEnum ( def, substs) => {
@@ -2143,7 +2143,7 @@ pub struct BareFunctionDecl {
2143
2143
pub unsafety : hir:: Unsafety ,
2144
2144
pub generics : Generics ,
2145
2145
pub decl : FnDecl ,
2146
- pub abi : String ,
2146
+ pub abi : Abi ,
2147
2147
}
2148
2148
2149
2149
impl Clean < BareFunctionDecl > for hir:: BareFnTy {
@@ -2156,7 +2156,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy {
2156
2156
where_predicates : Vec :: new ( )
2157
2157
} ,
2158
2158
decl : self . decl . clean ( cx) ,
2159
- abi : self . abi . to_string ( ) ,
2159
+ abi : self . abi ,
2160
2160
}
2161
2161
}
2162
2162
}
Original file line number Diff line number Diff line change @@ -451,11 +451,7 @@ impl fmt::Display for clean::Type {
451
451
clean:: BareFunction ( ref decl) => {
452
452
write ! ( f, "{}{}fn{}{}" ,
453
453
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) ,
459
455
decl. generics,
460
456
decl. decl)
461
457
}
@@ -770,8 +766,7 @@ impl fmt::Display for AbiSpace {
770
766
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
771
767
match self . 0 {
772
768
Abi :: Rust => Ok ( ( ) ) ,
773
- Abi :: C => write ! ( f, "extern " ) ,
774
- abi => write ! ( f, "extern {} " , abi) ,
769
+ abi => write ! ( f, "extern "{}" " , abi. name( ) ) ,
775
770
}
776
771
}
777
772
}
Original file line number Diff line number Diff line change @@ -2129,8 +2129,6 @@ fn render_assoc_item(w: &mut fmt::Formatter,
2129
2129
d : & clean:: FnDecl ,
2130
2130
link : AssocItemLink )
2131
2131
-> fmt:: Result {
2132
- use syntax:: abi:: Abi ;
2133
-
2134
2132
let name = meth. name . as_ref ( ) . unwrap ( ) ;
2135
2133
let anchor = format ! ( "#{}.{}" , shortty( meth) , name) ;
2136
2134
let href = match link {
@@ -2157,10 +2155,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
2157
2155
{generics}{decl}{where_clause}",
2158
2156
ConstnessSpace ( vis_constness) ,
2159
2157
UnsafetySpace ( unsafety) ,
2160
- match abi {
2161
- Abi :: Rust => String :: new( ) ,
2162
- a => format!( "extern {} " , a. to_string( ) )
2163
- } ,
2158
+ AbiSpace ( abi) ,
2164
2159
href = href,
2165
2160
name = name,
2166
2161
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 13
13
14
14
extern crate rustdoc_ffi as lib;
15
15
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)'
17
17
pub use lib:: foreigner;
18
18
19
19
extern "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)'
21
21
pub fn another ( cold_as_ice : u32 ) ;
22
22
}
Original file line number Diff line number Diff line change 10
10
11
11
extern {
12
12
// @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()'
14
14
pub fn foo1 ( ) ;
15
15
}
16
16
@@ -21,7 +21,7 @@ extern "system" {
21
21
}
22
22
23
23
// @has issue_22038/fn.bar.html \
24
- // '//*[@class="rust fn"]' 'pub extern fn bar()'
24
+ // '//*[@class="rust fn"]' 'pub extern "C" fn bar()'
25
25
pub extern fn bar ( ) { }
26
26
27
27
// @has issue_22038/fn.baz.html \
Original file line number Diff line number Diff line change 9
9
// except according to those terms.
10
10
11
11
extern "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, ...)'
13
13
pub fn foo ( x : i32 , ...) ;
14
14
}
You can’t perform that action at this time.
0 commit comments