Skip to content

Commit 8301081

Browse files
Fix primitive blanket impls not showing up
1 parent 4aba7de commit 8301081

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

src/librustdoc/clean/blanket_impl.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
6565
);
6666
return impls;
6767
}
68-
if self.cx.access_levels.borrow().is_doc_reachable(def_id) {
68+
let ty = self.cx.tcx.type_of(def_id);
69+
if self.cx.access_levels.borrow().is_doc_reachable(def_id) || ty.is_primitive() {
6970
let generics = self.cx.tcx.generics_of(def_id);
70-
let ty = self.cx.tcx.type_of(def_id);
7171
let real_name = name.clone().map(|name| Ident::from_str(&name));
7272
let param_env = self.cx.tcx.param_env(def_id);
7373
for &trait_def_id in self.cx.all_traits.iter() {
@@ -84,8 +84,8 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
8484
let trait_ref = infcx.tcx.impl_trait_ref(impl_def_id)
8585
.expect("Cannot get impl trait");
8686

87-
match infcx.tcx.type_of(impl_def_id).sty {
88-
::rustc::ty::TypeVariants::TyParam(_) => {},
87+
match trait_ref.self_ty().sty {
88+
ty::TypeVariants::TyParam(_) => {},
8989
_ => return,
9090
}
9191

@@ -153,7 +153,6 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
153153
.clean(self.cx)),
154154
}),
155155
});
156-
debug!("{:?} => {}", trait_ref, may_apply);
157156
}
158157
});
159158
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018 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+
// we need to reexport something from libstd so that `all_trait_implementations` is called.
14+
pub use std::string::String;
15+
16+
include!("primitive/primitive-generic-impl.rs");
17+
18+
// @has foo/primitive.i32.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2018 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+
#[doc(primitive = "i32")]
12+
/// Some useless docs, wouhou!
13+
mod i32 {}

0 commit comments

Comments
 (0)