]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoHave worker-local GlobalArenas
John Kåre Alsaker [Mon, 22 Jan 2018 13:31:23 +0000 (14:31 +0100)]
Have worker-local GlobalArenas

6 years agoAdd a WorkerLocal abstraction
John Kåre Alsaker [Fri, 11 May 2018 14:28:28 +0000 (16:28 +0200)]
Add a WorkerLocal abstraction

6 years agoUpdate recursion limits
John Kåre Alsaker [Sat, 3 Mar 2018 05:22:19 +0000 (06:22 +0100)]
Update recursion limits

6 years agoEnsure ImplicitCtxt is Sync
John Kåre Alsaker [Wed, 25 Apr 2018 23:03:54 +0000 (01:03 +0200)]
Ensure ImplicitCtxt is Sync

6 years agoFix optimization_fuel
John Kåre Alsaker [Tue, 17 Apr 2018 18:09:40 +0000 (20:09 +0200)]
Fix optimization_fuel

6 years agoFix OneThread
John Kåre Alsaker [Fri, 20 Apr 2018 21:50:10 +0000 (23:50 +0200)]
Fix OneThread

6 years agoAuto merge of #51181 - mbrubeck:prelude, r=petrochenkov
bors [Fri, 1 Jun 2018 10:48:14 +0000 (10:48 +0000)]
Auto merge of #51181 - mbrubeck:prelude, r=petrochenkov

Add std/core to prelude if extern_prelude enabled

Fixes #50605

6 years agoAuto merge of #51060 - michaelwoerister:thread-safe-consts, r=Zoxc
bors [Fri, 1 Jun 2018 08:46:38 +0000 (08:46 +0000)]
Auto merge of #51060 - michaelwoerister:thread-safe-consts, r=Zoxc

Make const decoding thread-safe.

This is an alternative to https://github.com/rust-lang/rust/pull/50957. It's a proof of concept (e.g. it doesn't adapt metadata decoding, just the incr. comp. cache) but I think it turned out nice. It's rather simple and does not require passing around a bunch of weird closures, like we currently do.

If you (@Zoxc & @oli-obk) think this approach is good then I'm happy to finish and clean this up.

Note: The current version just spins when it encounters an in-progress decoding. I don't have a strong preference for this approach. Decoding concurrently is equally fine by me (or maybe even better because it doesn't require poisoning).

r? @Zoxc

6 years agoRemove outdated AllocId decoding function.
Michael Woerister [Tue, 29 May 2018 08:52:36 +0000 (10:52 +0200)]
Remove outdated AllocId decoding function.

6 years agoMake metadata decoding use AllocDecodingState/Session.
Michael Woerister [Tue, 29 May 2018 08:26:26 +0000 (10:26 +0200)]
Make metadata decoding use AllocDecodingState/Session.

6 years agoMake const decoding from the incremental cache thread-safe.
Michael Woerister [Fri, 25 May 2018 15:19:31 +0000 (17:19 +0200)]
Make const decoding from the incremental cache thread-safe.

6 years agoAdd TinyList data structure.
Michael Woerister [Mon, 28 May 2018 15:43:53 +0000 (17:43 +0200)]
Add TinyList data structure.

6 years agoAuto merge of #51225 - oli-obk:miri_oob_ptr, r=eddyb
bors [Fri, 1 Jun 2018 06:42:12 +0000 (06:42 +0000)]
Auto merge of #51225 - oli-obk:miri_oob_ptr, r=eddyb

Fix the miri submodule

cc @bjorn3

r? @eddyb

6 years agoAuto merge of #51171 - faern:const-bswap-ctpop-cttz-ctlz, r=oli-obk
bors [Fri, 1 Jun 2018 03:24:54 +0000 (03:24 +0000)]
Auto merge of #51171 - faern:const-bswap-ctpop-cttz-ctlz, r=oli-obk

Make some std::intrinsics `const fn`s

Making some rustc intrinsics (`ctpop`, `cttz`, `ctlz` and `bswap`) `const fn`s.

This is a pre-step to being able to make `swap_bytes`, `to_be` and `from_be` constant functions. That in itself could be ergonomic and useful. But even better is that it would allow `Ipv4Addr::new` etc becoming `const fn`s as well. Which might be really useful since I find it quite common to want to define them as constants.

r? @oli-obk

6 years agoAuto merge of #50836 - jsgf:arc-downcast, r=SimonSapin
bors [Fri, 1 Jun 2018 01:09:25 +0000 (01:09 +0000)]
Auto merge of #50836 - jsgf:arc-downcast, r=SimonSapin

Arc downcast

Implement `downcast` for `Arc<Any + Send + Sync>` as part of #44608, and gated by the same `rc_downcast` feature.

This PR is mostly lightly-edited cut'n'paste.

