diff options
| author | Oliver Middleton <olliemail27@gmail.com> | 2016-04-22 11:48:46 +0100 |
|---|---|---|
| committer | Oliver Middleton <olliemail27@gmail.com> | 2016-04-22 11:51:25 +0100 |
| commit | 2b1e35ec129b53bc440b59ede8bfaccb88a3cbf4 (patch) | |
| tree | 53affdf3d5596d72cb9a57b4b4b4a591810cbba2 /src/librustdoc | |
| parent | 887e9471783ff3f5edc920a85b6110486dc063c0 (diff) | |
| download | rust-2b1e35ec129b53bc440b59ede8bfaccb88a3cbf4.tar.gz rust-2b1e35ec129b53bc440b59ede8bfaccb88a3cbf4.zip | |
rustdoc: Cleanup ABI rendering
Use a common method for rendering `extern "<abi>"`. This now consistently shows `extern "C" fn` rather than just `extern fn`.
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/html/format.rs | 9 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 7 |
3 files changed, 6 insertions, 16 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c9f40a1adae..c030f02f123 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1721,7 +1721,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> { where_predicates: Vec::new() }, decl: (cx.map.local_def_id(0), &fty.sig).clean(cx), - abi: fty.abi.to_string(), + abi: fty.abi, }), ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => { @@ -2143,7 +2143,7 @@ pub struct BareFunctionDecl { pub unsafety: hir::Unsafety, pub generics: Generics, pub decl: FnDecl, - pub abi: String, + pub abi: Abi, } impl Clean<BareFunctionDecl> for hir::BareFnTy { @@ -2156,7 +2156,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy { where_predicates: Vec::new() }, decl: self.decl.clean(cx), - abi: self.abi.to_string(), + abi: self.abi, } } } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d4212bba590..72414ad4c5e 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -451,11 +451,7 @@ impl fmt::Display for clean::Type { clean::BareFunction(ref decl) => { write!(f, "{}{}fn{}{}", UnsafetySpace(decl.unsafety), - match &*decl.abi { - "" => " extern ".to_string(), - "\"Rust\"" => "".to_string(), - s => format!(" extern {} ", s) - }, + AbiSpace(decl.abi), decl.generics, decl.decl) } @@ -770,8 +766,7 @@ impl fmt::Display for AbiSpace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.0 { Abi::Rust => Ok(()), - Abi::C => write!(f, "extern "), - abi => write!(f, "extern {} ", abi), + abi => write!(f, "extern "{}" ", abi.name()), } } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index c08d917589d..f41c81f20ed 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2129,8 +2129,6 @@ fn render_assoc_item(w: &mut fmt::Formatter, d: &clean::FnDecl, link: AssocItemLink) -> fmt::Result { - use syntax::abi::Abi; - let name = meth.name.as_ref().unwrap(); let anchor = format!("#{}.{}", shortty(meth), name); let href = match link { @@ -2157,10 +2155,7 @@ fn render_assoc_item(w: &mut fmt::Formatter, {generics}{decl}{where_clause}", ConstnessSpace(vis_constness), UnsafetySpace(unsafety), - match abi { - Abi::Rust => String::new(), - a => format!("extern {} ", a.to_string()) - }, + AbiSpace(abi), href = href, name = name, generics = *g, |
