Skip to content

Commit 9ad133b

Browse files
committed
rustdoc: Add a primitive page for raw pointers
Closes #15318
1 parent c9c7be7 commit 9ad133b

File tree

10 files changed

+90
-5
lines changed

10 files changed

+90
-5
lines changed

src/compiletest/runtest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ fn document(config: &Config, props: &TestProps,
11671167
testfile: &Path, extra_args: &[String]) -> (ProcRes, PathBuf) {
11681168
let aux_dir = aux_output_dir_name(config, testfile);
11691169
let out_dir = output_base_name(config, testfile);
1170+
let _ = fs::remove_dir_all(&out_dir);
11701171
ensure_dir(&out_dir);
11711172
let mut args = vec!["-L".to_string(),
11721173
aux_dir.to_str().unwrap().to_string(),

src/etc/htmldocck.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ def concat_multi_lines(f):
186186

187187
firstlineno = firstlineno or lineno
188188
if line.endswith('\\'):
189-
lastline = line[:-1]
189+
if lastline is None:
190+
lastline = line[:-1]
190191
catenated += line[:-1]
191192
else:
192193
yield firstlineno, catenated + line

src/libcore/ptr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
//! of unsafe pointers in Rust.
9090
9191
#![stable(feature = "rust1", since = "1.0.0")]
92+
#![doc(primitive = "pointer")]
9293

9394
use mem;
9495
use clone::Clone;

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ pub enum PrimitiveType {
13681368
Slice,
13691369
Array,
13701370
PrimitiveTuple,
1371+
PrimitiveRawPointer,
13711372
}
13721373

13731374
#[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
@@ -1404,6 +1405,7 @@ impl PrimitiveType {
14041405
"array" => Some(Array),
14051406
"slice" => Some(Slice),
14061407
"tuple" => Some(PrimitiveTuple),
1408+
"pointer" => Some(PrimitiveRawPointer),
14071409
_ => None,
14081410
}
14091411
}
@@ -1449,6 +1451,7 @@ impl PrimitiveType {
14491451
Array => "array",
14501452
Slice => "slice",
14511453
PrimitiveTuple => "tuple",
1454+
PrimitiveRawPointer => "pointer",
14521455
}
14531456
}
14541457

src/librustdoc/html/format.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ impl fmt::Display for clean::Type {
491491
}
492492
clean::Bottom => f.write_str("!"),
493493
clean::RawPointer(m, ref t) => {
494-
write!(f, "*{}{}", RawMutableSpace(m), **t)
494+
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
495+
&format!("*{}{}", RawMutableSpace(m), **t))
495496
}
496497
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
497498
let lt = match *l {

src/librustdoc/html/render.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,8 @@ impl DocFolder for Cache {
10281028
clean::Item{ attrs, inner: clean::ImplItem(i), .. } => {
10291029
use clean::{Primitive, Vector, ResolvedPath, BorrowedRef};
10301030
use clean::PrimitiveType::{Array, Slice, PrimitiveTuple};
1031-
use clean::{FixedVector, Tuple};
1031+
use clean::PrimitiveType::{PrimitiveRawPointer};
1032+
use clean::{FixedVector, Tuple, RawPointer};
10321033

10331034
// extract relevant documentation for this impl
10341035
let dox = match attrs.into_iter().find(|a| {
@@ -1064,8 +1065,8 @@ impl DocFolder for Cache {
10641065
Some(ast_util::local_def(Array.to_node_id()))
10651066
}
10661067

1067-
// In a DST world, we may only need Vector, but for now we
1068-
// also pick up borrowed references
1068+
// In a DST world, we may only need Vector, but for
1069+
// now we also pick up borrowed references
10691070
Vector(..) |
10701071
BorrowedRef{ type_: box Vector(..), .. } =>
10711072
{
@@ -1077,6 +1078,11 @@ impl DocFolder for Cache {
10771078
Some(ast_util::local_def(id))
10781079
}
10791080

1081+
RawPointer(..) => {
1082+
let id = PrimitiveRawPointer.to_node_id();
1083+
Some(ast_util::local_def(id))
1084+
}
1085+
10801086
_ => None,
10811087
};
10821088

src/test/auxiliary/issue-15318.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 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(html_root_url = "http://example.com/")]
12+
13+
/// dox
14+
#[doc(primitive = "pointer")]
15+
pub mod ptr {}

src/test/rustdoc/issue-15318-2.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 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+
// aux-build:issue-15318.rs
12+
13+
extern crate issue_15318;
14+
15+
pub use issue_15318::ptr;
16+
17+
// @has issue_15318_2/fn.bar.html \
18+
// '//*[@href="primitive.pointer.html"]' \
19+
// '*mut T'
20+
pub fn bar<T>(ptr: *mut T) {}
21+

src/test/rustdoc/issue-15318-3.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 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+
// @has issue_15318_3/primitive.pointer.html
12+
13+
/// dox
14+
#[doc(primitive = "pointer")]
15+
pub mod ptr {}

src/test/rustdoc/issue-15318.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 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+
// aux-build:issue-15318.rs
12+
13+
#![feature(no_std)]
14+
#![no_std]
15+
16+
extern crate issue_15318;
17+
18+
// @has issue_15318/fn.bar.html \
19+
// '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \
20+
// '*mut T'
21+
pub fn bar<T>(ptr: *mut T) {}

0 commit comments

Comments
 (0)