This has two additional changes:
- The `downcast` implementation needs `Any + Send + Sync` implementations for `is` and `Debug`, and I added `downcast_ref` and `downcast_mut` for completeness/consistency. (Can these be insta-stabilized?)
- At @SimonSapin's suggestion, I converted `Arc` and `Rc` to use `NonNull::cast` to avoid an `unsafe` block in each which tidied things up nicely.

6 years agoAuto merge of #51096 - matthewjasper:reverse-normalization-bounds, r=nikomatsakis
bors [Thu, 31 May 2018 22:58:37 +0000 (22:58 +0000)]
Auto merge of #51096 - matthewjasper:reverse-normalization-bounds, r=nikomatsakis

Register outlives predicates from queries the right way around.

Closes #49354
The region constraints from queries need to be reversed from sub to outlives.

Note: wf checking reports these errors before NLL, so I'm not sure if there's any case when these predicates need to be created at all.

cc @nikomatsakis

6 years agoAuto merge of #51257 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Thu, 31 May 2018 20:44:04 +0000 (20:44 +0000)]
Auto merge of #51257 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #49546 (Stabilize short error format)
 - #51123 (Update build instructions)
 - #51146 (typeck: Do not pass the field check on field error)
 - #51193 (Fixes some style issues in rustdoc "implementations on Foreign types")
 - #51213 (fs: copy: Use File::set_permissions instead of fs::set_permissions)
 - #51227 (mod.rs isn't beautiful)
 - #51240 (Two minor parsing tweaks)

Failed merges:

6 years agoFix up Any doc examples
Jeremy Fitzhardinge [Fri, 18 May 2018 15:18:44 +0000 (08:18 -0700)]
Fix up Any doc examples

Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.

6 years agoUpdate `Arc` and `Rc` to use `NonNull::cast` to cast the inner pointers
Jeremy Fitzhardinge [Thu, 17 May 2018 15:25:48 +0000 (08:25 -0700)]
Update `Arc` and `Rc` to use `NonNull::cast` to cast the inner pointers

This avoids an `unsafe` block in each case.

6 years agoImplement `downcast` for `Arc<Any + Send + Sync>`
Jeremy Fitzhardinge [Thu, 17 May 2018 15:17:35 +0000 (08:17 -0700)]
Implement `downcast` for `Arc<Any + Send + Sync>`

We only need to implement it for `Any + Send + Sync` because in practice
that's the only useful combination for `Arc` and `Any`.

Implementation for #44608 under the `rc_downcast` feature.

6 years agoAdd implementations for Any + Send + Sync
Jeremy Fitzhardinge [Thu, 17 May 2018 06:09:58 +0000 (23:09 -0700)]
Add implementations for Any + Send + Sync

Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for
`Any + Send + Sync`.

6 years agoRollup merge of #51240 - nnethercote:parse-2, r=nikomatsakis
Guillaume Gomez [Thu, 31 May 2018 20:17:16 +0000 (22:17 +0200)]
Rollup merge of #51240 - nnethercote:parse-2, r=nikomatsakis

Two minor parsing tweaks

6 years agoRollup merge of #51227 - uuttff8:master, r=dtolnay
Guillaume Gomez [Thu, 31 May 2018 20:17:15 +0000 (22:17 +0200)]
Rollup merge of #51227 - uuttff8:master, r=dtolnay

mod.rs isn't beautiful

I hate this spaces.

6 years agoRollup merge of #51213 - nicokoch:copy_permissions, r=cramertj
Guillaume Gomez [Thu, 31 May 2018 20:17:14 +0000 (22:17 +0200)]
Rollup merge of #51213 - nicokoch:copy_permissions, r=cramertj

fs: copy: Use File::set_permissions instead of fs::set_permissions

We already got the open file descriptor at this point.
Don't make the kernel resolve the path again.

6 years agoRollup merge of #51193 - GuillaumeGomez:fixes-style-issues, r=QuietMisdreavus
Guillaume Gomez [Thu, 31 May 2018 20:17:13 +0000 (22:17 +0200)]
Rollup merge of #51193 - GuillaumeGomez:fixes-style-issues, r=QuietMisdreavus

Fixes some style issues in rustdoc "implementations on Foreign types"

Fixes #51113.

r? @QuietMisdreavus

6 years agoRollup merge of #51146 - dlrobertson:fix_51102, r=estebank
Guillaume Gomez [Thu, 31 May 2018 20:17:12 +0000 (22:17 +0200)]
Rollup merge of #51146 - dlrobertson:fix_51102, r=estebank

typeck: Do not pass the field check on field error

If a struct pattern has a field error return an error.

Fixes: #51102
6 years agoRollup merge of #51123 - akoserwal:master, r=Mark-Simulacrum
Guillaume Gomez [Thu, 31 May 2018 20:17:10 +0000 (22:17 +0200)]
Rollup merge of #51123 - akoserwal:master, r=Mark-Simulacrum

