Skip to content

rustdoc: Fix a number of low-hanging-fruit problems #24177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Apr 10, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
10359de
compiletest: Add support for running rustdoc tests
alexcrichton Apr 6, 2015
d3647fe
test: Move all run-make rustdoc tests to test/rustdoc
alexcrichton Apr 6, 2015
458102e
rustdoc: Run external traits through filters
alexcrichton Apr 6, 2015
29299d5
rustdoc: Add a test for #15169
alexcrichton Apr 6, 2015
c9c7be7
mk: Pass the same flags to rustdoc as rustc
alexcrichton Apr 6, 2015
9ad133b
rustdoc: Add a primitive page for raw pointers
alexcrichton Apr 6, 2015
a30f28e
rustdoc: Add a test for fixed issue #15347
alexcrichton Apr 6, 2015
c47bb7c
rustdoc: Add a test for fixed issue #16019
alexcrichton Apr 6, 2015
fcc89ea
rustdoc: Only hide possibly private modules
alexcrichton Apr 6, 2015
641bca0
rustdoc: Link "Trait Implementations" to sources
alexcrichton Apr 7, 2015
179719d
rustdoc: Allowing specifying attrs for doctests
alexcrichton Apr 7, 2015
ba40231
std: Deny most warnings in doctests
alexcrichton Apr 7, 2015
8f6855c
rustdoc: Render methods/impls for bare traits
alexcrichton Apr 7, 2015
8874fd4
rustdoc: Show impls for references to types
alexcrichton Apr 7, 2015
11f26f9
rustdoc: Simplify cross-crate where clauses
alexcrichton Apr 7, 2015
75ef083
rustdoc: Improve handling inlined associated types
alexcrichton Apr 7, 2015
ec412c2
rustdoc: Add a test for #21092
alexcrichton Apr 7, 2015
0f3183f
rustdoc: Don't duplicate inlined impl blocks
alexcrichton Apr 7, 2015
947f1b6
book: Emit links to play.rust-lang.org to run examples
alexcrichton Apr 7, 2015
d7fcee8
rustdoc: Detect provided methods on inlined traits
alexcrichton Apr 7, 2015
6950f68
rustdoc: Simplify predicates with paren notation
alexcrichton Apr 7, 2015
2b9076e
rustdoc: Encode ABI in all methods
alexcrichton Apr 7, 2015
ed276ca
mk: Stop documenating non-facade crates
alexcrichton Apr 7, 2015
11b1ff1
book: Fix a hyperlink to CONFIGS.md
alexcrichton Apr 7, 2015
dbaa242
rustdoc: Handle tests with bare `#` marks
alexcrichton Apr 7, 2015
61d0365
rustdoc: Handle duplicate reexports listed
alexcrichton Apr 7, 2015
f651bea
std: Reorganize thread::local a bit
alexcrichton Apr 8, 2015
1b568ba
std: Hide facade extension traits in docs
alexcrichton Apr 8, 2015
77d164d
rustdoc: Index inherent methods on primitives
alexcrichton Apr 8, 2015
2625276
rustdoc: Add a test for should_fail in doctests
alexcrichton Apr 8, 2015
445faca
Test fixes and review feedback
alexcrichton Apr 8, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustdoc: Index inherent methods on primitives
The set of types which can have an inherent impl changed slightly and rustdoc
just needed to catch up to understand what it means to see a `impl str`!

Closes #23511
  • Loading branch information
alexcrichton committed Apr 8, 2015
commit 77d164d8099abc17f97aa50442245e4fc88b36a2
15 changes: 15 additions & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,21 @@ pub enum TypeKind {
TypeTypedef,
}

impl Type {
pub fn primitive_type(&self) -> Option<PrimitiveType> {
match *self {
Primitive(p) | BorrowedRef { type_: box Primitive(p), ..} => Some(p),
Vector(..) | BorrowedRef{ type_: box Vector(..), .. } => Some(Slice),
FixedVector(..) | BorrowedRef { type_: box FixedVector(..), .. } => {
Some(Array)
}
Tuple(..) => Some(PrimitiveTuple),
RawPointer(..) => Some(PrimitiveRawPointer),
_ => None,
}
}
}

impl PrimitiveType {
fn from_str(s: &str) -> Option<PrimitiveType> {
match s {
Expand Down
59 changes: 17 additions & 42 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,16 @@ impl DocFolder for Cache {
self.parent_stack.push(did);
true
}
_ => false
ref t => {
match t.primitive_type() {
Some(prim) => {
let did = ast_util::local_def(prim.to_node_id());
self.parent_stack.push(did);
true
}
_ => false,
}
}
}
}
_ => false
Expand All @@ -1037,11 +1046,6 @@ impl DocFolder for Cache {
Some(item) => {
match item {
clean::Item{ attrs, inner: clean::ImplItem(i), .. } => {
use clean::{Primitive, Vector, ResolvedPath, BorrowedRef};
use clean::PrimitiveType::{Array, Slice, PrimitiveTuple};
use clean::PrimitiveType::{PrimitiveRawPointer};
use clean::{FixedVector, Tuple, RawPointer};

// extract relevant documentation for this impl
let dox = match attrs.into_iter().find(|a| {
match *a {
Expand All @@ -1059,47 +1063,18 @@ impl DocFolder for Cache {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
let did = match i.for_ {
ResolvedPath { did, .. } |
BorrowedRef {
type_: box ResolvedPath { did, .. }, ..
clean::ResolvedPath { did, .. } |
clean::BorrowedRef {
type_: box clean::ResolvedPath { did, .. }, ..
} => {
Some(did)
}

// References to primitives are picked up as well to
// recognize implementations for &str, this may not
// be necessary in a DST world.
Primitive(p) |
BorrowedRef { type_: box Primitive(p), ..} =>
{
Some(ast_util::local_def(p.to_node_id()))
ref t => {
t.primitive_type().map(|p| {
ast_util::local_def(p.to_node_id())
})
}

FixedVector(..) |
BorrowedRef { type_: box FixedVector(..), .. } =>
{
Some(ast_util::local_def(Array.to_node_id()))
}

// In a DST world, we may only need Vector, but for
// now we also pick up borrowed references
Vector(..) |
BorrowedRef{ type_: box Vector(..), .. } =>
{
Some(ast_util::local_def(Slice.to_node_id()))
}

Tuple(..) => {
let id = PrimitiveTuple.to_node_id();
Some(ast_util::local_def(id))
}

RawPointer(..) => {
let id = PrimitiveRawPointer.to_node_id();
Some(ast_util::local_def(id))
}

_ => None,
};

if let Some(did) = did {
Expand Down
24 changes: 24 additions & 0 deletions src/test/rustdoc/issue-23511.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2015 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.

#![feature(no_std, lang_items, core)]
#![no_std]

extern crate core;

pub mod str {
#![doc(primitive = "str")]

#[lang = "str"]
impl str {
// @has search-index.js foo
pub fn foo(&self) {}
}
}