Skip to content

Commit c72f2b5

Browse files
committed
---
yaml --- r: 106284 b: refs/heads/auto c: 6053102 h: refs/heads/master v: v3
1 parent d22606c commit c72f2b5

File tree

5 files changed

+111
-34
lines changed

5 files changed

+111
-34
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 1f35f834be9b3f1dbbe04cc46ac3a8f72fd381c5
16+
refs/heads/auto: 60531025abdd86b3e777568e58f2041240c52530
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustdoc/clean.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,18 @@ pub enum ItemEnum {
174174
StaticItem(Static),
175175
TraitItem(Trait),
176176
ImplItem(Impl),
177+
/// `use` and `extern crate`
177178
ViewItemItem(ViewItem),
179+
/// A method signature only. Used for required methods in traits (ie,
180+
/// non-default-methods).
178181
TyMethodItem(TyMethod),
182+
/// A method with a body.
179183
MethodItem(Method),
180184
StructFieldItem(StructField),
181185
VariantItem(Variant),
186+
/// `fn`s from an extern block
182187
ForeignFunctionItem(Function),
188+
/// `static`s from an extern block
183189
ForeignStaticItem(Static),
184190
MacroItem(Macro),
185191
}
@@ -1014,11 +1020,23 @@ pub struct Impl {
10141020
generics: Generics,
10151021
trait_: Option<Type>,
10161022
for_: Type,
1017-
methods: Vec<Item> ,
1023+
methods: Vec<Item>,
1024+
derived: bool,
10181025
}
10191026

10201027
impl Clean<Item> for doctree::Impl {
10211028
fn clean(&self) -> Item {
1029+
let mut derived = false;
1030+
for attr in self.attrs.iter() {
1031+
match attr.node.value.node {
1032+
ast::MetaWord(ref s) => {
1033+
if s.get() == "automatically_derived" {
1034+
derived = true;
1035+
}
1036+
}
1037+
_ => {}
1038+
}
1039+
}
10221040
Item {
10231041
name: None,
10241042
attrs: self.attrs.clean(),
@@ -1030,6 +1048,7 @@ impl Clean<Item> for doctree::Impl {
10301048
trait_: self.trait_.clean(),
10311049
for_: self.for_.clean(),
10321050
methods: self.methods.clean(),
1051+
derived: derived,
10331052
}),
10341053
}
10351054
}

