Skip to content

Commit

Permalink
Fix primitive blanket impls not showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 4, 2018
1 parent 4aba7de commit 8301081
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/librustdoc/clean/blanket_impl.rs
Expand Up @@ -65,9 +65,9 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
);
return impls;
}
if self.cx.access_levels.borrow().is_doc_reachable(def_id) {
let ty = self.cx.tcx.type_of(def_id);
if self.cx.access_levels.borrow().is_doc_reachable(def_id) || ty.is_primitive() {
let generics = self.cx.tcx.generics_of(def_id);
let ty = self.cx.tcx.type_of(def_id);
let real_name = name.clone().map(|name| Ident::from_str(&name));
let param_env = self.cx.tcx.param_env(def_id);
for &trait_def_id in self.cx.all_traits.iter() {
Expand All @@ -84,8 +84,8 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
let trait_ref = infcx.tcx.impl_trait_ref(impl_def_id)
.expect("Cannot get impl trait");

match infcx.tcx.type_of(impl_def_id).sty {
::rustc::ty::TypeVariants::TyParam(_) => {},
match trait_ref.self_ty().sty {
ty::TypeVariants::TyParam(_) => {},
_ => return,
}

Expand Down Expand Up @@ -153,7 +153,6 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
.clean(self.cx)),
}),
});
debug!("{:?} => {}", trait_ref, may_apply);
}
});
});
Expand Down
18 changes: 18 additions & 0 deletions src/test/rustdoc/primitive-generic-impl.rs
@@ -0,0 +1,18 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![crate_name = "foo"]

// we need to reexport something from libstd so that `all_trait_implementations` is called.
pub use std::string::String;

include!("primitive/primitive-generic-impl.rs");

// @has foo/primitive.i32.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'
13 changes: 13 additions & 0 deletions src/test/rustdoc/primitive/primitive-generic-impl.rs
@@ -0,0 +1,13 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[doc(primitive = "i32")]
/// Some useless docs, wouhou!
mod i32 {}

0 comments on commit 8301081

Please sign in to comment.