Skip to content

Commit da41920

Browse files
committed
Auto merge of #33768 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests - Successful merges: #33578, #33679, #33743, #33746, #33747, #33750, #33757 - Failed merges:
2 parents 91e9073 + 61b9be7 commit da41920

File tree

8 files changed

+81
-39
lines changed

8 files changed

+81
-39
lines changed

src/doc/book/ownership.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ vector object and its data live in separate memory regions instead of being a
155155
single contiguous memory allocation (due to reasons we will not go into at
156156
this point of time). These two parts of the vector (the one on the stack and
157157
one on the heap) must agree with each other at all times with regards to
158-
things like the length, capacity etc.
158+
things like the length, capacity, etc.
159159

160160
When we move `v` to `v2`, Rust actually does a bitwise copy of the vector
161161
object `v` into the stack allocation represented by `v2`. This shallow copy

src/doc/book/the-stack-and-the-heap.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ And then `bold()` calls `italic()`:
175175
| **2** | **b**|**100**|
176176
| **1** | **a**| **5** |
177177
| 0 | x | 42 |
178+
178179
Whew! Our stack is growing tall.
179180

180181
After `italic()` is over, its frame is deallocated, leaving only `bold()` and
@@ -260,8 +261,7 @@ layout of a program which has been running for a while now:
260261
| (2<sup>30</sup>) - 3 | | |
261262
| (2<sup>30</sup>) - 4 | | 42 |
262263
| ... | ... | ... |
263-
| 3 | y | → (2<sup>30</sup>) - 4 |
264-
| 2 | y | 42 |
264+
| 2 | z | → (2<sup>30</sup>) - 4 |
265265
| 1 | y | 42 |
266266
| 0 | x | → (2<sup>30</sup>) - 1 |
267267

src/doc/book/unsized-types.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ pointers, can use this `impl`.
4747
# ?Sized
4848

4949
If you want to write a function that accepts a dynamically sized type, you
50-
can use the special bound, `?Sized`:
50+
can use the special bound syntax, `?Sized`:
5151

5252
```rust
5353
struct Foo<T: ?Sized> {
5454
f: T,
5555
}
5656
```
5757

58-
This `?`, read as “T may be `Sized`”, means that this bound is special: it
59-
lets us match more kinds, not less. It’s almost like every `T` implicitly has
60-
`T: Sized`, and the `?` undoes this default.
58+
This `?Sized`, read as “T may or may not be `Sized`”, which allows us to match
59+
both sized and unsized types. All generic type parameters implicitly
60+
have the `Sized` bound, so the `?Sized` can be used to opt-out of the implicit
61+
bound.

src/libcollections/slice.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,10 @@ impl<T> [T] {
779779
core_slice::SliceExt::binary_search_by_key(self, b, f)
780780
}
781781

782-
/// Sorts the slice, in place.
783-
///
784782
/// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`.
785783
///
786-
/// This is a stable sort.
784+
/// This sort is stable and `O(n log n)` worst-case but allocates
785+
/// approximately `2 * n` where `n` is the length of `self`.
787786
///
788787
/// # Examples
789788
///
@@ -804,11 +803,9 @@ impl<T> [T] {
804803
/// Sorts the slice, in place, using `key` to extract a key by which to
805804
/// order the sort by.
806805
///
807-
/// This sort is `O(n log n)` worst-case and stable, but allocates
806+
/// This sort is stable and `O(n log n)` worst-case but allocates
808807
/// approximately `2 * n`, where `n` is the length of `self`.
809808
///
810-
/// This is a stable sort.
811-
///
812809
/// # Examples
813810
///
814811
/// ```rust
@@ -828,7 +825,7 @@ impl<T> [T] {
828825
/// Sorts the slice, in place, using `compare` to compare
829826
/// elements.
830827
///
831-
/// This sort is `O(n log n)` worst-case and stable, but allocates
828+
/// This sort is stable and `O(n log n)` worst-case but allocates
832829
/// approximately `2 * n`, where `n` is the length of `self`.
833830
///
834831
/// # Examples

src/librustc_typeck/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1002,18 +1002,18 @@ operate on.
10021002
This will cause an error:
10031003
10041004
```compile_fail
1005-
#![feature(simd)]
1005+
#![feature(repr_simd)]
10061006
1007-
#[simd]
1007+
#[repr(simd)]
10081008
struct Bad;
10091009
```
10101010
10111011
This will not:
10121012
10131013
```
1014-
#![feature(simd)]
1014+
#![feature(repr_simd)]
10151015
1016-
#[simd]
1016+
#[repr(simd)]
10171017
struct Good(u32);
10181018
```
10191019
"##,

src/librustdoc/html/render.rs

+43-12
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,19 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
16581658
Ok(())
16591659
}
16601660

1661+
fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLink) -> fmt::Result {
1662+
if let Some(s) = item.doc_value() {
1663+
let markdown = if s.contains('\n') {
1664+
format!("{} [Read more]({})",
1665+
&plain_summary_line(Some(s)), naive_assoc_href(item, link))
1666+
} else {
1667+
format!("{}", &plain_summary_line(Some(s)))
1668+
};
1669+
write!(w, "<div class='docblock'>{}</div>", Markdown(&markdown))?;
1670+
}
1671+
Ok(())
1672+
}
1673+
16611674
fn item_module(w: &mut fmt::Formatter, cx: &Context,
16621675
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
16631676
document(w, cx, item)?;
@@ -2555,8 +2568,9 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
25552568
}
25562569