Update build instructions

It get stuck at the cloning step.
`./x.py build `
Updating only changed submodules
Updating submodule src/llvm
Submodule 'src/llvm' (https://github.com/rust-lang/llvm.git) registered for path 'src/llvm'
Cloning into '/home/username/rust/src/llvm'...

6 years agoRollup merge of #49546 - GuillaumeGomez:stabilize-short-error-format, r=oli-obk
Guillaume Gomez [Thu, 31 May 2018 20:17:09 +0000 (22:17 +0200)]
Rollup merge of #49546 - GuillaumeGomez:stabilize-short-error-format, r=oli-obk

Stabilize short error format

r? @oli-obk

Added in https://github.com/rust-lang/rust/pull/44636

6 years agoRegister outlives predicates from queries the right way around.
Matthew Jasper [Sat, 26 May 2018 10:47:38 +0000 (11:47 +0100)]
Register outlives predicates from queries the right way around.

6 years agoUpdate build instructions
Abhishek koserwal [Mon, 28 May 2018 11:57:15 +0000 (17:27 +0530)]
Update build instructions

6 years agoMake short-error format GNU compatible
Guillaume Gomez [Thu, 3 May 2018 21:18:49 +0000 (23:18 +0200)]
Make short-error format GNU compatible

6 years agoStabilize short error format
Guillaume Gomez [Sat, 31 Mar 2018 22:10:34 +0000 (00:10 +0200)]
Stabilize short error format

6 years agoAuto merge of #51050 - symphorien:fstatat, r=kennytm
bors [Thu, 31 May 2018 17:47:12 +0000 (17:47 +0000)]
Auto merge of #51050 - symphorien:fstatat, r=kennytm

std::fs::DirEntry.metadata(): use fstatat instead of lstat when possible

When reading a directory with `read_dir`, querying metadata for a resulting `DirEntry` is done by building the whole path and then `lstat`ing it, which requires the kernel to resolve the whole path. Instead, one
can use the file descriptor to the enumerated directory and use `fstatat`. This make the resolving step
unnecessary.
This PR implements using `fstatat` on linux, android and emscripten.

## Compatibility across targets
`fstatat` is POSIX.
* Linux >= 2.6.19 according to https://linux.die.net/man/2/fstatat
* android according to https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt#392
* emscripten according to https://github.com/kripken/emscripten/blob/7f89560101843198787530731f40a65288f6f15f/system/include/libc/sys/stat.h#L76

The man page says "A similar system call exists on Solaris." but I haven't found it.

## Compatibility with old platforms
This was introduced with glibc 2.4 according to the man page. The only information I could find about the minimal version of glibc rust must support is this discussion https://internals.rust-lang.org/t/bumping-glibc-requirements-for-the-rust-toolchain/5111/10
The conclusion, if I understand correctly, is that currently rust supports glibc >= 2.3.4 but the "real" requirement is Centos 5 with glibc 2.5. This PR would make the minimal version 2.4, so this should be fine.

## Benefit
I did the following silly benchmark:
```rust
use std::io;
use std::fs;
use std::os::linux::fs::MetadataExt;
use std::time::Instant;

fn main() -> Result<(), io::Error> {
    let mut n = 0;
    let mut size = 0;
    let start = Instant::now();
    for entry in fs::read_dir("/nix/store/.links")? {
        let entry = entry?;
        let stat = entry.metadata()?;
        size += stat.st_size();
        n+=1;
    }
    println!("{} files, size {}, time {:?}", n, size, Instant::now().duration_since(start));
    Ok(())
}
```
On warm cache, with current rust nightly:
```
1014099 files, size 76895290022, time Duration { secs: 2, nanos: 65832118 }
```
(between 2.1 and 2.9 seconds usually)
With this PR:
```
1014099 files, size 76895290022, time Duration { secs: 1, nanos: 581662953 }
```
(1.5 to 1.6 seconds usually).

approximately 40% faster :)

On cold cache there is not much to gain because path lookup (which we spare) would have been a cache hit:
Before
```
1014099 files, size 76895290022, time Duration { secs: 391, nanos: 739874992 }
```
After
```
1014099 files, size 76895290022, time Duration { secs: 388, nanos: 431567396 }
```
## Testing
The tests were run on linux `x86_64`
```
python x.py test src/tools/tidy
./x.py test src/libstd
```
and the above benchmark.
I did not test any other target.

6 years agoRename num -> bits and num -> out_val
Linus Färnstrand [Thu, 31 May 2018 17:43:56 +0000 (19:43 +0200)]
Rename num -> bits and num -> out_val

6 years agoRename bytes -> bits
Linus Färnstrand [Thu, 31 May 2018 17:21:34 +0000 (19:21 +0200)]
Rename bytes -> bits

