Skip to content

Commit eedaa94

Browse files
committed
Auto merge of rust-lang#39470 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 9 pull requests - Successful merges: rust-lang#38823, rust-lang#39196, rust-lang#39299, rust-lang#39319, rust-lang#39373, rust-lang#39383, rust-lang#39416, rust-lang#39420, rust-lang#39427 - Failed merges:
2 parents a47a6ea + d09e4de commit eedaa94

File tree

17 files changed

+75
-137
lines changed

17 files changed

+75
-137
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Ožbolt Menegatti <ozbolt.menegatti@gmail.com> gareins <ozbolt.menegatti@gmail.c
167167
Paul Faria <paul_faria@ultimatesoftware.com> Paul Faria <Nashenas88@gmail.com>
168168
Peer Aramillo Irizar <peer.aramillo.irizar@gmail.com> parir <peer.aramillo.irizar@gmail.com>
169169
Peter Elmers <peter.elmers@yahoo.com> <peter.elmers@rice.edu>
170+
Peter Liniker <peter.liniker+github@gmail.com>
170171
Peter Zotov <whitequark@whitequark.org>
171172
Phil Dawes <phil@phildawes.net> Phil Dawes <pdawes@drw.com>
172173
Philipp Brüschweiler <blei42@gmail.com> <blei42@gmail.com>

src/doc/book/testing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ be imported in every test with `mod common;`
499499
That's all there is to the `tests` directory. The `tests` module isn't needed
500500
here, since the whole thing is focused on tests.
501501

502+
Note, when building integration tests, cargo will not pass the `test` attribute
503+
to the compiler. It means that all parts in `cfg(test)` won't be included in
504+
the build used in your integration tests.
505+
502506
Let's finally check out that third section: documentation tests.
503507

504508
# Documentation tests

src/doc/nomicon/dropck.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,42 @@ assert (unsafely) that a generic type's destructor is *guaranteed* to
199199
not access any expired data, even if its type gives it the capability
200200
to do so.
201201

