about summary refs log tree commit diff
path: root/src/librustc_borrowck
AgeCommit message (Collapse)AuthorLines
2017-05-02Rollup merge of #41640 - gaurikholkar:master, r=nikomatsakisCorey Farwell-1/+8
Consider changing to & for let bindings #40402 This is a fix for #40402 For the example ``` fn main() { let v = vec![String::from("oh no")]; let e = v[0]; } ``` It gives ``` error[E0507]: cannot move out of indexed content --> ex1.rs:4:13 | 4 | let e = v[0]; | ^^^^ cannot move out of indexed content | = help: consider changing to `&v[0]` error: aborting due to previous error ``` Another alternative is ``` error[E0507]: cannot move out of indexed content --> ex1.rs:4:13 | 4 | let e = v[0]; | ^^^^ consider changing to `&v[0]` error: aborting due to previous error ``` Also refer to #41564 for more details. r? @nikomatsakis
2017-05-02have borrowck fetch MIR, which will perform some errorsNiko Matsakis-0/+10
2017-05-02run MIR borrowck on the validated, not optimized, MIRNiko Matsakis-1/+17
2017-05-02simplify the MirPass traits and passes dramaticallyNiko Matsakis-6/+6
Overall goal: reduce the amount of context a mir pass needs so that it resembles a query. - The hooks are no longer "threaded down" to the pass, but rather run automatically from the top-level (we also thread down the current pass number, so that the files are sorted better). - The hook now receives a *single* callback, rather than a callback per-MIR. - The traits are no longer lifetime parameters, which moved to the methods -- given that we required `for<'tcx>` objecs, there wasn't much point to that. - Several passes now store a `String` instead of a `&'l str` (again, no point).
2017-05-02rework `MirPass` API to be stateless and extract helper fnsNiko Matsakis-1/+1
2017-05-02introduce `mir_keys()`Niko Matsakis-2/+2
Each MIR key is a DefId that has MIR associated with it
2017-05-02Using a span_suggestion to display use & hintgaurikholkar-6/+3
2017-05-02Adding consider changing to & suggestion for let bindingsgaurikholkar-1/+11
2017-04-30modify `ExprUseVisitor` and friends to take region-maps, not def-idNiko Matsakis-2/+2
2017-04-30introduce per-fn RegionMapsTaylor Cramer-35/+39
Instead of requesting the region maps for the entire crate, request for a given item etc. Several bits of code were modified to take `&RegionMaps` as input (e.g., the `resolve_regions_and_report_errors()` function). I am not totally happy with this setup -- I *think* I'd rather have the region maps be part of typeck tables -- but at least the `RegionMaps` works in a "parallel" way to `FreeRegionMap`, so it's not too bad. Given that I expect a lot of this code to go away with NLL, I didn't want to invest *too* much energy tweaking it.
2017-04-30intern CodeExtentsNiko Matsakis-42/+41
Make a `CodeExtent<'tcx>` be something allocated in an arena instead of an index into the `RegionMaps`.
2017-04-30remove ROOT_CODE_EXTENT and DUMMY_CODE_EXTENTNiko Matsakis-1/+1
Instead, thread around `Option<CodeExtent>` where applicable.
2017-04-30On-demandify region mappingTaylor Cramer-20/+20
2017-04-28Adding documentation, indentation fixesgaurikholkar-19/+39
2017-04-28Disable ref hint for pattern in let and adding ui-tests.gaurikholkar-16/+71
2017-04-27Rollup merge of #41523 - estebank:moved, r=arielb1Corey Farwell-2/+5
Point at variable moved by closure Fix #41482, #31752.
2017-04-25Point at variable moved by closureEsteban Küber-2/+5
2017-04-24rustc: expose the common DUMMY_SP query case as tcx methods.Eduard-Mihai Burtescu-2/+2
2017-04-24rustc: rename some of the queries to match tcx methods.Eduard-Mihai Burtescu-2/+2
2017-04-22avoid calling `mk_region` unnecessarilyAriel Ben-Yehuda-1/+1
this improves typeck & trans performance by 1%. This looked hotter on callgrind than it is on a CPU.
2017-04-20rustc: combine type_needs_drop_given_env and may_drop into needs_drop.Eduard-Mihai Burtescu-1/+1
2017-04-14Auto merge of #41153 - petrochenkov:umove, r=pnkfelixbors-15/+15
Fix move checking for nested union fields Fixes https://github.com/rust-lang/rust/issues/41126 r? @arielb1
2017-04-12Rollup merge of #41232 - arielb1:mir-rvalues, r=eddybTim Neumann-3/+3
move rvalue checking to MIR
2017-04-12Rollup merge of #41063 - nikomatsakis:issue-40746-always-exec-loops, r=eddybTim Neumann-16/+18
remove unnecessary tasks Remove various unnecessary tasks. All of these are "always execute" tasks that don't do any writes to tracked state (or else an assert would trigger, anyhow). In some cases, they issue lints or errors, but we''ll deal with that -- and anyway side-effects outside of a task don't cause problems for anything that I can see. The one non-trivial refactoring here is the borrowck conversion, which adds the requirement to go from a `DefId` to a `BodyId`. I tried to make a useful helper here. r? @eddyb cc #40746 cc @cramertj @michaelwoerister
2017-04-12fix nitNiko Matsakis-1/+1
2017-04-11store Spans for all MIR localsAriel Ben-Yehuda-3/+3
2017-04-08Auto merge of #41148 - arielb1:dead-unwind, r=nagisabors-38/+121
borrowck::mir::dataflow: ignore unwind edges of empty drops This avoids creating drop flags in many unnecessary situations. Fixes #41110. r? @nagisa beta-nominating because regression. However, that is merely a small perf regression and codegen changes are always risky, so we might let this slide for 1.17.
2017-04-08borrowck::mir::dataflow: ignore unwind edges of empty dropsAriel Ben-Yehuda-38/+121
This avoids creating drop flags in many unnecessary situations. Fixes #41110.
2017-04-08Fix move checking for nested union fieldsVadim Petrochenkov-15/+15
2017-04-07Rollup merge of #40797 - GAJaloyan:patch-1, r=arielb1Corey Farwell-3/+3
Correcting mistakes in the README.md Correcting the two mistakes in the README.md (issue #40793)
2017-04-04push `borrowck` into its own taskNiko Matsakis-16/+18
2017-03-29Rollup merge of #40841 - arielb1:immutable-blame, r=pnkfelixCorey Farwell-123/+140
borrowck: consolidate `mut` suggestions This converts all of borrowck's `mut` suggestions to a new `mc::ImmutabilityBlame` API instead of the current mix of various hacks. Fixes #35937. Fixes #40823. Fixes #40859. cc @estebank r? @pnkfelix
2017-03-27correcting another mistake in an example GAJaloyan-1/+1
copy_pointer -> copy_borrowed_ptr
2017-03-27Fix various useless derefs and slicingsOliver Schneider-14/+14
2017-03-27fix handling of `self`Ariel Ben-Yehuda-29/+31
2017-03-27borrowck: consolidate `mut` suggestionsAriel Ben-Yehuda-104/+119
This converts all of borrowck's `mut` suggestions to a new `mc::ImmutabilityBlame` API instead of the current mix of various hacks. Fixes #35937. Fixes #40823.
2017-03-24issue #40793GAJaloyan-2/+2
Correcting the two mistakes in the README.md
2017-03-23Remove internal liblogAlex Crichton-1/+1
This commit deletes the internal liblog in favor of the implementation that lives on crates.io. Similarly it's also setting a convention for adding crates to the compiler. The main restriction right now is that we want compiler implementation details to be unreachable from normal Rust code (e.g. requires a feature), and by default everything in the sysroot is reachable via `extern crate`. The proposal here is to require that crates pulled in have these lines in their `src/lib.rs`: #![cfg_attr(rustbuild, feature(staged_api, rustc_private))] #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] This'll mean that by default they're not using these attributes but when compiled as part of the compiler they do a few things: * Mark themselves as entirely unstable via the `staged_api` feature and the `#![unstable]` attribute. * Allow usage of other unstable crates via `feature(rustc_private)` which is required if the crate relies on any other crates to compile (other than std).
2017-03-20Auto merge of #39628 - arielb1:shimmir, r=eddybbors-789/+140
Translate shims using MIR This removes one large remaining part of old trans.
2017-03-19Rollup merge of #40445 - estebank:issue-18150, r=jonathandturnerCorey Farwell-0/+19
Point to let when modifying field of immutable variable Point at the immutable local variable when trying to modify one of its fields. Given a file: ```rust struct Foo { pub v: Vec<String> } fn main() { let f = Foo { v: Vec::new() }; f.v.push("cat".to_string()); } ``` present the following output: ``` error: cannot borrow immutable field `f.v` as mutable --> file.rs:7:13 | 6 | let f = Foo { v: Vec::new() }; | - this should be `mut` 7 | f.v.push("cat".to_string()); | ^^^ error: aborting due to previous error ``` Fix #27593.
2017-03-18translate drop glue using MIRAriel Ben-Yehuda-1/+1
Drop of arrays is now translated in trans::block in an ugly way that I should clean up in a later PR, and does not handle panics in the middle of an array drop, but this commit & PR are growing too big.
2017-03-18move the drop expansion code to rustc_mirAriel Ben-Yehuda-788/+139
2017-03-13Add label to primary span for mutable access of immutable struct errorEsteban Küber-3/+8
2017-03-12Change label to "consider changing this to `mut f`"Esteban Küber-1/+3
Change the wording of mutable borrow on immutable binding from "this should be `mut`" to "consider changing this to `mut f`".
2017-03-11Point to let when modifying field of immutable variableEsteban Küber-0/+12
Point at the immutable local variable when trying to modify one of its fields. Given a file: ```rust struct Foo { pub v: Vec<String> } fn main() { let f = Foo { v: Vec::new() }; f.v.push("cat".to_string()); } ``` present the following output: ``` error: cannot borrow immutable field `f.v` as mutable --> file.rs:7:13 | 6 | let f = Foo { v: Vec::new() }; | - this should be `mut` 7 | f.v.push("cat".to_string()); | ^^^ error: aborting due to previous error ```
2017-03-10isolate dep-graph tasksNiko Matsakis-5/+8
A task function is now given as a `fn` pointer to ensure that it carries no state. Each fn can take two arguments, because that worked out to be convenient -- these two arguments must be of some type that is `DepGraphSafe`, a new trait that is intended to prevent "leaking" information into the task that was derived from tracked state. This intentionally leaves `DepGraph::in_task()`, the more common form, alone. Eventually all uses of `DepGraph::in_task()` should be ported to `with_task()`, but I wanted to start with a smaller subset. Originally I wanted to use closures bound by an auto trait, but that approach has some limitations: - the trait cannot have a `read()` method; since the current method is unused, that may not be a problem. - more importantly, we would want the auto trait to be "undefined" for all types *by default* -- that is, this use case doesn't really fit the typical auto trait scenario. For example, imagine that there is a `u32` loaded out of a `hir::Node` -- we don't really want to be passing that `u32` into the task!
2017-03-03Auto merge of #40133 - arielb1:operand-lifetimes, r=eddybbors-0/+1
[MIR] improve operand lifetimes r? @eddyb
2017-03-02schedule drops on bindings only after initializing themAriel Ben-Yehuda-0/+1
This reduces the number of dynamic drops in libstd from 1141 to 899. However, without this change, the next patch would have created much more dynamic drops. A basic merge unswitching hack reduced the number of dynamic drops to 644, with no effect on stack usage. I should be writing a more dedicated drop unswitching pass. No performance measurements.
2017-02-28kill the code path for E0388Niko Matsakis-26/+8
This was specific to the old special-case handling of statics in borrowck.
2017-02-28remove `Option` from the `tables` fieldNiko Matsakis-7/+9