summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* random #include removalHEADmasterTom Tromey2018-05-302-64/+1
|
* Auto merge of #51138 - spastorino:add-polonius-compare-mode, r=pnkfelixbors2018-05-305-782/+1230
|\ | | | | | | | | | | Add polonius compare mode **This is now ready to review/merge**
| * Run rustfmtSantiago Pastorino2018-05-304-783/+1206
| |
| * Add compare-mode to x.pySantiago Pastorino2018-05-303-1/+14
| |
| * Add polonius compare modeSantiago Pastorino2018-05-302-2/+14
| |
* | Auto merge of #51215 - eddyb:visit-for-a-lifetime, r=nikomatsakisbors2018-05-309-143/+122
|\ \ | | | | | | | | | | | | | | | | | | | | | 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
| * | rustc: don't visit lifetime parameters through visit_lifetime.Eduard-Mihai Burtescu2018-05-308-89/+102
| | |
| * | syntax: remove overloading of fold_lifetime{,_def}{,s}.Eduard-Mihai Burtescu2018-05-301-54/+20
| |/
* | Auto merge of #51100 - estebank:as-ref, r=oli-obkbors2018-05-303-16/+144
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Suggest using `as_ref` on some borrow errors [hack]Esteban Küber2018-05-303-16/+144
|/ | | | | | | | | | | | | | | | | 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.
* Auto merge of #50955 - steveklabnik:update-libbacktrace, r=alexcrichtonbors2018-05-3047-40245/+62
|\ | | | | | | | | | | | | | | 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
| * Replace libbacktrace with a submoduleAlex Crichton2018-05-306-26/+62
| | | | | | | | | | | | | | 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
| * std: Delete bundled libbacktrace moduleAlex Crichton2018-05-3041-40219/+0
| |
* | Auto merge of #50880 - glandium:oom, r=SimonSapinbors2018-05-3010-113/+206
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Add hooks allowing to override the `oom` behaviorMike Hommey2018-05-301-2/+46
| |
| * Pass a `Layout` to `oom`Mike Hommey2018-05-3010-112/+161
| | | | | | | | | | | | | | | | As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent, there are use-cases where the OOM handler needs to know the size of the allocation that failed. The alignment might also be a cause for allocation failure, so providing it as well can be useful.
* | Auto merge of #51106 - davidtwco:issue-50934, r=nikomatsakisbors2018-05-302-14/+78
|\ \ | | | | | | | | | | | | | | | | | | Optimize the way that loans are killed in borrowck dataflow Fixes #50934. r? @nikomatsakis
| * | fix off by one errorNiko Matsakis2018-05-291-1/+1
| | |
| * | tweak debug output some moreNiko Matsakis2018-05-292-3/+8
| | |
| * | Ensure that all statements in block are visited not just successors of a block.David Wood2018-05-291-8/+18
| | |
| * | add some debugging statementsNiko Matsakis2018-05-291-0/+3
| | |
| * | Refactored DFS to be much cleaner. Added continue after noting that borrow ↵David Wood2018-05-291-99/+27
| | | | | | | | | | | | is out of scope at location.
| * | Ensure that depth first search does not get stuck in cycles.David Wood2018-05-271-12/+28
| | |
| * | Ensure that we don't skip the last statement.David Wood2018-05-271-2/+2
| | |
| * | Use precomputed DFS of borrows that out of scope at a location.David Wood2018-05-271-14/+116
| | |
* | | Auto merge of #51017 - estebank:crate-name-in-path, r=michaelwoeristerbors2018-05-305-1/+72
|\ \ \ | | | | | | | | | | | | | | | | | | | | Use crate name for reexported `extern crate` paths Fix #43189.
| * | | Add test for reexported crate namesEsteban Küber2018-05-284-0/+67
| | | |
| * | | Use crate name for reexported `extern crate` pathsEsteban Küber2018-05-231-1/+5
| | | |
* | | | Auto merge of #50783 - ↵bors2018-05-3037-235/+790
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | Review feedback: Adding test cases suggested by arielb1.Felix S. Klock II2018-05-294-0/+146
| | | | |
| * | | | Review feedback: Fix typo.Felix S. Klock II2018-05-291-1/+1
| | | | |
| * | | | Review feedback, remove fixme comment.Felix S. Klock II2018-05-291-17/+0
| | | | |
| * | | | Review feedback: Remove a fixme/tbd note and just add a note for the ↵Felix S. Klock II2018-05-291-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | post-NLL future. Driveby: just inline the two-line `fn inject_borrow` into its one call site and remove its definition.
| * | | | Review feedback: update fixme comment to reflect reality.Felix S. Klock II2018-05-291-3/+2
| | | | |
| * | | | review feedback: fix indentation of pattern candidates to match code ↵Felix S. Klock II2018-05-291-3/+3
| | | | | | | | | | | | | | | | | | | | elsewhere in file.
| * | | | Tests illustrating the bug fixes for #27282 and #24535.Felix S. Klock II2018-05-297-0/+211
| | | | |
| * | | | Test update: Fallout from ReadForMatch statements + changes to codegen under ↵Felix S. Klock II2018-05-291-112/+125
| | | | | | | | | | | | | | | | | | | | NLL.
| * | | | Expand two-phase-borrows so that a case like this still compiles:Felix S. Klock II2018-05-295-113/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```rust fn main() { fn reuse<X>(_: &mut X) {} let mut t = 2f64; match t { ref mut _b if { false } => { reuse(_b); } _ => {} } } ``` Note: The way this is currently written is confusing; when `autoref` is off, then the arm body bindings (introduced by `bind_matched_candidate_for_arm_body`) are *also* used for the guard. (Any attempt to fix this needs to still ensure that the bindings used by the guard are introduced before the guard is evaluated.) (Once we turn NLL on by default, we can presumably simplify all of that.)
| * | | | Fallout from allowing some mutation in guards.Felix S. Klock II2018-05-291-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some reason, allowing restricted mutation in match arms exposed an obvious case where a unique borrow can indeed fail, namely something like: ```rust match b { ... ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); false } => { &mut *r } // ~~~~~~~ // | // This ends up holding a `&unique` borrow of `r`, but there ends up being an // implicit shared borrow in the guard thanks to rust-lang/rust#49870 ... } ```
| * | | | rust-lang/rust#41962 has a new error with my new code. Incorporate that into ↵Felix S. Klock II2018-05-292-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | my code. In particular, I am adding an implicit injected borrow on the pattern matches, and when we go around the loop, the compiler is reporting that this injected borrow is conflicting with the move of the original value when the match succeeds.
| * | | | rust-lang/rust#27282: emit `ReadForMatch` on each match arm.Felix S. Klock II2018-05-293-4/+107
| | | | | | | | | | | | | | | | | | | | Also, turn on ReadForMatch emission by default (when using NLL).
| * | | | rust-lang/rust#27282: Add `StatementKind::ReadForMatch` to MIR.Felix S. Klock II2018-05-2915-1/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (This is just the data structure changes and some boilerplate match code that followed from it; the actual emission of these statements comes in a follow-up commit.)
| * | | | Debug flag to bypass restriction of mutation in match guards.Felix S. Klock II2018-05-293-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now, if you pass `-Z disable-ast-check-for-mutation-in-guard`, then we will just allow you to mutably-borrow and assign in guards of `match` arms. This is wildly unsound with AST-borrowck. It is also unsound with MIR-borrowck without further adjustments, which come in later in the commit series on this Pull Request. See also rust-lang/rust#24535 and rust-lang/rfcs#1006.
* | | | | Auto merge of #50772 - nicokoch:fastcopy, r=alexcrichtonbors2018-05-291-0/+88
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | | Fix additional nits:Nicolas Koch2018-05-291-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | - compute bytes_to_copy more elegantly - add assert that written is 0 in fallback case
| * | | | Use FIXME instead of TODO; Move bytes_to_copy calculation inside ifNicolas Koch2018-05-281-6/+7
| | | | | | | | | | | | | | | | | | | | branch
| * | | | Implement suggestions from the PRNicolas Koch2018-05-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | - Move loading of atomic bool outside the loop - Add comment about TryFrom for future improvement
| * | | | Store ENOSYS in a global to avoid unnecessary system callsNicolas Koch2018-05-171-10/+25
| | | | |
| * | | | Fix large file copies on 32 bit platformsNicolas Koch2018-05-161-2/+6
| | | | |
| * | | | Adjust len in every iterationNicolas Koch2018-05-161-1/+2
| | | | |