202-
That attribute is called `unsafe_destructor_blind_to_params`.
202+
That attribute is called `may_dangle` and was introduced in [RFC 1327]
203+
(https://github.com/rust-lang/rfcs/blob/master/text/1327-dropck-param-eyepatch.md).
203204
To deploy it on the Inspector example from above, we would write:
204205

205206
```rust,ignore
206207
struct Inspector<'a>(&'a u8, &'static str);
207208
208-
impl<'a> Drop for Inspector<'a> {
209-
#[unsafe_destructor_blind_to_params]
209+
unsafe impl<#[may_dangle] 'a> Drop for Inspector<'a> {
210210
fn drop(&mut self) {
211211
println!("Inspector(_, {}) knows when *not* to inspect.", self.1);
212212
}
213213
}
214214
```
215215

216-
This attribute has the word `unsafe` in it because the compiler is not
217-
checking the implicit assertion that no potentially expired data
216+
Use of this attribute requires the `Drop` impl to be marked `unsafe` because the
217+
compiler is not checking the implicit assertion that no potentially expired data
218218
(e.g. `self.0` above) is accessed.
219219

220+
The attribute can be applied to any number of lifetime and type parameters. In
221+
the following example, we assert that we access no data behind a reference of
222+
lifetime `'b` and that the only uses of `T` will be moves or drops, but omit
223+
the attribute from `'a` and `U`, because we do access data with that lifetime
224+
and that type:
225+
226+
```rust,ignore
227+
use std::fmt::Display;
228+
229+
struct Inspector<'a, 'b, T, U: Display>(&'a u8, &'b u8, T, U);
230+
231+
unsafe impl<'a, #[may_dangle] 'b, #[may_dangle] T, U: Display> Drop for Inspector<'a, 'b, T, U> {
232+
fn drop(&mut self) {
233+
println!("Inspector({}, _, _, {})", self.0, self.3);
234+
}
235+
}
236+
```
237+
220238
It is sometimes obvious that no such access can occur, like the case above.
221239
However, when dealing with a generic type parameter, such access can
222240
occur indirectly. Examples of such indirect access are:
@@ -263,7 +281,7 @@ some other method invoked by the destructor, rather than being written
263281
directly within it.
264282

265283
In all of the above cases where the `&'a u8` is accessed in the
266-
destructor, adding the `#[unsafe_destructor_blind_to_params]`
284+
destructor, adding the `#[may_dangle]`
267285
attribute makes the type vulnerable to misuse that the borrower
268286
checker will not catch, inviting havoc. It is better to avoid adding
269287
the attribute.

src/liballoc/rc.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
//! pointer to the same value in the heap. When the last [`Rc`] pointer to a
1818
//! given value is destroyed, the pointed-to value is also destroyed.
1919
//!
20-
//! Shared references in Rust disallow mutation by default, and `Rc` is no
21-
//! exception. If you need to mutate through an [`Rc`], use [`Cell`] or
22-
//! [`RefCell`].
20+
//! Shared references in Rust disallow mutation by default, and [`Rc`]
21+
//! is no exception: you cannot obtain a mutable reference to
22+
//! something inside an [`Rc`]. If you need mutability, put a [`Cell`]
23+
//! or [`RefCell`] inside the [`Rc`]; see [an example of mutability
24+
//! inside an Rc][mutability].
2325
//!
2426
//! [`Rc`] uses non-atomic reference counting. This means that overhead is very
2527
//! low, but an [`Rc`] cannot be sent between threads, and consequently [`Rc`]
@@ -214,6 +216,7 @@
214216
//! [upgrade]: struct.Weak.html#method.upgrade
215217
//! [`None`]: ../../std/option/enum.Option.html#variant.None
216218
//! [assoc]: ../../book/method-syntax.html#associated-functions
219+
//! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable
217220
218221
#![stable(feature = "rust1", since = "1.0.0")]
219222

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ pub mod util {
109109
pub mod common;
110110
pub mod ppaux;
111111
pub mod nodemap;
112-
pub mod num;
113112
pub mod fs;
114113
}
115114

src/librustc/util/num.rs

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

src/librustc_const_eval/eval.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//#![allow(non_camel_case_types)]
12-
1311
use rustc::middle::const_val::ConstVal::*;
1412
use rustc::middle::const_val::ConstVal;
1513
use self::ErrKind::*;

src/librustc_llvm/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ extern "C" {
804804
Name: *const c_char)
805805
-> ValueRef;
806806
pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
807-
pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
807+
pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
808808

809809
// Add a case to the switch instruction
810810
pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);

src/librustc_mir/build/block.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use rustc::hir;
1616
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1717
pub fn ast_block(&mut self,
1818
destination: &Lvalue<'tcx>,
19-
// FIXME(#32959): temporary measure for the issue
20-
dest_is_unit: bool,
2119
mut block: BasicBlock,
2220
ast_block: &'tcx hir::Block)
2321
-> BlockAnd<()> {
@@ -83,8 +81,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8381
// of the block.
8482
if let Some(expr) = expr {
8583
unpack!(block = this.into(destination, block, expr));
86-
} else if dest_is_unit {
87-
// FIXME(#31472)
84+
} else {
8885
let source_info = this.source_info(span);
8986
this.cfg.push_assign_unit(block, source_info, destination);
9087
}

src/librustc_mir/build/expr/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
4040
this.in_scope(extent, block, |this| this.into(destination, block, value))
4141
}
4242
ExprKind::Block { body: ast_block } => {
43-
this.ast_block(destination, expr.ty.is_nil(), block, ast_block)
43+
this.ast_block(destination, block, ast_block)
4444
}
4545
ExprKind::Match { discriminant, arms } => {
4646
this.match_expr(destination, expr_span, block, discriminant, arms)

0 commit comments

Comments
 (0)