Skip to content

Commit 25c2a82

Browse files
committed
---
yaml --- r: 233515 b: refs/heads/beta c: 6f6ea46 h: refs/heads/master i: 233513: 8849add 233511: 353603b v: v3
1 parent c64363a commit 25c2a82

File tree

5 files changed

+7
-63
lines changed

5 files changed

+7
-63
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 6c11e4a48ec3ac385f32da1879384bc6921bdf75
26+
refs/heads/beta: 6f6ea4687e9d596d7136dc591dee312e51fa0ad7
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/doc/trpl/trait-objects.md

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -300,41 +300,3 @@ let y = TraitObject {
300300
// y.method();
301301
(y.vtable.method)(y.data);
302302
```
303-
304-
## Object Safety
305-
306-
Not every trait can be used to make a trait object. For example, vectors implement
307-
`Clone`, but if we try to make a trait object:
308-
309-
```ignore
310-
let v = vec![1, 2, 3];
311-
let o = &v as &Clone;
312-
```
313-
314-
We get an error:
315-
316-
```text
317-
error: cannot convert to a trait object because trait `core::clone::Clone` is not object-safe [E0038]
318-
let o = &v as &Clone;
319-
^~
320-
note: the trait cannot require that `Self : Sized`
321-
let o = &v as &Clone;
322-
^~
323-
```
324-
325-
The error says that `Clone` is not ‘object-safe’. Only traits that are
326-
object-safe can be made into trait objects. A trait is object-safe if both of
327-
these are true:
328-
329-
* the trait does not require that `Self: Sized`
330-
* all of its methods are object-safe
331-
332-
So what makes a method object-safe? Each method must require that `Self: Sized`
333-
or all of the following:
334-
335-
* must not have any type parameters
336-
* must not use `Self`
337-
338-
Whew! As we can see, almost all of these rules talk about `Self`. A good intuition
339-
is “except in special circumstances, if your trait’s method uses `Self`, it is not
340-
object-safe.”

branches/beta/src/libcollections/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
//! // 7
113113
//! // +-----------------+
114114
//! // | |
115-
//! // v 1 2 |
115+
//! // v 1 2 | 2
116116
//! // 0 -----> 1 -----> 3 ---> 4
117117
//! // | ^ ^ ^
118118
//! // | | 1 | |

branches/beta/src/libcollections/btree/node.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -387,29 +387,8 @@ impl<K, V> Node<K, V> {
387387

388388
#[inline]
389389
pub fn as_slices_internal_mut<'b>(&'b mut self) -> MutNodeSlice<'b, K, V> {
390-
let len = self.len();
391-
let is_leaf = self.is_leaf();
392-
let keys = unsafe { slice::from_raw_parts_mut(*self.keys, len) };
393-
let vals = unsafe { slice::from_raw_parts_mut(*self.vals, len) };
394-
let edges: &mut [_] = if is_leaf {
395-
&mut []
396-
} else {
397-
unsafe {
398-
let data = match self.edges {
399-
None => heap::EMPTY as *mut Node<K,V>,
400-
Some(ref mut p) => **p as *mut Node<K,V>,
401-
};
402-
slice::from_raw_parts_mut(data, len + 1)
403-
}
404-
};
405-
MutNodeSlice {
406-
keys: keys,
407-
vals: vals,
408-
edges: edges,
409-
head_is_edge: true,
410-
tail_is_edge: true,
411-
has_edges: !is_leaf,
412-
}
390+
// FIXME(#27620): Bad: This relies on structure layout!
391+
unsafe { mem::transmute(self.as_slices_internal()) }
413392
}
414393

415394
#[inline]

branches/beta/src/libstd/io/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,9 @@ pub trait Seek {
10601060
/// A seek beyond the end of a stream is allowed, but implementation
10611061
/// defined.
10621062
///
1063+
/// The behavior when seeking past the end of the stream is implementation
1064+
/// defined.
1065+
///
10631066
/// If the seek operation completed successfully,
10641067
/// this method returns the new position from the start of the stream.
10651068
/// That position can be used later with `SeekFrom::Start`.

0 commit comments

Comments
 (0)