Skip to content
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5c1cd6c
Update cargo
dtolnay Apr 3, 2019
a37c33b
Mark unix::ffi::OsStrExt methods as inline
LunaBorowska Apr 4, 2019
a964921
Use declare_lint_pass! and impl_lint_pass! in more places
hgallagher1993 Apr 4, 2019
d6b91fe
Update cargo
dtolnay Apr 4, 2019
1bf04c9
std: Upgrade `compiler_builtins` to fix wasi linkage
alexcrichton Apr 2, 2019
7994197
Make FnBox a subtrait of FnOnce.
qnighy Oct 28, 2018
059ec76
Add Fn* blanket impls for Box.
qnighy Oct 28, 2018
480dcb4
Add tests for boxed_closure_impls.
qnighy Oct 28, 2018
219097e
Add unstable-book articles on fnbox and boxed_closure_impls.
qnighy Oct 28, 2018
e55d82c
Fix expectations on some ui tests involving FnOnce.
qnighy Oct 28, 2018
4dcd6cc
Fix failing tests.
qnighy Feb 3, 2019
a38f292
We already have unsized_locals in stage0.
qnighy Feb 10, 2019
45c0b28
Remove FnBox specialization of impl FnOnce for Box<impl FnOnce>.
qnighy Feb 11, 2019
ecc3e89
Stabilize boxed_closure_impls in 1.35.0.
crlf0710 Feb 11, 2019
440e873
Simplify fnbox docs.
qnighy Feb 11, 2019
7a63c7f
Add ignore to doc code
qnighy Feb 11, 2019
471db2b
wasm32: Default to a "static" relocation model
alexcrichton Apr 4, 2019
8c0e786
Rollup merge of #59500 - crlf0710:boxed-closure-impls, r=cramertj
Centril Apr 5, 2019
1f05de7
Rollup merge of #59643 - alexcrichton:wasi-symbols, r=sanxiyn
Centril Apr 5, 2019
bc995f4
Rollup merge of #59681 - dtolnay:cargo, r=alexcrichton
Centril Apr 5, 2019
6070d47
Rollup merge of #59690 - xfix:patch-17, r=cramertj
Centril Apr 5, 2019
3600e4d
Rollup merge of #59702 - hgallagher1993:origin, r=Centril
Centril Apr 5, 2019
c03fa7b
Rollup merge of #59712 - alexcrichton:wasm-static-not-pic, r=eddyb
Centril Apr 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ dependencies = [
name = "alloc"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -107,7 +107,7 @@ version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]
@@ -465,7 +465,7 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -751,7 +751,7 @@ name = "dlmalloc"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]
@@ -917,7 +917,7 @@ name = "fortanix-sgx-abi"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]

