Skip to content

Commit a0f6d18

Browse files
committed
---
yaml --- r: 212436 b: refs/heads/master c: cb31373 h: refs/heads/master v: v3
1 parent 0c12bff commit a0f6d18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+159
-492
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7d9427e6cd798e24b4be633aa4bf459bd232400c
2+
refs/heads/master: cb31373dc26ca447f7a4a142b2ed352677fb55a0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/src/doc/grammar.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
281281
## Macros
282282

283283
```antlr
284-
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ';'
285-
| "macro_rules" '!' ident '{' macro_rule * '}' ;
284+
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ;
286285
macro_rule : '(' matcher * ')' "=>" '(' transcriber * ')' ';' ;
287286
matcher : '(' matcher * ')' | '[' matcher * ']'
288287
| '{' matcher * '}' | '$' ident ':' ident

trunk/src/doc/trpl/enums.md

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,45 +64,3 @@ equality yet, but we’ll find out in the [`traits`][traits] section.
6464
[match]: match.html
6565
[if-let]: if-let.html
6666
[traits]: traits.html
67-
68-
# Constructors as functions
69-
70-
An enum’s constructors can also be used like functions. For example:
71-
72-
```rust
73-
# enum Message {
74-
# Write(String),
75-
# }
76-
let m = Message::Write("Hello, world".to_string());
77-
```
78-
79-
Is the same as
80-
81-
```rust
82-
# enum Message {
83-
# Write(String),
84-
# }
85-
fn foo(x: String) -> Message {
86-
Message::Write(x)
87-
}
88-
89-
let x = foo("Hello, world".to_string());
90-
```
91-
92-
This is not immediately useful to us, but when we get to
93-
[`closures`][closures], we’ll talk about passing functions as arguments to
94-
other functions. For example, with [`iterators`][iterators], we can do this
95-
to convert a vector of `String`s into a vector of `Message::Write`s:
96-
97-
```rust
98-
# enum Message {
99-
# Write(String),
100-
# }
101-
102-
let v = vec!["Hello".to_string(), "World".to_string()];
103-
104-
let v1: Vec<Message> = v.into_iter().map(Message::Write).collect();
105-
```
106-
107-
[closures]: closures.html
108-
[iterators]: iterators.html

trunk/src/doc/trpl/ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ However it is often desired that the callback is targeted to a special
238238
Rust object. This could be the object that represents the wrapper for the
239239
respective C object.
240240
241-
This can be achieved by passing an raw pointer to the object down to the
241+
This can be achieved by passing an unsafe pointer to the object down to the
242242
C library. The C library can then include the pointer to the Rust object in
243243
the notification. This will allow the callback to unsafely access the
244244
referenced Rust object.
@@ -370,7 +370,7 @@ On OSX, frameworks behave with the same semantics as a dynamic library.
370370
371371
# Unsafe blocks
372372
373-
Some operations, like dereferencing raw pointers or calling functions that have been marked
373+
Some operations, like dereferencing unsafe pointers or calling functions that have been marked
374374
unsafe are only allowed inside unsafe blocks. Unsafe blocks isolate unsafety and are a promise to
375375
the compiler that the unsafety does not leak out of the block.
376376

trunk/src/doc/trpl/raw-pointers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ println!("raw points at {}", *raw);
5252
It gives this error:
5353

5454
```text
55-
error: dereference of raw pointer requires unsafe function or block [E0133]
56-
println!("raw points at {}", *raw);
57-
^~~~
55+
error: dereference of unsafe pointer requires unsafe function or block [E0133]
56+
println!("raw points at{}", *raw);
57+
^~~~
5858
```
5959

6060
When you dereference a raw pointer, you’re taking responsibility that it’s not

trunk/src/doc/trpl/strings.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,30 +117,6 @@ let dog = hachiko.chars().nth(1); // kinda like hachiko[1]
117117

118118
This emphasizes that we have to go through the whole list of `chars`.
119119

120-
## Slicing
121-
122-
You can get a slice of a string with slicing syntax:
123-
124-
```rust
125-
let dog = "hachiko";
126-
let hachi = &dog[0..5];
127-
```
128-
129-
But note that these are _byte_ offsets, not _character_ offsets. So
130-
this will fail at runtime:
131-
132-
```rust,should_panic
133-
let dog = "忠犬ハチ公";
134-
let hachi = &dog[0..2];
135-
```
136-
137-
with this error:
138-
139-
```text
140-
thread '<main>' panicked at 'index 0 and/or 2 in `忠犬ハチ公` do not lie on
141-
character boundary'
142-
```
143-
144120
## Concatenation
145121

146122
If you have a `String`, you can concatenate a `&str` to the end of it:

trunk/src/liballoc/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
//!
2323
//! ## Boxed values
2424
//!
25-
//! The [`Box`](boxed/index.html) type is a smart pointer type. There can
26-
//! only be one owner of a `Box`, and the owner can decide to mutate the
27-
//! contents, which live on the heap.
25+
//! The [`Box`](boxed/index.html) type is the core owned pointer type in Rust.
26+
//! There can only be one owner of a `Box`, and the owner can decide to mutate
27+
//! the contents, which live on the heap.
2828
//!
2929
//! This type can be sent among threads efficiently as the size of a `Box` value
3030
//! is the same as that of a pointer. Tree-like data structures are often built

trunk/src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<T> [T] {
370370
core_slice::SliceExt::get_unchecked_mut(self, index)
371371
}
372372

373-
/// Returns an raw pointer to the slice's buffer
373+
/// Returns an unsafe pointer to the slice's buffer
374374
///
375375
/// The caller must ensure that the slice outlives the pointer this
376376
/// function returns, or else it will end up pointing to garbage.

trunk/src/libcollections/str.rs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl str {
525525
core_str::StrExt::as_bytes(&self[..])
526526
}
527527

528-
/// Returns a raw pointer to the `&str`'s buffer.
528+
/// Returns an unsafe pointer to the `&str`'s buffer.
529529
///
530530
/// The caller must ensure that the string outlives this pointer, and
531531
/// that it is not
@@ -1180,8 +1180,9 @@ impl str {
11801180
/// matched by a pattern.
11811181
///
11821182
/// The pattern can be a simple `&str`, `char`, or a closure that
1183-
/// determines the split. Additional libraries might provide more complex
1184-
/// patterns like regular expressions.
1183+
/// determines the split.
1184+
/// Additional libraries might provide more complex patterns like
1185+
/// regular expressions.
11851186
///
11861187
/// # Iterator behavior
11871188
///
@@ -1223,32 +1224,6 @@ impl str {
12231224
/// let v: Vec<&str> = "abc1defXghi".split(|c| c == '1' || c == 'X').collect();
12241225
/// assert_eq!(v, ["abc", "def", "ghi"]);
12251226
/// ```
1226-
///
1227-
/// If a string contains multiple contiguous separators, you will end up
1228-
/// with empty strings in the output:
1229-
///
1230-
/// ```
1231-
/// let x = "||||a||b|c".to_string();
1232-
/// let d: Vec<_> = x.split('|').collect();
1233-
///
1234-
/// assert_eq!(d, &["", "", "", "", "a", "", "b", "c"]);
1235-
/// ```
1236-
///
1237-
/// This can lead to possibly surprising behavior when whitespace is used
1238-
/// as the separator. This code is correct:
1239-
///
1240-
/// ```
1241-
/// let x = " a b c".to_string();
1242-
/// let d: Vec<_> = x.split(' ').collect();
1243-
///
1244-
/// assert_eq!(d, &["", "", "", "", "a", "", "b", "c"]);
1245-
/// ```
1246-
///
1247-
/// It does _not_ give you:
1248-
///
1249-
/// ```rust,ignore
1250-
/// assert_eq!(d, &["a", "b", "c"]);
1251-
/// ```
12521227
#[stable(feature = "rust1", since = "1.0.0")]
12531228
pub fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P> {
12541229
core_str::StrExt::split(&self[..], pat)

trunk/src/libcollections/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,9 +1213,9 @@ impl<T: PartialEq> Vec<T> {
12131213
// Duplicate, advance r. End of vec. Truncate to w.
12141214

12151215
let ln = self.len();
1216-
if ln < 1 { return; }
1216+
if ln <= 1 { return; }
12171217

1218-
// Avoid bounds checks by using raw pointers.
1218+
// Avoid bounds checks by using unsafe pointers.
12191219
let p = self.as_mut_ptr();
12201220
let mut r: usize = 1;
12211221
let mut w: usize = 1;

trunk/src/libcore/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use marker::Sized;
4646

4747
extern "rust-intrinsic" {
4848

49-
// NB: These intrinsics take raw pointers because they mutate aliased
49+
// NB: These intrinsics take unsafe pointers because they mutate aliased
5050
// memory, which is not valid for either `&` or `&mut`.
5151

5252
pub fn atomic_cxchg<T>(dst: *mut T, old: T, src: T) -> T;

trunk/src/libcore/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ macro_rules! impls{
357357
/// struct is dropped, it may in turn drop one or more instances of
358358
/// the type `T`, though that may not be apparent from the other
359359
/// structure of the type itself. This is commonly necessary if the
360-
/// structure is using a raw pointer like `*mut T` whose referent
360+
/// structure is using an unsafe pointer like `*mut T` whose referent
361361
/// may be dropped when the type is dropped, as a `*mut T` is
362362
/// otherwise not treated as owned.
363363
///

trunk/src/libcore/ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
// FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory
1212

13-
//! Operations on raw pointers, `*const T`, and `*mut T`.
13+
//! Operations on unsafe pointers, `*const T`, and `*mut T`.
1414
//!
15-
//! Working with raw pointers in Rust is uncommon,
15+
//! Working with unsafe pointers in Rust is uncommon,
1616
//! typically limited to a few patterns.
1717
//!
1818
//! Use the `null` function to create null pointers, and the `is_null` method
1919
//! of the `*const T` type to check for null. The `*const T` type also defines
2020
//! the `offset` method, for pointer math.
2121
//!
22-
//! # Common ways to create raw pointers
22+
//! # Common ways to create unsafe pointers
2323
//!
2424
//! ## 1. Coerce a reference (`&T`) or mutable reference (`&mut T`).
2525
//!
@@ -86,7 +86,7 @@
8686
//!
8787
//! Usually you wouldn't literally use `malloc` and `free` from Rust,
8888
//! but C APIs hand out a lot of pointers generally, so are a common source
89-
//! of raw pointers in Rust.
89+
//! of unsafe pointers in Rust.
9090
9191
#![stable(feature = "rust1", since = "1.0.0")]
9292
#![doc(primitive = "pointer")]

trunk/src/librustc/middle/check_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
//
1414
// - For each *mutable* static item, it checks that its **type**:
1515
// - doesn't have a destructor
16-
// - doesn't own a box
16+
// - doesn't own an owned pointer
1717
//
1818
// - For each *immutable* static item, it checks that its **value**:
19-
// - doesn't own a box
19+
// - doesn't own owned, managed pointers
2020
// - doesn't contain a struct literal or a call to an enum variant / struct constructor where
2121
// - the type of the struct/enum has a dtor
2222
//

trunk/src/librustc/middle/effect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
162162
debug!("effect: unary case, base type is {}",
163163
ppaux::ty_to_string(self.tcx, base_type));
164164
if let ty::ty_ptr(_) = base_type.sty {
165-
self.require_unsafe(expr.span, "dereference of raw pointer")
165+
self.require_unsafe(expr.span, "dereference of unsafe pointer")
166166
}
167167
}
168168
ast::ExprAssign(ref base, _) | ast::ExprAssignOp(_, ref base, _) => {

trunk/src/librustc/middle/infer/freshen.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
104104
}
105105

106106
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
107-
if !ty::type_needs_infer(t) && !ty::type_has_erasable_regions(t) {
108-
return t;
109-
}
110-
111107
let tcx = self.infcx.tcx;
112108

113109
match t.sty {

trunk/src/librustc/middle/infer/higher_ranked/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
530530
* details.
531531
*/
532532

533-
let (result, map) = ty_fold::replace_late_bound_regions(infcx.tcx, binder, |br| {
533+
let (result, map) = ty::replace_late_bound_regions(infcx.tcx, binder, |br| {
534534
infcx.region_vars.new_skolemized(br, &snapshot.region_vars_snapshot)
535535
});
536536

trunk/src/librustc/middle/infer/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ use middle::free_region::FreeRegionMap;
2626
use middle::subst;
2727
use middle::subst::Substs;
2828
use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, UnconstrainedNumeric};
29+
use middle::ty::replace_late_bound_regions;
2930
use middle::ty::{self, Ty};
30-
use middle::ty_fold::{self, TypeFolder, TypeFoldable};
31+
use middle::ty_fold::{TypeFolder, TypeFoldable};
3132
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
3233
use rustc_data_structures::unify::{self, UnificationTable};
3334
use std::cell::{RefCell};
@@ -1037,7 +1038,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10371038
-> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
10381039
where T : TypeFoldable<'tcx> + Repr<'tcx>
10391040
{
1040-
ty_fold::replace_late_bound_regions(
1041+
ty::replace_late_bound_regions(
10411042
self.tcx,
10421043
value,
10431044
|br| self.next_region_var(LateBoundRegion(span, br, lbrct)))

trunk/src/librustc/middle/mem_categorization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ pub enum AliasableReason {
14101410

14111411
impl<'tcx> cmt_<'tcx> {
14121412
pub fn guarantor(&self) -> cmt<'tcx> {
1413-
//! Returns `self` after stripping away any derefs or
1413+
//! Returns `self` after stripping away any owned pointer derefs or
14141414
//! interior content. The return value is basically the `cmt` which
14151415
//! determines how long the value in `self` remains live.
14161416
@@ -1546,7 +1546,7 @@ impl<'tcx> cmt_<'tcx> {
15461546
format!("`Box` content")
15471547
}
15481548
UnsafePtr(..) => {
1549-
format!("dereference of raw pointer")
1549+
format!("dereference of unsafe pointer")
15501550
}
15511551
BorrowedPtr(..) => {
15521552
format!("borrowed content")

trunk/src/librustc/middle/pat_util.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,34 +135,22 @@ pub fn pat_contains_bindings(dm: &DefMap, pat: &ast::Pat) -> bool {
135135
contains_bindings
136136
}
137137

138-
/// Checks if the pattern contains any `ref` or `ref mut` bindings,
139-
/// and if yes wether its containing mutable ones or just immutables ones.
140-
pub fn pat_contains_ref_binding(dm: &DefMap, pat: &ast::Pat) -> Option<ast::Mutability> {
141-
let mut result = None;
138+
/// Checks if the pattern contains any `ref` or `ref mut` bindings.
139+
pub fn pat_contains_ref_binding(dm: &DefMap, pat: &ast::Pat) -> bool {
140+
let mut result = false;
142141
pat_bindings(dm, pat, |mode, _, _, _| {
143142
match mode {
144-
ast::BindingMode::BindByRef(m) => {
145-
// Pick Mutable as maximum
146-
match result {
147-
None | Some(ast::MutImmutable) => result = Some(m),
148-
_ => (),
149-
}
150-
}
143+
ast::BindingMode::BindByRef(_) => { result = true; }
151144
ast::BindingMode::BindByValue(_) => { }
152145
}
153146
});
154147
result
155148
}
156149

157150
/// Checks if the patterns for this arm contain any `ref` or `ref mut`
158-
/// bindings, and if yes wether its containing mutable ones or just immutables ones.
159-
pub fn arm_contains_ref_binding(dm: &DefMap, arm: &ast::Arm) -> Option<ast::Mutability> {
160-
arm.pats.iter()
161-
.filter_map(|pat| pat_contains_ref_binding(dm, pat))
162-
.max_by(|m| match *m {
163-
ast::MutMutable => 1,
164-
ast::MutImmutable => 0,
165-
})
151+
/// bindings.
152+
pub fn arm_contains_ref_binding(dm: &DefMap, arm: &ast::Arm) -> bool {
153+
arm.pats.iter().any(|pat| pat_contains_ref_binding(dm, pat))
166154
}
167155

168156
/// Checks if the pattern contains any patterns that bind something to

0 commit comments

Comments
 (0)