Skip to content

Commit 4e2b503

Browse files
committed
---
yaml --- r: 234392 b: refs/heads/tmp c: 9b52c5b h: refs/heads/master v: v3
1 parent 3a16e5f commit 4e2b503

File tree

6 files changed

+83
-50
lines changed

6 files changed

+83
-50
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 01b9cc58ba0c91ec265d8c1ad9225b2ca777464e
28+
refs/heads/tmp: 9b52c5bfff16a5f95c04a01325c55881f652a802
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/doc/index.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,13 @@ series of small examples.
2020

2121
[rbe]: http://rustbyexample.com/
2222

23-
# Language Reference
24-
25-
Rust does not have an exact specification yet, but an effort to describe as much of
26-
the language in as much detail as possible is in [the reference](reference.html).
27-
28-
# Standard Library Reference
23+
# The Standard Library
2924

3025
We have [API documentation for the entire standard
3126
library](std/index.html). There's a list of crates on the left with more
3227
specific sections, or you can use the search bar at the top to search for
3328
something if you know its name.
3429

35-
# Tools
36-
37-
[Cargo](https://crates.io) is the Rust's package manager providing access to libraries
38-
beyond the standard one, and its website contains lots of good documentation.
39-
40-
[`rustdoc`](book/documentation.html) is the Rust's documentation generator, a tool converting
41-
annotated source code into HTML docs.
42-
43-
A bunch of non-official tools are available, such as [Racer](https://github.com/phildawes/racer)
44-
(code completion engine), or [rustfmt](https://github.com/nrc/rustfmt) (source code formatter),
45-
or text editor plugins.
46-
4730
# Community & Getting Help
4831

4932
If you need help with something, or just want to talk about Rust with others,
@@ -71,10 +54,25 @@ There is an active [subreddit](https://reddit.com/r/rust) with lots of
7154
discussion and news about Rust.
7255

7356
There is also a [user forum](https://users.rust-lang.org), for all
74-
user-oriented discussion, and a [developer
57+
user-oriented discussion, and a [developer
7558
forum](https://internals.rust-lang.org/), where the development of Rust
7659
itself is discussed.
7760

61+
# Specification
62+
63+
Rust does not have an exact specification, but an effort to describe as much of
64+
the language in as much detail as possible is in [the reference](reference.html).
65+
66+
# Tools
67+
68+
Rust is still a young language, so there isn't a ton of tooling yet, but the
69+
tools we have are really nice.
70+
71+
[Cargo](https://crates.io) is Rust's package manager, and its website contains
72+
lots of good documentation.
73+
74+
[`rustdoc`](book/documentation.html) is used to generate documentation for Rust code.
75+
7876
# FAQs
7977

8078
There are questions that are asked quite often, so we've made FAQs for them:

branches/tmp/src/doc/nomicon/vec-drain.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,14 @@ impl<'a, T> Drop for Drain<'a, T> {
129129
130130
impl<T> Vec<T> {
131131
pub fn drain(&mut self) -> Drain<T> {
132-
unsafe {
133-
let iter = RawValIter::new(&self);
134-
135-
// this is a mem::forget safety thing. If Drain is forgotten, we just
136-
// leak the whole Vec's contents. Also we need to do this *eventually*
137-
// anyway, so why not do it now?
138-
self.len = 0;
132+
// this is a mem::forget safety thing. If Drain is forgotten, we just
133+
// leak the whole Vec's contents. Also we need to do this eventually
134+
// anyway, so why not do it now?
135+
self.len = 0;
139136
137+
unsafe {
140138
Drain {
141-
iter: iter,
139+
iter: RawValIter::new(&self),
142140
vec: PhantomData,
143141
}
144142
}

branches/tmp/src/doc/nomicon/vec-final.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,13 @@ impl<T> Vec<T> {
155155
}
156156

157157
pub fn drain(&mut self) -> Drain<T> {
158+
// this is a mem::forget safety thing. If this is forgotten, we just
159+
// leak the whole Vec's contents. Also we need to do this *eventually*
160+
// anyway, so why not do it now?
161+
self.len = 0;
158162
unsafe {
159-
let iter = RawValIter::new(&self);
160-
161-
// this is a mem::forget safety thing. If Drain is forgotten, we just
162-
// leak the whole Vec's contents. Also we need to do this *eventually*
163-
// anyway, so why not do it now?
164-
self.len = 0;
165-
166163
Drain {
167-
iter: iter,
164+
iter: RawValIter::new(&self),
168165
vec: PhantomData,
169166
}
170167
}

branches/tmp/src/libgraphviz/lib.rs

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ pub enum LabelText<'a> {
313313
/// are also the escape sequences `\l` which left-justifies the
314314
/// preceding line and `\r` which right-justifies it.
315315
EscStr(Cow<'a, str>),
316+
317+
/// This uses a graphviz [HTML string label][html]. The string is
318+
/// printed exactly as given, but between `<` and `>`. **No
319+
/// escaping is performed.**
320+
///
321+
/// [html]: http://www.graphviz.org/content/node-shapes#html
322+
HtmlStr(Cow<'a, str>),
316323
}
317324

318325
/// The style for a node or edge.
@@ -453,6 +460,14 @@ pub trait Labeller<'a,N,E> {
453460
/// is a valid DOT identifier.
454461
fn node_id(&'a self, n: &N) -> Id<'a>;
455462

463+
/// Maps `n` to one of the [graphviz `shape` names][1]. If `None`
464+
/// is returned, no `shape` attribute is specified.
465+
///
466+
/// [1]: http://www.graphviz.org/content/node-shapes
467+
fn node_shape(&'a self, _node: &N) -> Option<LabelText<'a>> {
468+
None
469+
}
470+
456471
/// Maps `n` to a label that will be used in the rendered output.
457472
/// The label need not be unique, and may be the empty string; the
458473
/// default is just the output from `node_id`.
@@ -479,6 +494,16 @@ pub trait Labeller<'a,N,E> {
479494
}
480495
}
481496

497+
/// Escape tags in such a way that it is suitable for inclusion in a
498+
/// Graphviz HTML label.
499+
pub fn escape_html(s: &str) -> String {
500+
s
501+
.replace("&", "&amp;")
502+
.replace("\"", "&quot;")
503+
.replace("<", "&lt;")
504+
.replace(">", "&gt;")
505+
}
506+
482507
impl<'a> LabelText<'a> {
483508
pub fn label<S:IntoCow<'a, str>>(s: S) -> LabelText<'a> {
484509
LabelStr(s.into_cow())
@@ -488,6 +513,10 @@ impl<'a> LabelText<'a> {
488513
EscStr(s.into_cow())
489514
}
490515

516+
pub fn html<S:IntoCow<'a, str>>(s: S) -> LabelText<'a> {
517+
HtmlStr(s.into_cow())
518+
}
519+
491520
fn escape_char<F>(c: char, mut f: F) where F: FnMut(char) {
492521
match c {
493522
// not escaping \\, since Graphviz escString needs to
@@ -505,10 +534,12 @@ impl<'a> LabelText<'a> {
505534
}
506535

507536
/// Renders text as string suitable for a label in a .dot file.
508-
pub fn escape(&self) -> String {
537+
/// This includes quotes or suitable delimeters.
538+
pub fn to_dot_string(&self) -> String {
509539
match self {
510-
&LabelStr(ref s) => s.escape_default(),
511-
&EscStr(ref s) => LabelText::escape_str(&s[..]),
540+
&LabelStr(ref s) => format!("\"{}\"", s.escape_default()),
541+
&EscStr(ref s) => format!("\"{}\"", LabelText::escape_str(&s[..])),
542+
&HtmlStr(ref s) => format!("<{}>", s),
512543
}
513544
}
514545

@@ -524,6 +555,7 @@ impl<'a> LabelText<'a> {
524555
} else {
525556
s
526557
},
558+
HtmlStr(s) => s,
527559
}
528560
}
529561

@@ -612,14 +644,15 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
612644
try!(indent(w));
613645
let id = g.node_id(n);
614646

615-
let escaped = &g.node_label(n).escape();
647+
let escaped = &g.node_label(n).to_dot_string();
648+
let shape;
616649

617650
let mut text = vec![id.as_slice()];
618651

619652
if !options.contains(&RenderOption::NoNodeLabels) {
620-
text.push("[label=\"");
653+
text.push("[label=");
621654
text.push(escaped);
622-
text.push("\"]");
655+
text.push("]");
623656
}
624657

625658
let style = g.node_style(n);
@@ -629,12 +662,19 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
629662
text.push("\"]");
630663
}
631664

665+
if let Some(s) = g.node_shape(n) {
666+
shape = s.to_dot_string();
667+
text.push("[shape=");
668+
text.push(&shape);
669+
text.push("]");
670+
}
671+
632672
text.push(";");
633673
try!(writeln(w, &text));
634674
}
635675

636676
for e in g.edges().iter() {
637-
let escaped_label = &g.edge_label(e).escape();
677+
let escaped_label = &g.edge_label(e).to_dot_string();
638678
try!(indent(w));
639679
let source = g.source(e);
640680
let target = g.target(e);
@@ -644,9 +684,9 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
644684
let mut text = vec![source_id.as_slice(), " -> ", target_id.as_slice()];
645685

646686
if !options.contains(&RenderOption::NoEdgeLabels) {
647-
text.push("[label=\"");
687+
text.push("[label=");
648688
text.push(escaped_label);
649-
text.push("\"]");
689+
text.push("]");
650690
}
651691

652692
let style = g.edge_style(e);
@@ -667,7 +707,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
667707
mod tests {
668708
use self::NodeLabels::*;
669709
use super::{Id, Labeller, Nodes, Edges, GraphWalk, render, Style};
670-
use super::LabelText::{self, LabelStr, EscStr};
710+
use super::LabelText::{self, LabelStr, EscStr, HtmlStr};
671711
use std::io;
672712
use std::io::prelude::*;
673713
use std::borrow::IntoCow;
@@ -805,12 +845,12 @@ mod tests {
805845
fn node_id(&'a self, n: &Node) -> Id<'a> { self.graph.node_id(n) }
806846
fn node_label(&'a self, n: &Node) -> LabelText<'a> {
807847
match self.graph.node_label(n) {
808-
LabelStr(s) | EscStr(s) => EscStr(s),
848+
LabelStr(s) | EscStr(s) | HtmlStr(s) => EscStr(s),
809849
}
810850
}
811851
fn edge_label(&'a self, e: & &'a Edge) -> LabelText<'a> {
812852
match self.graph.edge_label(e) {
813-
LabelStr(s) | EscStr(s) => EscStr(s),
853+
LabelStr(s) | EscStr(s) | HtmlStr(s) => EscStr(s),
814854
}
815855
}
816856
}

branches/tmp/src/test/compile-fail/feature-gate-rustc-attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
1414

15-
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is an experimental feature
16-
#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is an experimental feature
15+
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
16+
#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
1717
#[rustc_move_fragments] //~ ERROR the `#[rustc_move_fragments]` attribute is an experimental feature
1818
#[rustc_foo]
1919
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics

0 commit comments

Comments
 (0)