Skip to content

Commit 0c4b138

Browse files
author
Oliver Schneider
committed
---
yaml --- r: 212976 b: refs/heads/master c: 59638d1 h: refs/heads/master v: v3
1 parent c67ff42 commit 0c4b138

File tree

14 files changed

+53
-176
lines changed

14 files changed

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

trunk/src/doc/reference.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -944,20 +944,9 @@ 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 `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`.
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)`.
961950

962951
The type parameters can also be explicitly supplied in a trailing
963952
[path](#paths) component after the function name. This might be necessary if
@@ -2779,24 +2768,22 @@ meaning of the operators on standard types is given here.
27792768
Like the [arithmetic operators](#arithmetic-operators), bitwise operators are
27802769
syntactic sugar for calls to methods of built-in traits. This means that
27812770
bitwise operators can be overridden for user-defined types. The default
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.
2771+
meaning of the operators on standard types is given here.
27852772

27862773
* `&`
2787-
: Bitwise AND.
2774+
: And.
27882775
Calls the `bitand` method of the `std::ops::BitAnd` trait.
27892776
* `|`
2790-
: Bitwise inclusive OR.
2777+
: Inclusive or.
27912778
Calls the `bitor` method of the `std::ops::BitOr` trait.
27922779
* `^`
2793-
: Bitwise exclusive OR.
2780+
: Exclusive or.
27942781
Calls the `bitxor` method of the `std::ops::BitXor` trait.
27952782
* `<<`
27962783
: Left shift.
27972784
Calls the `shl` method of the `std::ops::Shl` trait.
27982785
* `>>`
2799-
: Right shift (arithmetic).
2786+
: Right shift.
28002787
Calls the `shr` method of the `std::ops::Shr` trait.
28012788

28022789
#### Lazy boolean operators

trunk/src/librustc/middle/mem_categorization.rs

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

1388+
#[derive(Copy, Clone, Debug)]
1389+
pub enum InteriorSafety {
1390+
InteriorUnsafe,
1391+
InteriorSafe
1392+
}
1393+
13871394
#[derive(Clone, Debug)]
13881395
pub enum Aliasability {
13891396
FreelyAliasable(AliasableReason),
@@ -1397,8 +1404,8 @@ pub enum AliasableReason {
13971404
AliasableClosure(ast::NodeId), // Aliasable due to capture Fn closure env
13981405
AliasableOther,
13991406
UnaliasableImmutable, // Created as needed upon seeing ImmutableUnique
1400-
AliasableStatic,
1401-
AliasableStaticMut,
1407+
AliasableStatic(InteriorSafety),
1408+
AliasableStaticMut(InteriorSafety),
14021409
}
14031410

14041411
impl<'tcx> cmt_<'tcx> {
@@ -1462,10 +1469,16 @@ impl<'tcx> cmt_<'tcx> {
14621469
}
14631470

14641471
cat_static_item(..) => {
1472+
let int_safe = if ty::type_interior_is_unsafe(ctxt, self.ty) {
1473+
InteriorUnsafe
1474+
} else {
1475+
InteriorSafe
1476+
};
1477+
14651478
if self.mutbl.is_mutable() {
1466-
FreelyAliasable(AliasableStaticMut)
1479+
FreelyAliasable(AliasableStaticMut(int_safe))
14671480
} else {
1468-
FreelyAliasable(AliasableStatic)
1481+
FreelyAliasable(AliasableStatic(int_safe))
14691482
}
14701483
}
14711484

trunk/src/librustc/middle/ty.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,6 +3787,10 @@ 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+
37903794
pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
37913795
return memoized(&cx.tc_cache, ty, |ty| {
37923796
tc_ty(cx, ty, &mut FnvHashMap())

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,23 @@ 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), ty::ImmBorrow) => {
195-
// Borrow of an immutable static item.
196-
Ok(())
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+
}
197209
}
198-
(mc::Aliasability::FreelyAliasable(mc::AliasableStaticMut), _) => {
210+
(mc::Aliasability::FreelyAliasable(mc::AliasableStaticMut(..)), _) => {
199211
// Even touching a static mut is considered unsafe. We assume the
200212
// user knows what they're doing in these cases.
201213
Ok(())

trunk/src/librustc_llvm/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,20 +1300,8 @@ extern {
13001300
-> ValueRef;
13011301

13021302
/* Memory */
1303-
pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1304-
-> ValueRef;
1305-
pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1306-
Ty: TypeRef,
1307-
Val: ValueRef,
1308-
Name: *const c_char)
1309-
-> ValueRef;
13101303
pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
13111304
-> ValueRef;
1312-
pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1313-
Ty: TypeRef,
1314-
Val: ValueRef,
1315-
Name: *const c_char)
1316-
-> ValueRef;
13171305
pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
13181306
pub fn LLVMBuildLoad(B: BuilderRef,
13191307
PointerVal: ValueRef,

trunk/src/librustc_resolve/resolve_imports.rs

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

1313
use DefModifiers;
1414
use Module;
15-
use ModuleKind;
1615
use Namespace::{self, TypeNS, ValueNS};
1716
use NameBindings;
1817
use NamespaceResult::{BoundResult, UnboundResult, UnknownResult};
@@ -981,14 +980,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
981980
match import_resolution.type_target {
982981
Some(ref target) if target.shadowable != Shadowable::Always => {
983982
if let Some(ref ty) = *name_bindings.type_def.borrow() {
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"),
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")
992987
};
993988
span_err!(self.resolver.session, import_span, E0256,
994989
"import `{}` conflicts with {}",

trunk/src/librustc_trans/trans/build.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -522,30 +522,6 @@ pub fn Not(cx: Block, v: ValueRef, debug_loc: DebugLoc) -> ValueRef {
522522
B(cx).not(v)
523523
}
524524

525-
/* Memory */
526-
pub fn Malloc(cx: Block, ty: Type, debug_loc: DebugLoc) -> ValueRef {
527-
unsafe {
528-
if cx.unreachable.get() {
529-
return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref());
530-
}
531-
debug_loc.apply(cx.fcx);
532-
B(cx).malloc(ty)
533-
}
534-
}
535-
536-
pub fn ArrayMalloc(cx: Block,
537-
ty: Type,
538-
val: ValueRef,
539-
debug_loc: DebugLoc) -> ValueRef {
540-
unsafe {
541-
if cx.unreachable.get() {
542-
return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref());
543-
}
544-
debug_loc.apply(cx.fcx);
545-
B(cx).array_malloc(ty, val)
546-
}
547-
}
548-
549525
pub fn Alloca(cx: Block, ty: Type, name: &str) -> ValueRef {
550526
unsafe {
551527
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.ptr_to().to_ref()); }
@@ -560,16 +536,6 @@ pub fn AllocaFcx(fcx: &FunctionContext, ty: Type, name: &str) -> ValueRef {
560536
b.alloca(ty, name)
561537
}
562538

563-
pub fn ArrayAlloca(cx: Block, ty: Type, val: ValueRef) -> ValueRef {
564-
unsafe {
565-
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.ptr_to().to_ref()); }
566-
let b = cx.fcx.ccx.builder();
567-
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
568-
DebugLoc::None.apply(cx.fcx);
569-
b.array_alloca(ty, val)
570-
}
571-
}
572-
573539
pub fn Free(cx: Block, pointer_val: ValueRef) {
574540
if cx.unreachable.get() { return; }
575541
B(cx).free(pointer_val)

trunk/src/librustc_trans/trans/builder.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -410,21 +410,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
410410
}
411411
}
412412

413-
/* Memory */
414-
pub fn malloc(&self, ty: Type) -> ValueRef {
415-
self.count_insn("malloc");
416-
unsafe {
417-
llvm::LLVMBuildMalloc(self.llbuilder, ty.to_ref(), noname())
418-
}
419-
}
420-
421-
pub fn array_malloc(&self, ty: Type, val: ValueRef) -> ValueRef {
422-
self.count_insn("arraymalloc");
423-
unsafe {
424-
llvm::LLVMBuildArrayMalloc(self.llbuilder, ty.to_ref(), val, noname())
425-
}
426-
}
427-
428413
pub fn alloca(&self, ty: Type, name: &str) -> ValueRef {
429414
self.count_insn("alloca");
430415
unsafe {
@@ -438,13 +423,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
438423
}
439424
}
440425

441-
pub fn array_alloca(&self, ty: Type, val: ValueRef) -> ValueRef {
442-
self.count_insn("arrayalloca");
443-
unsafe {
444-
llvm::LLVMBuildArrayAlloca(self.llbuilder, ty.to_ref(), val, noname())
445-
}
446-
}
447-
448426
pub fn free(&self, ptr: ValueRef) {
449427
self.count_insn("free");
450428
unsafe {

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 performance depends on the value of B.
150+
//! Note also that BTreeMap's precise preformance 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 value that was inserted. This allows for further manipulation of the
312+
//! the 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.

trunk/src/test/compile-fail/issue-24081.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

trunk/src/test/run-pass/issue-22864-1.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

trunk/src/test/run-pass/issue-22864-2.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

trunk/src/test/run-pass/issue-25180.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)