6 years agolibstd/sys/unix/fs.rs: fix compilation on fuchsia
Guillaume Girol [Thu, 31 May 2018 17:18:58 +0000 (19:18 +0200)]
libstd/sys/unix/fs.rs: fix compilation on fuchsia

6 years agoRewrite numeric_intrinsic without macro
Linus Färnstrand [Wed, 30 May 2018 21:27:11 +0000 (23:27 +0200)]
Rewrite numeric_intrinsic without macro

6 years agoAdd test for intrinsics::bswap
Linus Färnstrand [Tue, 29 May 2018 14:00:01 +0000 (16:00 +0200)]
Add test for intrinsics::bswap

6 years agoMake ctpop, cttz, ctlz and bswap const fns
Linus Färnstrand [Tue, 29 May 2018 09:41:10 +0000 (11:41 +0200)]
Make ctpop, cttz, ctlz and bswap const fns

6 years agoAuto merge of #51235 - nikomatsakis:issue-51117-borrowck-implicit-deref, r=eddyb
bors [Thu, 31 May 2018 15:24:04 +0000 (15:24 +0000)]
Auto merge of #51235 - nikomatsakis:issue-51117-borrowck-implicit-deref, r=eddyb

remove notion of Implicit derefs from mem-cat

`PointerKind` is included in `LoanPath` and hence forms part of the equality check; this led to having two unequal paths that both represent `*x`, depending on whether the `*` was inserted automatically or explicitly. Bad mojo.

Fixes #51117

r? @eddyb

6 years agotypeck: Do not pass the field check on field error
Dan Robertson [Tue, 29 May 2018 01:51:36 +0000 (01:51 +0000)]
typeck: Do not pass the field check on field error

If a struct pattern has a field error return an error.

6 years agochange `PointerKind::Implicit` to a note
Niko Matsakis [Thu, 31 May 2018 14:17:51 +0000 (10:17 -0400)]
change `PointerKind::Implicit` to a note

`PointerKind` is included in `LoanPath` and hence forms part of the
equality check; this led to having two unequal paths that both
represent `*x`, depending on whether the `*` was inserted
automatically or explicitly. Bad mojo. The `note` field, in contrast,
is intended more-or-less primarily for this purpose of adding extra
data.

6 years agoAdd std/core to prelude if extern_prelude enabled
Matt Brubeck [Tue, 29 May 2018 18:26:10 +0000 (11:26 -0700)]
Add std/core to prelude if extern_prelude enabled

Fixes #50605

6 years agoAuto merge of #51203 - nnethercote:obligations-2, r=michaelwoerister
bors [Thu, 31 May 2018 13:14:18 +0000 (13:14 +0000)]
Auto merge of #51203 - nnethercote:obligations-2, r=michaelwoerister

Two minor `obligation_forest` tweaks.

Pretty minimal improvements, but improvements nonetheless.

6 years agoAuto merge of #51182 - eddyb:not-just-visibility, r=nikomatsakis
bors [Thu, 31 May 2018 08:55:09 +0000 (08:55 +0000)]
Auto merge of #51182 - eddyb:not-just-visibility, r=nikomatsakis

[MIR] Change "scopes" from "visibility scopes" to "source scopes".

These scopes are already used for source-oriented diagnostics, lint levels and unsafety checks.
This PR generalizes the naming around scopes, making the type `SourceScope`, and flips (across several commits) the relationship/priority between `LocalDecl`'s "visibility" and "syntactic" scopes.

r? @nikomatsakis

6 years agoUpdate miri submodule
Oliver Schneider [Wed, 30 May 2018 13:59:42 +0000 (15:59 +0200)]
Update miri submodule

6 years agoScalarPair for two element tuples was treated wrongly in closure calls
Oliver Schneider [Wed, 30 May 2018 13:41:43 +0000 (15:41 +0200)]
ScalarPair for two element tuples was treated wrongly in closure calls

6 years agoPull a layout computation out of a loop
Oliver Schneider [Wed, 30 May 2018 10:06:16 +0000 (12:06 +0200)]
Pull a layout computation out of a loop

6 years agoDon't invalidate one byte beyond the end
Oliver Schneider [Wed, 30 May 2018 10:05:56 +0000 (12:05 +0200)]
Don't invalidate one byte beyond the end

6 years agoDon't store the discriminant with the enum's type size
Oliver Schneider [Wed, 30 May 2018 10:05:38 +0000 (12:05 +0200)]
Don't store the discriminant with the enum's type size

6 years agoUpdate the miri submodule
Oliver Schneider [Wed, 30 May 2018 10:05:17 +0000 (12:05 +0200)]
Update the miri submodule

6 years agoAuto merge of #51127 - frewsxcv:frewsxcv-discriminant, r=GuillaumeGomez
bors [Thu, 31 May 2018 06:38:24 +0000 (06:38 +0000)]
Auto merge of #51127 - frewsxcv:frewsxcv-discriminant, r=GuillaumeGomez