25572570
fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
2558-
link: AssocItemLink, render_static: bool, is_default_item: bool,
2559-
outer_version: Option<&str>) -> fmt::Result {
2571+
link: AssocItemLink, render_static: bool,
2572+
is_default_item: bool, outer_version: Option<&str>,
2573+
trait_: Option<&clean::Trait>) -> fmt::Result {
25602574
let shortty = shortty(item);
25612575
let name = item.name.as_ref().unwrap();
25622576

@@ -2607,16 +2621,35 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
26072621
_ => panic!("can't make docs for trait item with name {:?}", item.name)
26082622
}
26092623

2610-
if !is_default_item && (!is_static || render_static) {
2611-
document(w, cx, item)
2612-
} else {
2613-
Ok(())
2624+
if !is_static || render_static {
2625+
if !is_default_item {
2626+
2627+
if item.doc_value().is_some() {
2628+
document(w, cx, item)?;
2629+
} else {
2630+
// In case the item isn't documented,
2631+
// provide short documentation from the trait
2632+
if let Some(t) = trait_ {
2633+
if let Some(it) = t.items.iter()
2634+
.find(|i| i.name == item.name) {
2635+
document_short(w, it, link)?;
2636+
}
2637+
}
2638+
}
2639+
} else {
2640+
document_short(w, item, link)?;
2641+
}
26142642
}
2643+
Ok(())
26152644
}
26162645

2646+
let traits = &cache().traits;
2647+
let trait_ = i.trait_did().and_then(|did| traits.get(&did));
2648+
26172649
write!(w, "<div class='impl-items'>")?;
26182650
for trait_item in &i.inner_impl().items {
2619-
doctraititem(w, cx, trait_item, link, render_header, false, outer_version)?;
2651+
doctraititem(w, cx, trait_item, link, render_header,
2652+
false, outer_version, trait_)?;
26202653
}
26212654

26222655
fn render_default_items(w: &mut fmt::Formatter,
@@ -2634,17 +2667,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
26342667
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
26352668

26362669
doctraititem(w, cx, trait_item, assoc_link, render_static, true,
2637-
outer_version)?;
2670+
outer_version, None)?;
26382671
}
26392672
Ok(())
26402673
}
26412674

26422675
// If we've implemented a trait, then also emit documentation for all
26432676
// default items which weren't overridden in the implementation block.
2644-
if let Some(did) = i.trait_did() {
2645-
if let Some(t) = cache().traits.get(&did) {
2646-
render_default_items(w, cx, t, &i.inner_impl(), render_header, outer_version)?;
2647-
}
2677+
if let Some(t) = trait_ {
2678+
render_default_items(w, cx, t, &i.inner_impl(), render_header, outer_version)?;
26482679
}
26492680
write!(w, "</div>")?;
26502681
Ok(())

src/libstd/sync/once.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ unsafe impl Send for Once {}
101101

102102
/// State yielded to the `call_once_force` method which can be used to query
103103
/// whether the `Once` was previously poisoned or not.
104-
#[unstable(feature = "once_poison", issue = "31688")]
104+
#[unstable(feature = "once_poison", issue = "33577")]
105105
pub struct OnceState {
106106
poisoned: bool,
107107
}
@@ -218,7 +218,7 @@ impl Once {
218218
/// The closure `f` is yielded a structure which can be used to query the
219219
/// state of this `Once` (whether initialization has previously panicked or
220220
/// not).
221-
#[unstable(feature = "once_poison", issue = "31688")]
221+
#[unstable(feature = "once_poison", issue = "33577")]
222222
pub fn call_once_force<F>(&'static self, f: F) where F: FnOnce(&OnceState) {
223223
// same as above, just with a different parameter to `call_inner`.
224224
if self.state.load(Ordering::SeqCst) == COMPLETE {
@@ -360,7 +360,7 @@ impl OnceState {
360360
///
361361
/// Once an initalization routine for a `Once` has panicked it will forever
362362
/// indicate to future forced initialization routines that it is poisoned.
363-
#[unstable(feature = "once_poison", issue = "31688")]
363+
#[unstable(feature = "once_poison", issue = "33577")]
364364
pub fn poisoned(&self) -> bool {
365365
self.poisoned
366366
}

src/test/rustdoc/manual_impl.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,24 @@ pub trait T {
2121
fn b_method(&self) -> usize {
2222
self.a_method()
2323
}
24+
25+
/// Docs associated with the trait c_method definition.
26+
///
27+
/// There is another line
28+
fn c_method(&self) -> usize {
29+
self.a_method()
30+
}
2431
}
2532

2633
// @has manual_impl/struct.S1.html '//*[@class="trait"]' 'T'
2734
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
2835
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
2936
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
30-
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
37+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
38+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
39+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
40+
// @!has - '//*[@class="docblock"]' 'There is another line'
41+
// @has - '//*[@class="docblock"]' 'Read more'
3142
pub struct S1(usize);
3243

3344
/// Docs associated with the S1 trait implementation.
@@ -41,9 +52,11 @@ impl T for S1 {
4152
// @has manual_impl/struct.S2.html '//*[@class="trait"]' 'T'
4253
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.'
4354
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.'
44-
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait b_method implementation.'
55+
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
4556
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
46-
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
57+
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
58+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
59+
// @!has - '//*[@class="docblock"]' 'Read more'
4760
pub struct S2(usize);
4861

4962
/// Docs associated with the S2 trait implementation.
@@ -53,16 +66,16 @@ impl T for S2 {
5366
self.0
5467
}
5568

56-
/// Docs associated with the S2 trait b_method implementation.
57-
fn b_method(&self) -> usize {
69+
/// Docs associated with the S2 trait c_method implementation.
70+
fn c_method(&self) -> usize {
5871
5
5972
}
6073
}
6174

6275
// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
6376
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
6477
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
65-
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
78+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
6679
pub struct S3(usize);
6780

6881
/// Docs associated with the S3 trait implementation.

0 commit comments

Comments
 (0)