branches/auto/src/librustdoc/html/layout.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,53 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
2929
-> fmt::Result
3030
{
3131
write!(dst,
32-
"<!DOCTYPE html>
33-
<html lang=\"en\">
32+
r##"<!DOCTYPE html>
33+
<html lang="en">
3434
<head>
35-
<meta charset=\"utf-8\" />
35+
<meta charset="utf-8" />
3636
<title>{title}</title>
3737
3838
<link href='http://fonts.googleapis.com/css?family=Oswald:700|Inconsolata:400,700'
3939
rel='stylesheet' type='text/css'>
40-
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}main.css\">
40+
<link rel="stylesheet" type="text/css" href="{root_path}main.css">
4141
42-
{favicon, select, none{} other{<link rel=\"shortcut icon\" href=\"#\" />}}
42+
{favicon, select, none{} other{<link rel="shortcut icon" href="\#" />}}
4343
</head>
4444
<body>
4545
<!--[if lte IE 8]>
46-
<div class=\"warning\">
46+
<div class="warning">
4747
This old browser is unsupported and will most likely display funky
4848
things.
4949
</div>
5050
<![endif]-->
5151
52-
<section class=\"sidebar\">
52+
<section class="sidebar">
5353
{logo, select, none{} other{
54-
<a href='{root_path}{krate}/index.html'><img src='#' alt=''/></a>
54+
<a href='{root_path}{krate}/index.html'><img src='\#' alt=''/></a>
5555
}}
5656
5757
{sidebar}
5858
</section>
5959
60-
<nav class=\"sub\">
61-
<form class=\"search-form js-only\">
62-
<button class=\"do-search\">Search</button>
63-
<div class=\"search-container\">
64-
<input class=\"search-input\" name=\"search\"
65-
autocomplete=\"off\"
66-
placeholder=\"Search documentation...\"
67-
type=\"search\" />
60+
<nav class="sub">
61+
<form class="search-form js-only">
62+
<button class="do-search">Search</button>
63+
<div class="search-container">
64+
<input class="search-input" name="search"
65+
autocomplete="off"
66+
placeholder="Search documentation..."
67+
type="search" />
6868
</div>
6969
</form>
7070
</nav>
7171
72-
<section id='main' class=\"content {ty}\">{content}</section>
73-
<section id='search' class=\"content hidden\"></section>
72+
<section id='main' class="content {ty}">{content}</section>
73+
<section id='search' class="content hidden"></section>
7474
75-
<section class=\"footer\"></section>
75+
<section class="footer"></section>
7676
77-
<div id=\"help\" class=\"hidden\">
78-
<div class=\"shortcuts\">
77+
<div id="help" class="hidden">
78+
<div class="shortcuts">
7979
<h1>Keyboard shortcuts</h1>
8080
<dl>
8181
<dt>?</dt>
@@ -86,11 +86,11 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
8686
<dd>Move up in search results</dd>
8787
<dt>&darr;</dt>
8888
<dd>Move down in search results</dd>
89-
<dt>&\\#9166;</dt>
89+
<dt>&\#9166;</dt>
9090
<dd>Go to active search result</dd>
9191
</dl>
9292
</div>
93-
<div class=\"infos\">
93+
<div class="infos">
9494
<h1>Search tricks</h1>
9595
<p>
9696
Prefix searches with a type followed by a colon (e.g.
@@ -106,15 +106,15 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
106106
</div>
107107
108108
<script>
109-
var rootPath = \"{root_path}\";
110-
var currentCrate = \"{krate}\";
109+
var rootPath = "{root_path}";
110+
var currentCrate = "{krate}";
111111
</script>
112-
<script src=\"{root_path}jquery.js\"></script>
113-
<script src=\"{root_path}main.js\"></script>
114-
<script async src=\"{root_path}search-index.js\"></script>
112+
<script src="{root_path}jquery.js"></script>
113+
<script src="{root_path}main.js"></script>
114+
<script async src="{root_path}search-index.js"></script>
115115
</body>
116116
</html>
117-
",
117+
"##,
118118
content = *t,
119119
root_path = page.root_path,
120120
ty = page.ty,

branches/auto/src/librustdoc/html/render.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,8 +1517,22 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
15171517
if traits.len() > 0 {
15181518
try!(write!(w, "<h2 id='implementations'>Trait \
15191519
Implementations</h2>"));
1520-
for &(ref i, ref dox) in traits.move_iter() {
1521-
try!(render_impl(w, i, dox));
1520+
let mut any_derived = false;
1521+
for & &(ref i, ref dox) in traits.iter() {
1522+
if !i.derived {
1523+
try!(render_impl(w, i, dox));
1524+
} else {
1525+
any_derived = true;
1526+
}
1527+
}
1528+
if any_derived {
1529+
try!(write!(w, "<h3 id='derived_implementations'>Derived Implementations \
1530+
</h3>"));
1531+
for &(ref i, ref dox) in traits.move_iter() {
1532+
if i.derived {
1533+
try!(render_impl(w, i, dox));
1534+
}
1535+
}
15221536
}
15231537
}
15241538
}

branches/auto/src/libstd/kinds.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,51 @@ pub trait Pod {
4040
// Empty.
4141
}
4242

43-
/// Types that can be safely shared between threads, hence thread-safe.
43+
/// Types that can be safely shared between tasks when aliased.
44+
///
45+
/// The precise definition is: a type `T` is `Share` if `&T` is
46+
/// thread-safe. In other words, there is no possibility of data races
47+
/// when passing `&T` references between tasks.
48+
///
49+
/// As one would expect, primitive types like `u8` and `f64` are all
50+
/// `Share`, and so are simple aggregate types containing them (like
51+
/// tuples, structs and enums). More instances of basic `Share` types
52+
/// include "immutable" types like `&T` and those with simple
53+
/// inherited mutability, such as `~T`, `Vec<T>` and most other
54+
/// collection types. (Generic parameters need to be `Share` for their
55+
/// container to be `Share`.)
56+
///
57+
/// A somewhat surprising consequence of the definition is `&mut T` is
58+
/// `Share` (if `T` is `Share`) even though it seems that it might
59+
/// provide unsynchronised mutation. The trick is a mutable reference
60+
/// stored in an aliasable reference (that is, `& &mut T`) becomes
61+
/// read-only, as if it were a `& &T`, hence there is no risk of a data
62+
/// race.
63+
///
64+
/// Types that are not `Share` are those that have "interior
65+
/// mutability" in a non-thread-safe way, such as `Cell` and `RefCell`
66+
/// in `std::cell`. These types allow for mutation of their contents
67+
/// even when in an immutable, aliasable slot, e.g. the contents of
68+
/// `&Cell<T>` can be `.set`, and do not ensure data races are
69+
/// impossible, hence they cannot be `Share`. A higher level example
70+
/// of a non-`Share` type is the reference counted pointer
71+
/// `std::rc::Rc`, because any reference `&Rc<T>` can clone a new
72+
/// reference, which modifies the reference counts in a non-atomic
73+
/// way.
74+
///
75+
/// For cases when one does need thread-safe interior mutability,
76+
/// types like the atomics in `std::sync` and `Mutex` & `RWLock` in
77+
/// the `sync` crate do ensure that any mutation cannot cause data
78+
/// races. Hence these types are `Share`.
79+
///
80+
/// Users writing their own types with interior mutability (or anything
81+
/// else that is not thread-safe) should use the `NoShare` marker type
82+
/// (from `std::kinds::marker`) to ensure that the compiler doesn't
83+
/// consider the user-defined type to be `Share`. Any types with
84+
/// interior mutability must also use the `std::ty::Unsafe` wrapper
85+
/// around the value(s) which can be mutated when behind a `&`
86+
/// reference; not doing this is undefined behaviour (for example,
87+
/// `transmute`-ing from `&T` to `&mut T` is illegal).
4488
#[lang="share"]
4589
pub trait Share {
4690
// Empty

0 commit comments

Comments
 (0)