Skip to content

Commit 941af7b

Browse files
committed
Auto merge of #26389 - Manishearth:rollup, r=Manishearth
- Successful merges: #26314, #26342, #26348, #26349, #26369, #26387 - Failed merges:
2 parents b20728c + 2424800 commit 941af7b

File tree

6 files changed

+45
-48
lines changed

6 files changed

+45
-48
lines changed

src/doc/reference.md

+21-8
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

src/librustc/middle/mem_categorization.rs

+4-17
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

src/librustc/middle/ty.rs

-4
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())

src/librustc_borrowck/borrowck/gather_loans/mod.rs

+4-16
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(())

src/libstd/collections/mod.rs

+3-3
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.

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

+13
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)