Add doc link from discriminant struct to function.

None

6 years agoAvoid an unnecessary `match` when lexing "<-".
Nicholas Nethercote [Thu, 31 May 2018 03:37:44 +0000 (13:37 +1000)]
Avoid an unnecessary `match` when lexing "<-".

6 years agoTweak identifer lexing.
Nicholas Nethercote [Thu, 31 May 2018 00:52:29 +0000 (10:52 +1000)]
Tweak identifer lexing.

By calling `bump()` after getting the first char, to avoid a redundant
`ident_continue()` test on it.

6 years agoAdd doc link from discriminant struct to function.
Corey Farwell [Mon, 28 May 2018 13:18:04 +0000 (09:18 -0400)]
Add doc link from discriminant struct to function.

6 years agoAuto merge of #51145 - petrochenkov:npbot, r=alexcrichton
bors [Thu, 31 May 2018 03:18:00 +0000 (03:18 +0000)]
Auto merge of #51145 - petrochenkov:npbot, r=alexcrichton

resolve: Make sure indeterminate and inconsistent macro resolutions always generate errors

Addresses the issue described in https://github.com/rust-lang/rust/pull/50911#issuecomment-392560525

I haven't come up with a minimized reproduction yet, but confirmed that `npbot` now generates the correct error with `![feature(use_extern_macros)]`.

6 years agoAuto merge of #51220 - nikomatsakis:issue-51008-false-positive-lifetime-must-be-decla...
bors [Thu, 31 May 2018 01:06:33 +0000 (01:06 +0000)]
Auto merge of #51220 - nikomatsakis:issue-51008-false-positive-lifetime-must-be-declared, r=cramertj

reset anonymous-lifetime-mode as we enter `()` scopes

Background:

The anonymous lifetime mode is used to prohibit elided lifetimes where
they didn't used to be permitted, and instead require that `'_` be
used. For example:

```rust
impl Trait for Ref<T> { .. }
//             ^^^^^^ ERROR: should be `Ref<'_, T>`
```

When we are parsing the parts of the impl header, we enter into an alternate mode called `CreateParameter`. In this mode, we give an error for things like `Ref<T>`, but for elided lifetimes in a reference type like `&T` we make the elided lifetime into an in-band lifetime:

https://github.com/rust-lang/rust/blob/4f99f37b7e213d69a489884f651adfc6d217cef5/src/librustc/hir/lowering.rs#L4017-L4035

This was not intended to change behavior because we only enter into that mode in contexts where elision was not historically permitted. However, the problem is that we fail to reset the mode when we enter into bounds like `Fn(&u32)`, where elision *was* allowed -- the same occurs for fn types like `fn(&u32`). This PR restores the original mode in those contexts.

Fixes #51008

r? @cramertj

6 years agoInline `NodeIndex` methods.
Nicholas Nethercote [Wed, 30 May 2018 06:58:48 +0000 (16:58 +1000)]
Inline `NodeIndex` methods.

Because they are small and hot.

6 years agoRemove `ObligationForest::cache_list`.
Nicholas Nethercote [Wed, 30 May 2018 01:36:31 +0000 (11:36 +1000)]
Remove `ObligationForest::cache_list`.

It's never used in a meaningful way.

6 years agoAuto merge of #51138 - spastorino:add-polonius-compare-mode, r=pnkfelix
bors [Wed, 30 May 2018 22:59:21 +0000 (22:59 +0000)]
Auto merge of #51138 - spastorino:add-polonius-compare-mode, r=pnkfelix

Add polonius compare mode

**This is now ready to review/merge**

6 years agoAuto merge of #51215 - eddyb:visit-for-a-lifetime, r=nikomatsakis
bors [Wed, 30 May 2018 20:34:23 +0000 (20:34 +0000)]
Auto merge of #51215 - eddyb:visit-for-a-lifetime, r=nikomatsakis

 rustc: don't visit lifetime parameters through visit_lifetime.

Ideally we'd also not use the `Lifetime` struct for parameters, but I'll leave that to @varkor (#48149).
Fixes #51185 (discovered while auditing all the `visit_lifetime` implementations).
r? @nikomatsakis

6 years agomod.rs isn't beautiful
uuttff8 [Wed, 30 May 2018 19:24:24 +0000 (22:24 +0300)]
mod.rs isn't beautiful

6 years agoresolve: Make sure indeterminate and inconsistent macro resolutions always generate...
Vadim Petrochenkov [Mon, 28 May 2018 19:13:59 +0000 (22:13 +0300)]
resolve: Make sure indeterminate and inconsistent macro resolutions always generate errors

6 years agoalso reset anon-param-mode for `fn()` types
Niko Matsakis [Wed, 30 May 2018 14:40:42 +0000 (10:40 -0400)]
also reset anon-param-mode for `fn()` types

6 years agoreset the "anonymous lifetime mode" for parenthesized where clauses
Niko Matsakis [Wed, 30 May 2018 14:27:53 +0000 (10:27 -0400)]
reset the "anonymous lifetime mode" for parenthesized where clauses

Background:

The anonymous lifetime mode is used to prohibit elided lifetimes where
they didn't used to be permitted, and instead require that `'_` be
used. For example:

```rust
impl Trait for Ref<T> { .. }
//             ^^^^^^ ERROR: should be `Ref<'_, T>`
```

When we are parsing the parts of the impl header, we enter into an
alternate mode called `CreateParameter`. In this mode, we give an
error for things like `Ref<T>`, but for elided lifetimes in a
reference type like `&T` we make the elided lifetime into an in-band
lifetime:

https://github.com/rust-lang/rust/blob/4f99f37b7e213d69a489884f651adfc6d217cef5/src/librustc/hir/lowering.rs#L4017-L4035

This was not intended to change behavior because we only enter into
that mode in contexts where elision was not historically
permitted. However, the problem is that we fail to reset the mode when
we enter into bounds like `Fn(&u32)`, where elision *was* allowed --
the same occurs for fn types like `fn(&u32`). This PR restores the
original mode in those contexts.

6 years agostd::fs::DirEntry.metadata(): use fstatat instead of lstat when possible
Guillaume Girol [Thu, 24 May 2018 21:50:28 +0000 (23:50 +0200)]
std::fs::DirEntry.metadata(): use fstatat instead of lstat when possible

6 years agoRun rustfmt
Santiago Pastorino [Wed, 30 May 2018 17:33:43 +0000 (14:33 -0300)]
Run rustfmt

6 years agoAdd compare-mode to x.py
Santiago Pastorino [Mon, 28 May 2018 22:44:33 +0000 (19:44 -0300)]
Add compare-mode to x.py

6 years agorustc: rename mir::LocalDecl's syntactic_source_info to source_info.
Eduard-Mihai Burtescu [Tue, 29 May 2018 18:31:33 +0000 (21:31 +0300)]
rustc: rename mir::LocalDecl's syntactic_source_info to source_info.

6 years agorustc: turn mir::LocalDecl's visibility_source_info into a SourceScope.
Eduard-Mihai Burtescu [Tue, 29 May 2018 10:55:21 +0000 (13:55 +0300)]
rustc: turn mir::LocalDecl's visibility_source_info into a SourceScope.

6 years agorustc: use syntactic (instead of visibility) source info where appropriate.
Eduard-Mihai Burtescu [Tue, 29 May 2018 10:54:24 +0000 (13:54 +0300)]
rustc: use syntactic (instead of visibility) source info where appropriate.

6 years agorustc: rename mir::LocalDecl's source_info to visibility_source_info.
Eduard-Mihai Burtescu [Tue, 29 May 2018 14:37:24 +0000 (17:37 +0300)]
rustc: rename mir::LocalDecl's source_info to visibility_source_info.

6 years agorustc: turn mir::LocalDecl's syntactic_scope into a SourceInfo.
Eduard-Mihai Burtescu [Tue, 29 May 2018 09:24:53 +0000 (12:24 +0300)]
rustc: turn mir::LocalDecl's syntactic_scope into a SourceInfo.

6 years agorustc: rename mir::SourceScopeInfo to mir::SourceScopeLocalData.
Eduard-Mihai Burtescu [Mon, 28 May 2018 14:37:48 +0000 (17:37 +0300)]
rustc: rename mir::SourceScopeInfo to mir::SourceScopeLocalData.

6 years agorustc: rename mir::VisibilityScope to mir::SourceScope.
Eduard-Mihai Burtescu [Mon, 28 May 2018 11:16:09 +0000 (14:16 +0300)]
rustc: rename mir::VisibilityScope to mir::SourceScope.

6 years agorustc: don't visit lifetime parameters through visit_lifetime.
Eduard-Mihai Burtescu [Wed, 30 May 2018 11:36:53 +0000 (14:36 +0300)]
rustc: don't visit lifetime parameters through visit_lifetime.

6 years agosyntax: remove overloading of fold_lifetime{,_def}{,s}.
Eduard-Mihai Burtescu [Tue, 29 May 2018 19:56:37 +0000 (22:56 +0300)]
syntax: remove overloading of fold_lifetime{,_def}{,s}.

6 years agoAdd polonius compare mode
Santiago Pastorino [Mon, 28 May 2018 18:30:02 +0000 (15:30 -0300)]
Add polonius compare mode

6 years agoAuto merge of #51100 - estebank:as-ref, r=oli-obk
bors [Wed, 30 May 2018 16:48:53 +0000 (16:48 +0000)]
Auto merge of #51100 - estebank:as-ref, r=oli-obk

Suggest using `as_ref` on some borrow errors [hack]

When encountering the following code:

```rust
struct Foo;
fn takes_ref(_: &Foo) {}
let ref opt = Some(Foo);

opt.map(|arg| takes_ref(arg));
```

Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead.

This is a stop gap solution until we expand typeck to deal with these
cases in a more graceful way.

#43861

6 years agoSuggest using `as_ref` on some borrow errors [hack]
Esteban Küber [Sun, 27 May 2018 00:02:56 +0000 (17:02 -0700)]
Suggest using `as_ref` on some borrow errors [hack]

When encountering the following code:

```rust
struct Foo;
fn takes_ref(_: &Foo) {}
let ref opt = Some(Foo);

opt.map(|arg| takes_ref(arg));
```

Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead.

This is a stop gap solution until we expand typeck to deal with these
cases in a more graceful way.

6 years agoAuto merge of #50955 - steveklabnik:update-libbacktrace, r=alexcrichton
bors [Wed, 30 May 2018 14:19:15 +0000 (14:19 +0000)]
Auto merge of #50955 - steveklabnik:update-libbacktrace, r=alexcrichton

Update libbacktrace

We haven't updated libbacktrace in two years. This is just blindly updating to the latest HEAD; I'd like to see what travis says. It at least builds on my machine, running some tests...

This perpetuates the patches from https://github.com/rust-lang/rust/pull/30908

6 years agoReplace libbacktrace with a submodule
Alex Crichton [Wed, 23 May 2018 02:40:02 +0000 (19:40 -0700)]
Replace libbacktrace with a submodule

While we're at it update the `backtrace` crate from crates.io. It turns out that
the submodule's configure script has gotten a lot more finnicky as of late so
also switch over to using the `cc` crate manually which allows to avoid some
hacks around the configure script as well

6 years agostd: Delete bundled libbacktrace module
Alex Crichton [Sun, 27 May 2018 20:02:34 +0000 (13:02 -0700)]
std: Delete bundled libbacktrace module

6 years agoAuto merge of #50880 - glandium:oom, r=SimonSapin
bors [Wed, 30 May 2018 11:35:00 +0000 (11:35 +0000)]
Auto merge of #50880 - glandium:oom, r=SimonSapin

OOM handling changes

As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent.

This does have codegen implications. Even without the hooks, and with a handler that ignores the arguments, the compiler doesn't eliminate calling `rust_oom` with the `Layout`. Even if it managed to eliminate that, with the hooks, I don't know if the compiler would be able to figure out it can skip it if the hook is never set.

A couple implementation notes:
- I went with explicit enums rather than bools because it makes it clearer in callers what is being requested.
- I didn't know what `feature` to put the hook setting functions behind. (and surprisingly, the compile went through without any annotation on the functions)
- There's probably some bikeshedding to do on the naming.

Cc: @Simonsapin, @sfackler
6 years agoRemobve unused import
Nicolas Koch [Wed, 30 May 2018 10:09:20 +0000 (12:09 +0200)]
Remobve unused import

6 years agoAuto merge of #51106 - davidtwco:issue-50934, r=nikomatsakis
bors [Wed, 30 May 2018 09:24:20 +0000 (09:24 +0000)]
Auto merge of #51106 - davidtwco:issue-50934, r=nikomatsakis

Optimize the way that loans are killed in borrowck dataflow

Fixes #50934.
r? @nikomatsakis

6 years agoAuto merge of #51017 - estebank:crate-name-in-path, r=michaelwoerister
bors [Wed, 30 May 2018 07:10:16 +0000 (07:10 +0000)]
Auto merge of #51017 - estebank:crate-name-in-path, r=michaelwoerister

Use crate name for reexported `extern crate` paths

Fix #43189.

6 years agofs: copy: Use File::set_permissions instead of fs::set_permissions
Nicolas Koch [Wed, 30 May 2018 04:33:54 +0000 (06:33 +0200)]
fs: copy: Use File::set_permissions instead of fs::set_permissions

We already got the open file descriptor at this point.
Don't make the kernel resolve the path again.

6 years agoAuto merge of #50783 - pnkfelix:issue-27282-match-borrows-its-input-take-three, r...
bors [Wed, 30 May 2018 02:11:59 +0000 (02:11 +0000)]
Auto merge of #50783 - pnkfelix:issue-27282-match-borrows-its-input-take-three, r=nikomatsakis

every match arm reads the match's borrowed input

This PR changes the `match` codegen under NLL (and just NLL, at least for now) to make the following adjustments:
 * It adds a `-Z disable-ast-check-for-mutation-in-guard` which, as described, turns off the naive (conservative but also not 100% sound) check for mutation in guards of match arms.
 * We now borrow the match input at the outset and emit a special `ReadForMatch` statement (that, according to the *static* semantics, reads that borrowed match input) at the start of each match arm. The intent here is to catch cases where the match guard mutates the match input, either via an independent borrow or via `ref mut` borrows in that arm's pattern.
 * In order to ensure that `ref mut` borrows do not actually conflict with the emitted `ReadForMatch` statements, I expanded the two-phase-borrow system slightly, and also changed the MIR code gen so that under NLL, when there is a guard on a match arm, then each pattern variable ends up having *three* temporaries associated with it:
   1. The first temporary will hold the substructure being matched; this is what we will move the (substructural) value into *if* the guard succeeds.
   2. The second temporary also corresponds to the same value as the first, but we are just constructing this temporarily for use during the scope of the guard; it is unaliased and its sole referrer is the third temporary.
   3. The third temporary is a reference to the second temporary.
   * (This sounds complicated, I know, but its actually *simpler* than what I was doing before and had checked into the repo, which was to sometimes construct the final value and then take a reference to it before evaluating the guard. See also PR #49870.)

Fix #27282

This also provides a path towards resolving #24535 aka rust-lang/rfcs#1006, at least once the `-Z disable-ast-check-for-mutation-in-guard` is just turned on by default (under NLL, that is. It is not sound under AST-borrowck).
 * But I did not want to make `#![feature(nll)]` imply that as part of this PR; that seemed like too drastic a change to me.

6 years agoAdd hooks allowing to override the `oom` behavior
Mike Hommey [Wed, 16 May 2018 00:16:37 +0000 (09:16 +0900)]
Add hooks allowing to override the `oom` behavior

6 years agoAuto merge of #50772 - nicokoch:fastcopy, r=alexcrichton
bors [Tue, 29 May 2018 23:49:11 +0000 (23:49 +0000)]
Auto merge of #50772 - nicokoch:fastcopy, r=alexcrichton

fs: copy: use copy_file_range on Linux

Linux 4.5 introduced a new system call [copy_file_range](http://man7.org/linux/man-pages/man2/copy_file_range.2.html) to copy data from one file to another.

This PR uses the new system call (if available). This has several advantages:

1. No need to constantly copy data from userspace to kernel space, if the buffer is small or the file is large
2. On some filesystems, like BTRFS, the kernel can leverage internal fs mechanisms for huge performance gains
3. Filesystems on the network dont need to copy data between the host and the client machine (they have to in the current read/write implementation)

I have created a small library that also implements the new system call for some huge performance gains here: https://github.com/nicokoch/fastcopy
Benchmark results are in the README

6 years agoFixes some style issues in rustdoc "implementations on Foreign types"
Guillaume Gomez [Tue, 29 May 2018 23:10:48 +0000 (01:10 +0200)]
Fixes some style issues in rustdoc "implementations on Foreign types"

6 years agoFix additional nits:
Nicolas Koch [Tue, 29 May 2018 21:42:42 +0000 (23:42 +0200)]
Fix additional nits:
  - compute bytes_to_copy more elegantly
  - add assert that written is 0 in fallback case

6 years agoReview feedback: Adding test cases suggested by arielb1.
Felix S. Klock II [Wed, 23 May 2018 09:21:01 +0000 (11:21 +0200)]
Review feedback: Adding test cases suggested by arielb1.

6 years agoReview feedback: Fix typo.
Felix S. Klock II [Tue, 22 May 2018 14:50:03 +0000 (16:50 +0200)]
Review feedback: Fix typo.

6 years agoReview feedback, remove fixme comment.
Felix S. Klock II [Tue, 22 May 2018 14:48:43 +0000 (16:48 +0200)]
Review feedback, remove fixme comment.

6 years agoReview feedback: Remove a fixme/tbd note and just add a note for the post-NLL future.
Felix S. Klock II [Tue, 22 May 2018 14:45:21 +0000 (16:45 +0200)]
Review feedback: Remove a fixme/tbd note and just add a note for the post-NLL future.

Driveby: just inline the two-line `fn inject_borrow` into its one call
site and remove its definition.

6 years agoReview feedback: update fixme comment to reflect reality.
Felix S. Klock II [Tue, 22 May 2018 13:05:02 +0000 (15:05 +0200)]
Review feedback: update fixme comment to reflect reality.

6 years agoreview feedback: fix indentation of pattern candidates to match code elsewhere in...
Felix S. Klock II [Tue, 22 May 2018 13:03:40 +0000 (15:03 +0200)]
review feedback: fix indentation of pattern candidates to match code elsewhere in file.

6 years agoTests illustrating the bug fixes for #27282 and #24535.
Felix S. Klock II [Tue, 15 May 2018 21:23:00 +0000 (23:23 +0200)]
Tests illustrating the bug fixes for #27282 and #24535.