Skip to content

Commit aa55d8f

Browse files
committed
---
yaml --- r: 212977 b: refs/heads/master c: 7a13b93 h: refs/heads/master i: 212975: c67ff42 v: v3
1 parent 0c4b138 commit aa55d8f

File tree

11 files changed

+108
-53
lines changed

11 files changed

+108
-53
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: 59638d15c1137a36edecf2b710f388d7bd86a88a
2+
refs/heads/master: 7a13b93b00af4e8f8b3baae2926e9877f5f6403d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/src/doc/reference.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,20 @@ fn foo<T>(x: T) where T: Debug {
944944
```
945945

946946
When a generic function is referenced, its type is instantiated based on the
947-
context of the reference. For example, calling the `iter` function defined
948-
above on `[1, 2]` will instantiate type parameter `T` with `i32`, and require
949-
the closure parameter to have type `Fn(i32)`.
947+
context of the reference. For example, calling the `foo` function here:
948+
949+
```
950+
use std::fmt::Debug;
951+
952+
fn foo<T>(x: &[T]) where T: Debug {
953+
// details elided
954+
# ()
955+
}
956+
957+
foo(&[1, 2]);
958+
```
959+
960+
will instantiate type parameter `T` with `i32`.
950961

951962
The type parameters can also be explicitly supplied in a trailing
952963
[path](#paths) component after the function name. This might be necessary if
@@ -2768,22 +2779,24 @@ meaning of the operators on standard types is given here.
27682779
Like the [arithmetic operators](#arithmetic-operators), bitwise operators are
27692780
syntactic sugar for calls to methods of built-in traits. This means that
27702781
bitwise operators can be overridden for user-defined types. The default
2771-
meaning of the operators on standard types is given here.
2782+
meaning of the operators on standard types is given here. Bitwise `&`, `|` and
2783+
`^` applied to boolean arguments are equivalent to logical `&&`, `||` and `!=`
2784+
evaluated in non-lazy fashion.
27722785

27732786
* `&`
2774-
: And.
2787+
: Bitwise AND.
27752788
Calls the `bitand` method of the `std::ops::BitAnd` trait.
27762789
* `|`
2777-
: Inclusive or.
2790+
: Bitwise inclusive OR.
27782791
Calls the `bitor` method of the `std::ops::BitOr` trait.
27792792
* `^`
2780-
: Exclusive or.
2793+
: Bitwise exclusive OR.
27812794
Calls the `bitxor` method of the `std::ops::BitXor` trait.
27822795
* `<<`
27832796
: Left shift.
27842797
Calls the `shl` method of the `std::ops::Shl` trait.
27852798
* `>>`
2786-
: Right shift.
2799+
: Right shift (arithmetic).
27872800
Calls the `shr` method of the `std::ops::Shr` trait.
27882801

27892802
#### Lazy boolean operators

trunk/src/librustc/middle/mem_categorization.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ pub use self::InteriorKind::*;
6565
pub use self::FieldName::*;
6666
pub use self::ElementKind::*;
6767
pub use self::MutabilityCategory::*;
68-
pub use self::InteriorSafety::*;
6968
pub use self::AliasableReason::*;
7069
pub use self::Note::*;
7170
pub use self::deref_kind::*;
@@ -1385,12 +1384,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
13851384
}
13861385
}
13871386

1388-
#[derive(Copy, Clone, Debug)]
1389-
pub enum InteriorSafety {
1390-
InteriorUnsafe,
1391-
InteriorSafe
1392-
}
1393-
13941387
#[derive(Clone, Debug)]
13951388
pub enum Aliasability {
13961389
FreelyAliasable(AliasableReason),
@@ -1404,8 +1397,8 @@ pub enum AliasableReason {
14041397
AliasableClosure(ast::NodeId), // Aliasable due to capture Fn closure env
14051398
AliasableOther,
14061399
UnaliasableImmutable, // Created as needed upon seeing ImmutableUnique
1407-
AliasableStatic(InteriorSafety),
1408-
AliasableStaticMut(InteriorSafety),
1400+
AliasableStatic,
1401+
AliasableStaticMut,
14091402
}
14101403

14111404
impl<'tcx> cmt_<'tcx> {
@@ -1469,16 +1462,10 @@ impl<'tcx> cmt_<'tcx> {
14691462
}
14701463

14711464
cat_static_item(..) => {
1472-
let int_safe = if ty::type_interior_is_unsafe(ctxt, self.ty) {
1473-
InteriorUnsafe
1474-
} else {
1475-
InteriorSafe
1476-
};
1477-
14781465
if self.mutbl.is_mutable() {
1479-
FreelyAliasable(AliasableStaticMut(int_safe))
1466+
FreelyAliasable(AliasableStaticMut)
14801467
} else {
1481-
FreelyAliasable(AliasableStatic(int_safe))
1468+
FreelyAliasable(AliasableStatic)
14821469
}
14831470
}
14841471

trunk/src/librustc/middle/ty.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,10 +3787,6 @@ impl fmt::Debug for TypeContents {
37873787
}
37883788
}
37893789

3790-
pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
3791-
type_contents(cx, ty).interior_unsafe()
3792-
}
3793-
37943790
pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
37953791
return memoized(&cx.tc_cache, ty, |ty| {
37963792
tc_ty(cx, ty, &mut FnvHashMap())

trunk/src/librustc_borrowck/borrowck/gather_loans/mod.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,11 @@ fn check_aliasability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
191191
/* Uniquely accessible path -- OK for `&` and `&mut` */
192192
Ok(())
193193
}
194-
(mc::Aliasability::FreelyAliasable(mc::AliasableStatic(safety)), ty::ImmBorrow) => {
195-
// Borrow of an immutable static item:
196-
match safety {
197-
mc::InteriorUnsafe => {
198-
// If the static item contains an Unsafe<T>, it has interior
199-
// mutability. In such cases, another phase of the compiler
200-
// will ensure that the type is `Sync` and then trans will
201-
// not put it in rodata, so this is ok to allow.
202-
Ok(())
203-
}
204-
mc::InteriorSafe => {
205-
// Immutable static can be borrowed, no problem.
206-
Ok(())
207-
}
208-
}
194+
(mc::Aliasability::FreelyAliasable(mc::AliasableStatic), ty::ImmBorrow) => {
195+
// Borrow of an immutable static item.
196+
Ok(())
209197
}
210-
(mc::Aliasability::FreelyAliasable(mc::AliasableStaticMut(..)), _) => {
198+
(mc::Aliasability::FreelyAliasable(mc::AliasableStaticMut), _) => {
211199
// Even touching a static mut is considered unsafe. We assume the
212200
// user knows what they're doing in these cases.
213201
Ok(())

trunk/src/librustc_resolve/resolve_imports.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use self::ImportDirectiveSubclass::*;
1212

1313
use DefModifiers;
1414
use Module;
15+
use ModuleKind;
1516
use Namespace::{self, TypeNS, ValueNS};
1617
use NameBindings;
1718
use NamespaceResult::{BoundResult, UnboundResult, UnknownResult};
@@ -980,10 +981,14 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
980981
match import_resolution.type_target {
981982
Some(ref target) if target.shadowable != Shadowable::Always => {
982983
if let Some(ref ty) = *name_bindings.type_def.borrow() {
983-
let (what, note) = if ty.module_def.is_some() {
984-
("existing submodule", "note conflicting module here")
985-
} else {
986-
("type in this module", "note conflicting type here")
984+
let (what, note) = match ty.module_def {
985+
Some(ref module)
986+
if module.kind.get() == ModuleKind::NormalModuleKind =>
987+
("existing submodule", "note conflicting module here"),
988+
Some(ref module)
989+
if module.kind.get() == ModuleKind::TraitModuleKind =>
990+
("trait in this module", "note conflicting trait here"),
991+
_ => ("type in this module", "note conflicting type here"),
987992
};
988993
span_err!(self.resolver.session, import_span, E0256,
989994
"import `{}` conflicts with {}",

trunk/src/libstd/collections/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
//! ### Use a `BTreeMap` when:
6767
//! * You're interested in what the smallest or largest key-value pair is.
6868
//! * You want to find the largest or smallest key that is smaller or larger
69-
//! than something
69+
//! than something.
7070
//! * You want to be able to get all of the entries in order on-demand.
7171
//! * You want a sorted map.
7272
//!
@@ -147,7 +147,7 @@
147147
//! relation to the number of elements in the collection. VecMap should only be
148148
//! seriously considered for small keys.
149149
//!
150-
//! Note also that BTreeMap's precise preformance depends on the value of B.
150+
//! Note also that BTreeMap's precise performance depends on the value of B.
151151
//!
152152
//! # Correct and Efficient Usage of Collections
153153
//!
@@ -309,7 +309,7 @@
309309
//! If a `Vacant(entry)` is yielded, then the key *was not* found. In this case
310310
//! the only valid operation is to `insert` a value into the entry. When this is
311311
//! done, the vacant entry is consumed and converted into a mutable reference to
312-
//! the the value that was inserted. This allows for further manipulation of the
312+
//! the value that was inserted. This allows for further manipulation of the
313313
//! value beyond the lifetime of the search itself. This is useful if complex
314314
//! logic needs to be performed on the value regardless of whether the value was
315315
//! just inserted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::ops::Add; //~ ERROR import `Add` conflicts with type in this module
12+
use std::ops::Sub; //~ ERROR import `Sub` conflicts with type in this module
13+
use std::ops::Mul; //~ ERROR import `Mul` conflicts with type in this module
14+
use std::ops::Div; //~ ERROR import `Div` conflicts with existing submodule
15+
use std::ops::Rem; //~ ERROR import `Rem` conflicts with trait in this module
16+
17+
type Add = bool;
18+
struct Sub { x: f32 }
19+
enum Mul { A, B }
20+
mod Div { }
21+
trait Rem { }
22+
23+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
struct Fun<F>(F);
13+
let f = Fun(|x| 3*x);
14+
let Fun(g) = f;
15+
println!("{:?}",g(4));
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
let f = || || 0;
13+
std::thread::spawn(f());
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
const x: &'static Fn() = &|| println!("ICE here");
12+
13+
fn main() {}

0 commit comments

Comments
 (0)