@@ -1769,7 +1769,7 @@ dependencies = [
name = "panic_abort"
version = "0.0.0"
dependencies = [
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1779,7 +1779,7 @@ name = "panic_unwind"
version = "0.0.0"
dependencies = [
"alloc 0.0.0",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"unwind 0.0.0",
@@ -1964,7 +1964,7 @@ name = "profiler_builtins"
version = "0.0.0"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

@@ -2479,7 +2479,7 @@ name = "rustc-demangle"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]

@@ -2579,7 +2579,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

@@ -2806,7 +2806,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

@@ -2868,7 +2868,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

@@ -2989,7 +2989,7 @@ dependencies = [
"alloc 0.0.0",
"build_helper 0.1.0",
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
]

@@ -3256,7 +3256,7 @@ dependencies = [
"alloc 0.0.0",
"backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3830,7 +3830,7 @@ name = "unwind"
version = "0.0.0"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -4026,7 +4026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
"checksum compiler_builtins 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "a28c3898d0c57b26fa6f92de141ba665fa5ac5179f795db06db408be84302395"
"checksum compiler_builtins 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d7de11892d9f9f1bc76d43011c8233d27d58300d629dc9dfb51b6626ef7f6077"
"checksum compiletest_rs 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "56c799b1f7142badf3b047b4c1f2074cc96b6b784fb2432f2ed9c87da0a03749"
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
32 changes: 32 additions & 0 deletions src/doc/unstable-book/src/library-features/fnbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# `fnbox`

The tracking issue for this feature is [#28796]

[#28796]: https://github.com/rust-lang/rust/issues/28796

------------------------

This had been a temporary alternative to the following impls:

```rust,ignore
impl<A, F> FnOnce for Box<F> where F: FnOnce<A> + ?Sized {}
impl<A, F> FnMut for Box<F> where F: FnMut<A> + ?Sized {}
impl<A, F> Fn for Box<F> where F: Fn<A> + ?Sized {}
```

The impls are parallel to these (relatively old) impls:

```rust,ignore
impl<A, F> FnOnce for &mut F where F: FnMut<A> + ?Sized {}
impl<A, F> FnMut for &mut F where F: FnMut<A> + ?Sized {}
impl<A, F> Fn for &mut F where F: Fn<A> + ?Sized {}
impl<A, F> FnOnce for &F where F: Fn<A> + ?Sized {}
impl<A, F> FnMut for &F where F: Fn<A> + ?Sized {}
impl<A, F> Fn for &F where F: Fn<A> + ?Sized {}
```

Before the introduction of [`unsized_locals`][unsized_locals], we had been unable to provide the former impls. That means, unlike `&dyn Fn()` or `&mut dyn FnMut()` we could not use `Box<dyn FnOnce()>` at that time.

[unsized_locals]: language-features/unsized-locals.html

`FnBox()` is an alternative approach to `Box<dyn FnBox()>` is delegated to `FnBox::call_box` which doesn't need unsized locals. As we now have `Box<dyn FnOnce()>` working, the `fnbox` feature is going to be removed.
48 changes: 23 additions & 25 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
@@ -694,6 +694,28 @@ impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {
#[stable(feature = "fused", since = "1.26.0")]
impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}

#[stable(feature = "boxed_closure_impls", since = "1.35.0")]
impl<A, F: FnOnce<A> + ?Sized> FnOnce<A> for Box<F> {
type Output = <F as FnOnce<A>>::Output;

extern "rust-call" fn call_once(self, args: A) -> Self::Output {
<F as FnOnce<A>>::call_once(*self, args)
}
}

#[stable(feature = "boxed_closure_impls", since = "1.35.0")]
impl<A, F: FnMut<A> + ?Sized> FnMut<A> for Box<F> {
extern "rust-call" fn call_mut(&mut self, args: A) -> Self::Output {
<F as FnMut<A>>::call_mut(self, args)
}
}

#[stable(feature = "boxed_closure_impls", since = "1.35.0")]
impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
extern "rust-call" fn call(&self, args: A) -> Self::Output {
<F as Fn<A>>::call(self, args)
}
}

/// `FnBox` is a version of the `FnOnce` intended for use with boxed
/// closure objects. The idea is that where one would normally store a
@@ -735,9 +757,7 @@ impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
#[rustc_paren_sugar]
#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
pub trait FnBox<A> {
type Output;

pub trait FnBox<A>: FnOnce<A> {
fn call_box(self: Box<Self>, args: A) -> Self::Output;
}

@@ -746,33 +766,11 @@ pub trait FnBox<A> {
impl<A, F> FnBox<A> for F
where F: FnOnce<A>
{
type Output = F::Output;

fn call_box(self: Box<F>, args: A) -> F::Output {
self.call_once(args)
}
}

#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
impl<A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + '_> {
type Output = R;

extern "rust-call" fn call_once(self, args: A) -> R {
self.call_box(args)
}
}

#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
impl<A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + Send + '_> {
type Output = R;

extern "rust-call" fn call_once(self, args: A) -> R {
self.call_box(args)
}
}

#[unstable(feature = "coerce_unsized", issue = "27732")]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}

1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@
#![feature(unboxed_closures)]
#![feature(unicode_internals)]
#![feature(unsize)]
#![feature(unsized_locals)]
#![feature(allocator_internals)]
#![feature(on_unimplemented)]
#![feature(rustc_const_unstable)]
22 changes: 2 additions & 20 deletions src/librustc/lint/internal.rs
Original file line number Diff line number Diff line change
@@ -28,15 +28,7 @@ impl DefaultHashTypes {
}
}

impl LintPass for DefaultHashTypes {
fn get_lints(&self) -> LintArray {
lint_array!(DEFAULT_HASH_TYPES)
}

fn name(&self) -> &'static str {
"DefaultHashTypes"
}
}
impl_lint_pass!(DefaultHashTypes => [DEFAULT_HASH_TYPES]);

impl EarlyLintPass for DefaultHashTypes {
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) {
@@ -68,17 +60,7 @@ declare_lint! {
"Usage of `ty::TyKind` outside of the `ty::sty` module"
}

pub struct TyKindUsage;

impl LintPass for TyKindUsage {
fn get_lints(&self) -> LintArray {
lint_array!(USAGE_OF_TY_TYKIND)
}

fn name(&self) -> &'static str {
"TyKindUsage"
}
}
declare_lint_pass!(TyKindUsage => [USAGE_OF_TY_TYKIND]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage {
fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path, _: HirId) {
9 changes: 9 additions & 0 deletions src/librustc_target/spec/wasm32_base.rs
Original file line number Diff line number Diff line change
@@ -118,6 +118,15 @@ pub fn options() -> TargetOptions {

pre_link_args,

// This has no effect in LLVM 8 or prior, but in LLVM 9 and later when
// PIC code is implemented this has quite a drastric effect if it stays
// at the default, `pic`. In an effort to keep wasm binaries as minimal
// as possible we're defaulting to `static` for now, but the hope is
// that eventually we can ship a `pic`-compatible standard library which
// works with `static` as well (or works with some method of generating
// non-relative calls and such later on).
relocation_model: "static".to_string(),

.. Default::default()
}
}
2 changes: 1 addition & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ panic_unwind = { path = "../libpanic_unwind", optional = true }
panic_abort = { path = "../libpanic_abort" }
core = { path = "../libcore" }
libc = { version = "0.2.51", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.8" }
compiler_builtins = { version = "0.1.9" }
profiler_builtins = { path = "../libprofiler_builtins", optional = true }
unwind = { path = "../libunwind" }
rustc-demangle = { version = "0.1.10", features = ['rustc-dep-of-std'] }
1 change: 1 addition & 0 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
@@ -960,6 +960,7 @@ impl IntoInner<Buf> for OsString {
}

impl AsInner<Slice> for OsStr {
#[inline]
fn as_inner(&self) -> &Slice {
&self.inner
}
2 changes: 2 additions & 0 deletions src/libstd/sys_common/os_str_bytes.rs
Original file line number Diff line number Diff line change
@@ -236,9 +236,11 @@ pub trait OsStrExt {

#[stable(feature = "rust1", since = "1.0.0")]
impl OsStrExt for OsStr {
#[inline]
fn from_bytes(slice: &[u8]) -> &OsStr {
unsafe { mem::transmute(slice) }
}
#[inline]
fn as_bytes(&self) -> &[u8] {
&self.as_inner().inner
}
8 changes: 8 additions & 0 deletions src/test/run-pass/unsized-locals/box-fnonce.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn call_it<T>(f: Box<dyn FnOnce() -> T>) -> T {
f()
}

fn main() {
let s = "hello".to_owned();
assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
}
12 changes: 12 additions & 0 deletions src/test/run-pass/unsized-locals/fnbox-compat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(fnbox)]

use std::boxed::FnBox;

fn call_it<T>(f: Box<dyn FnBox() -> T>) -> T {
f()
}

fn main() {
let s = "hello".to_owned();
assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
}
32 changes: 10 additions & 22 deletions src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ LL | f(f(10));
| first mutable borrow occurs here
| first borrow later used by call

error[E0382]: use of moved value: `*f`
error[E0382]: use of moved value: `f`
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
|
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
@@ -17,7 +17,7 @@ LL | f(f(10));
| |
| value moved here
|
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
= note: move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait

error[E0499]: cannot borrow `*f` as mutable more than once at a time
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@@ -28,30 +28,18 @@ LL | f(f(10));
| first mutable borrow occurs here
| first borrow later used by call

error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
--> $DIR/two-phase-nonrecv-autoref.rs:85:9
|
LL | f(f(10));
| ^

error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
|
LL | f(f(10));
| ^

error[E0382]: use of moved value: `*f`
error[E0382]: use of moved value: `f`
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
|
LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait
= note: move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait

error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:129:27
--> $DIR/two-phase-nonrecv-autoref.rs:125:27
|
LL | double_access(&mut a, &a);
| ------------- ------ ^^ immutable borrow occurs here
@@ -60,7 +48,7 @@ LL | double_access(&mut a, &a);
| mutable borrow later used by call

error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:157:7
--> $DIR/two-phase-nonrecv-autoref.rs:153:7
|
LL | i[i[3]] = 4;
| --^----
@@ -70,7 +58,7 @@ LL | i[i[3]] = 4;
| mutable borrow later used here

error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:163:7
--> $DIR/two-phase-nonrecv-autoref.rs:159:7
|
LL | i[i[3]] = i[4];
| --^----
@@ -79,7 +67,7 @@ LL | i[i[3]] = i[4];
| mutable borrow occurs here
| mutable borrow later used here

error: aborting due to 9 previous errors
error: aborting due to 7 previous errors

Some errors occurred: E0161, E0382, E0499, E0502.
For more information about an error, try `rustc --explain E0161`.
Some errors occurred: E0382, E0499, E0502.
For more information about an error, try `rustc --explain E0382`.
22 changes: 11 additions & 11 deletions src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@ LL | f(f(10));
| | second mutable borrow occurs here
| first mutable borrow occurs here

error[E0382]: use of moved value: `*f`
error[E0382]: use of moved value: `f`
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
|
LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
= note: move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait

error[E0499]: cannot borrow `*f` as mutable more than once at a time
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@@ -34,18 +34,18 @@ LL | f(f(10));
| | second mutable borrow occurs here
| first mutable borrow occurs here

error[E0382]: use of moved value: `*f`
error[E0382]: use of moved value: `f`
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
|
LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `(dyn std::ops::FnOnce(i32) -> i32 + 'static)`, which does not implement the `Copy` trait
= note: move occurs because `f` has type `std::boxed::Box<(dyn std::ops::FnOnce(i32) -> i32 + 'static)>`, which does not implement the `Copy` trait

error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:129:28
--> $DIR/two-phase-nonrecv-autoref.rs:125:28
|
LL | double_access(&mut a, &a);
| - ^- mutable borrow ends here
@@ -54,7 +54,7 @@ LL | double_access(&mut a, &a);
| mutable borrow occurs here

error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:135:9
--> $DIR/two-phase-nonrecv-autoref.rs:131:9
|
LL | a.m(a.i(10));
| - ^ - mutable borrow ends here
@@ -63,7 +63,7 @@ LL | a.m(a.i(10));
| mutable borrow occurs here

error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:157:7
--> $DIR/two-phase-nonrecv-autoref.rs:153:7
|
LL | i[i[3]] = 4;
| - ^ - mutable borrow ends here
@@ -72,7 +72,7 @@ LL | i[i[3]] = 4;
| mutable borrow occurs here

error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:163:7
--> $DIR/two-phase-nonrecv-autoref.rs:159:7
|
LL | i[i[3]] = i[4];
| - ^ - mutable borrow ends here
@@ -81,7 +81,7 @@ LL | i[i[3]] = i[4];
| mutable borrow occurs here

error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:172:12
--> $DIR/two-phase-nonrecv-autoref.rs:168:12
|
LL | v.push(v.len());
| - ^ - mutable borrow ends here
@@ -90,7 +90,7 @@ LL | v.push(v.len());
| mutable borrow occurs here

error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:183:9
--> $DIR/two-phase-nonrecv-autoref.rs:179:9
|
LL | s.m(s.i(10));
| - ^ - mutable borrow ends here
@@ -99,7 +99,7 @@ LL | s.m(s.i(10));
| mutable borrow occurs here

error[E0502]: cannot borrow `t` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:188:9
--> $DIR/two-phase-nonrecv-autoref.rs:184:9
|
LL | t.m(t.i(10));
| - ^ - mutable borrow ends here
36 changes: 11 additions & 25 deletions src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr
Original file line number Diff line number Diff line change
@@ -7,17 +7,15 @@ LL | f(f(10));
| first mutable borrow occurs here
| first borrow later used by call

error[E0382]: use of moved value: `*f`
error[E0382]: use of moved value: `f`
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
|
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
| - consider adding a `Copy` constraint to this type argument
| - move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait
LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait

error[E0499]: cannot borrow `*f` as mutable more than once at a time
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@@ -28,30 +26,18 @@ LL | f(f(10));
| first mutable borrow occurs here
| first borrow later used by call

error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
--> $DIR/two-phase-nonrecv-autoref.rs:85:9
|
LL | f(f(10));
| ^

error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
|
LL | f(f(10));
| ^

error[E0382]: use of moved value: `*f`
error[E0382]: use of moved value: `f`
--> $DIR/two-phase-nonrecv-autoref.rs:85:11
|
LL | fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) {
| - move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait
LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait

error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:129:27
--> $DIR/two-phase-nonrecv-autoref.rs:125:27
|
LL | double_access(&mut a, &a);
| ------------- ------ ^^ immutable borrow occurs here
@@ -60,7 +46,7 @@ LL | double_access(&mut a, &a);
| mutable borrow later used by call

error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:157:7
--> $DIR/two-phase-nonrecv-autoref.rs:153:7
|
LL | i[i[3]] = 4;
| --^----
@@ -70,7 +56,7 @@ LL | i[i[3]] = 4;
| mutable borrow later used here

error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:163:7
--> $DIR/two-phase-nonrecv-autoref.rs:159:7
|
LL | i[i[3]] = i[4];
| --^----
@@ -79,7 +65,7 @@ LL | i[i[3]] = i[4];
| mutable borrow occurs here
| mutable borrow later used here

error: aborting due to 9 previous errors
error: aborting due to 7 previous errors

Some errors occurred: E0161, E0382, E0499, E0502.
For more information about an error, try `rustc --explain E0161`.
Some errors occurred: E0382, E0499, E0502.
For more information about an error, try `rustc --explain E0382`.
16 changes: 6 additions & 10 deletions src/test/ui/borrowck/two-phase-nonrecv-autoref.rs
Original file line number Diff line number Diff line change
@@ -67,9 +67,9 @@ fn overloaded_call_traits() {
}
fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
f(f(10));
//[nll]~^ ERROR use of moved value: `*f`
//[g2p]~^^ ERROR use of moved value: `*f`
//[ast]~^^^ ERROR use of moved value: `*f`
//[nll]~^ ERROR use of moved value: `f`
//[g2p]~^^ ERROR use of moved value: `f`
//[ast]~^^^ ERROR use of moved value: `f`
}

fn twice_ten_om(f: &mut FnMut(i32) -> i32) {
@@ -83,13 +83,9 @@ fn overloaded_call_traits() {
}
fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) {
f(f(10));
//[nll]~^ ERROR cannot move a value of type
//[nll]~^^ ERROR cannot move a value of type
//[nll]~^^^ ERROR use of moved value: `*f`
//[g2p]~^^^^ ERROR cannot move a value of type
//[g2p]~^^^^^ ERROR cannot move a value of type
//[g2p]~^^^^^^ ERROR use of moved value: `*f`
//[ast]~^^^^^^^ ERROR use of moved value: `*f`
//[nll]~^ ERROR use of moved value: `f`
//[g2p]~^^ ERROR use of moved value: `f`
//[ast]~^^^ ERROR use of moved value: `f`
}

twice_ten_sm(&mut |x| x + 1);
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ LL | fn test2<F>(f: &F) where F: FnMut() {
LL | (*f)();
| ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow `*f.f` as mutable, as it is behind a `&` reference
error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
|
LL | fn test4(f: &Test) {
2 changes: 1 addition & 1 deletion src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ fn test3<F>(f: &mut F) where F: FnMut() {

fn test4(f: &Test) {
f.f.call_mut(())
//~^ ERROR: cannot borrow `Box` content `*f.f` of immutable binding as mutable
//~^ ERROR: cannot borrow field `f.f` of immutable binding as mutable
}

fn test5(f: &mut Test) {
4 changes: 2 additions & 2 deletions src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr
Original file line number Diff line number Diff line change
@@ -19,13 +19,13 @@ LL | fn test2<F>(f: &F) where F: FnMut() {
LL | (*f)();
| ^^^^ cannot borrow as mutable

error[E0596]: cannot borrow `Box` content `*f.f` of immutable binding as mutable
error[E0596]: cannot borrow field `f.f` of immutable binding as mutable
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
|
LL | fn test4(f: &Test) {
| ----- use `&mut Test` here to make mutable
LL | f.f.call_mut(())
| ^^^ cannot borrow as mutable
| ^^^ cannot mutably borrow field of immutable binding

error[E0504]: cannot move `f` into closure because it is borrowed
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13
2 changes: 1 addition & 1 deletion src/tools/cargo
Submodule cargo updated 59 files
+15 −2 src/bin/cargo/cli.rs
+12 −6 src/bin/cargo/commands/build.rs
+77 −0 src/bin/cargo/commands/clippy.rs
+47 −17 src/bin/cargo/commands/install.rs
+3 −0 src/bin/cargo/commands/mod.rs
+4 −9 src/cargo/core/compiler/build_config.rs
+5 −1 src/cargo/core/compiler/build_context/mod.rs
+2 −20 src/cargo/core/compiler/compilation.rs
+1 −1 src/cargo/core/compiler/context/compilation_files.rs
+2 −2 src/cargo/core/compiler/context/mod.rs
+7 −7 src/cargo/core/compiler/mod.rs
+50 −4 src/cargo/core/features.rs
+8 −1 src/cargo/core/manifest.rs
+1 −1 src/cargo/core/mod.rs
+46 −4 src/cargo/core/package.rs
+19 −2 src/cargo/core/package_id.rs
+15 −14 src/cargo/core/profiles.rs
+61 −10 src/cargo/core/resolver/conflict_cache.rs
+82 −30 src/cargo/core/resolver/context.rs
+138 −64 src/cargo/core/resolver/mod.rs
+7 −3 src/cargo/core/resolver/types.rs
+4 −1 src/cargo/core/workspace.rs
+5 −15 src/cargo/ops/cargo_doc.rs
+1 −1 src/cargo/ops/cargo_fetch.rs
+1 −1 src/cargo/ops/cargo_install.rs
+8 −2 src/cargo/ops/cargo_new.rs
+13 −26 src/cargo/ops/fix.rs
+2 −2 src/cargo/sources/git/utils.rs
+35 −12 src/cargo/sources/registry/index.rs
+8 −5 src/cargo/util/command_prelude.rs
+8 −9 src/cargo/util/config.rs
+18 −0 src/cargo/util/graph.rs
+1 −1 src/cargo/util/mod.rs
+1 −4 src/cargo/util/process_builder.rs
+8 −4 src/cargo/util/rustc.rs
+11 −0 src/cargo/util/toml/mod.rs
+8 −4 src/doc/man/cargo-build.adoc
+5 −5 src/doc/man/cargo-install.adoc
+8 −4 src/doc/man/generated/cargo-build.html
+5 −5 src/doc/man/generated/cargo-install.html
+17 −9 src/doc/src/appendix/glossary.md
+6 −4 src/doc/src/reference/unstable.md
+16 −6 src/etc/man/cargo-build.1
+7 −7 src/etc/man/cargo-install.1
+1 −1 tests/testsuite/alt_registry.rs
+22 −0 tests/testsuite/bad_config.rs
+76 −8 tests/testsuite/build.rs
+8 −1 tests/testsuite/cargo_features.rs
+0 −2 tests/testsuite/death.rs
+3 −11 tests/testsuite/doc.rs
+69 −4 tests/testsuite/git.rs
+18 −0 tests/testsuite/install.rs
+6 −2 tests/testsuite/member_errors.rs
+11 −0 tests/testsuite/new.rs
+68 −0 tests/testsuite/profile_overrides.rs
+33 −5 tests/testsuite/resolve.rs
+108 −22 tests/testsuite/support/mod.rs
+1 −0 tests/testsuite/support/registry.rs
+3 −0 tests/testsuite/workspaces.rs