about summary refs log tree commit diff
path: root/src/librustc_borrowck
AgeCommit message (Collapse)AuthorLines
2017-02-28use `visit_all_bodies_in_krate` for borrowck instead of item-likesNiko Matsakis-59/+8
2017-02-28remove special-case code for statics and just use `borrowck_fn`Niko Matsakis-57/+4
Fixes #38520
2017-02-28make `borrowck_fn` and friends create `bccx`Niko Matsakis-39/+42
2017-02-28remove the borrowck statsNiko Matsakis-41/+0
2017-02-28rewrite `borrowck_fn` to only use the body-idNiko Matsakis-20/+16
2017-02-28move the `FreeRegionMap` into `TypeckTables`Niko Matsakis-32/+19
2017-02-25rustc_typeck: rework coherence to be almost completely on-demand.Eduard-Mihai Burtescu-6/+6
2017-02-25rustc_typeck: hook up collect and item/body check to on-demand.Eduard-Mihai Burtescu-3/+1
2017-02-25rustc: combine BareFnTy and ClosureTy into FnSig.Eduard-Mihai Burtescu-1/+2
2017-02-25rustc: move the actual values of enum discriminants into a map.Eduard-Mihai Burtescu-6/+5
2017-02-15[MIR] Make InlineAsm a StatementSimonas Kazlauskas-2/+5
Previously InlineAsm was an Rvalue, but its semantics doesn’t really match the semantics of an Rvalue – rather it behaves more like a Statement.
2017-02-10Inline open_drop_for_variant & clean matches::testSimonas Kazlauskas-43/+22
2017-02-10Add TerminatorKind::if_ convenience constructorSimonas Kazlauskas-7/+2
Constructs a TerminatorKind::SwitchInt for an equivalent conditional true-false branch.
2017-02-10Prefer switching on false for boolean switchesSimonas Kazlauskas-2/+2
This ends up not really mattering because we generate a plain conditional branch in LLVM either way.
2017-02-10Fix SwitchInt building in ElaborateDrops passSimonas Kazlauskas-6/+18
Previously it used to build a switch in a way that didn’t preserve the invariat of SwitchInt. Now it builds it in an optimal way too, where otherwise branch becomes all the branches which did not have partial variant drops.
2017-02-10Fix the IntTypeExt::to_ty() lifetime boundsSimonas Kazlauskas-2/+0
2017-02-10Only SwitchInt over integers, not all constsSimonas Kazlauskas-3/+3
Also use a Cow to avoid full Vec for all SwitchInts
2017-02-10SwitchInt over SwitchSimonas Kazlauskas-18/+35
This removes another special case of Switch by replacing it with the more general SwitchInt. While this is more clunky currently, there’s no reason we can’t make it nice (and efficient) to use.
2017-02-10If is now always a SwitchInt in MIRSimonas Kazlauskas-8/+6
2017-02-10Add Rvalue::Discriminant to retrieve discriminantSimonas Kazlauskas-0/+1
2017-02-03Add warning for () to ! switchAndrew Cann-2/+2
2017-01-30Implement Drop for BoxVadim Petrochenkov-3/+3
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-5/+5
2017-01-28rustc: always include elidable lifetimes in HIR types.Eduard-Mihai Burtescu-2/+2
2017-01-27Auto merge of #39139 - estebank:issue-38147, r=nikomatsakisbors-50/+96
Point to immutable arg/fields when trying to use as &mut Present the following output when trying to access an immutable borrow's field as mutable: ``` error[E0389]: cannot borrow data mutably in a `&` reference --> $DIR/issue-38147-1.rs:27:9 | 26 | fn f(&self) { | ----- use `&mut self` here to make mutable 27 | f.s.push('x'); | ^^^ assignment into an immutable reference ``` And the following when trying to access an immutable struct field as mutable: ``` error: cannot borrow immutable borrowed content `*self.s` as mutable --> $DIR/issue-38147-3.rs:17:9 | 12 | s: &'a String | ------------- use `&'a mut String` here to make mutable ...| 16 | fn f(&self) { | ----- use `&mut self` here to make mutable 17 | self.s.push('x'); | ^^^^^^ cannot borrow as mutable ``` Fixes #38147.
2017-01-26Point to immutable arg/fields when trying to use as &mutEsteban Küber-50/+96
Point to immutable borrow arguments and fields when trying to use them as mutable borrows. Add label to primary span on "cannot borrow as mutable" errors. Present the following output when trying to access an immutable borrow's field as mutable: ``` error[E0389]: cannot borrow data mutably in a `&` reference --> $DIR/issue-38147-1.rs:27:9 | 26 | fn f(&self) { | ----- use `&mut self` here to make mutable 27 | f.s.push('x'); | ^^^ assignment into an immutable reference ``` And the following when trying to access an immutable struct field as mutable: ``` error: cannot borrow immutable borrowed content `*self.s` as mutable --> $DIR/issue-38147-3.rs:17:9 | 12 | s: &'a String | ------------- use `&'a mut String` here to make mutable ...| 16 | fn f(&self) { | ----- use `&mut self` here to make mutable 17 | self.s.push('x'); | ^^^^^^ cannot borrow as mutable ```
2017-01-26Auto merge of #39066 - arielb1:lifetime-extension-test, r=nikomatsakisbors-2/+13
End temporary lifetimes being extended by `let X: &_` hints cc #39283 r? @nikomatsakis
2017-01-26rustc: don't call the HIR AST.Eduard-Mihai Burtescu-1/+1
2017-01-26rustc: rename TyCtxt's `map` field to `hir`.Eduard-Mihai Burtescu-28/+28
2017-01-25end temporary lifetimes being extended by `let X: &_` hintsAriel Ben-Yehuda-2/+13
Fixes #36082.
2017-01-08Auto merge of #38813 - eddyb:lazy-11, r=nikomatsakisbors-51/+34
[11/n] Separate ty::Tables into one per each body. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/38449) | [next]()) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well. If any motivation is unclear, please ask for additional PR description clarifications or code comments._ <hr> In order to track the results of type-checking and inference for incremental recompilation, they must be stored separately for each function or constant value, instead of lumped together. These side-`Tables` also have to be tracked by various passes, as they visit through bodies (all of which have `Tables`, even if closures share the ones from their parent functions). This is usually done by switching a `tables` field in an override of `visit_nested_body` before recursing through `visit_body`, to the relevant one and then restoring it - however, in many cases the nesting is unnecessary and creating the visitor for each body in the crate and then visiting that body, would be a much cleaner solution. To simplify handling of inlined HIR & its side-tables, their `NodeId` remapping and entries HIR map were fully stripped out, which means that `NodeId`s from inlined HIR must not be used where a local `NodeId` is expected. It might be possible to make the nodes (`Expr`, `Block`, `Pat`, etc.) that only show up within a `Body` have IDs that are scoped to that `Body`, which would also allow `Tables` to use `Vec`s. That last part also fixes #38790 which was accidentally introduced in a previous refactor.
2017-01-06rustc: keep track of tables everywhere as if they were per-body.Eduard-Mihai Burtescu-51/+34
2016-12-29Remove not(stage0) from deny(warnings)Alex Crichton-1/+1
Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2016-12-28Auto merge of #38449 - eddyb:lazy-10, r=nikomatsakisbors-72/+48
[10/n] Split constants and functions' arguments into disjoint bodies. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/38053) | [next]()) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well. If any motivation is unclear, please ask for additional PR description clarifications or code comments._ <hr> Finishes the signature-body split started in #37918, namely: * `trait` items are separated just like `impl` items were, for uniformity, closing #37712 * `static`s, `const`s (including associated ones), `enum` discriminants and array lengths get bodies * even the count in "repeat expressions", i.e. `n` in `[x; n]`, which fixes #24414 * arguments' patterns are moved to the bodies, with the types staying in `FnDecl` * `&self` now desugars to `self: &Self` instead of `self: &_` (similarly for other `self` forms) * `astconv`'s and metadata's (for rustdoc) informative uses are explicitly ignored for the purposes of the dep graph. this could be fixed in the future by hashing the exact information being extracted about the arguments as opposed to generating a dependency on *the whole body*
2016-12-28Auto merge of #38616 - pnkfelix:refactor-mir-dataflow-remove-ctxt, r=arielb1bors-135/+144
Refactor mir::dataflow: remove Ctxt associated type from BitDenotation trait Refactor mir::dataflow: remove Ctxt associated type from BitDenotation trait I no longer remember why I needed this (or thought I did). The way that the `BitDenotation` is passed around in all existing use cases (and planned future ones), the thing that were in the `Ctxt` can just be part of `Self` instead. (I think ariel had been pushing me to do this back when I first put in this infrastructure; it took me a while to see how much of pain the `Ctxt` was causing.)
2016-12-28rustc: simplify constant cross-crate loading and rustc_passes::consts.Eduard-Mihai Burtescu-2/+2
2016-12-28rustc: move function arguments into hir::Body.Eduard-Mihai Burtescu-28/+20
2016-12-28rustc: separate bodies for static/(associated)const and embedded constants.Eduard-Mihai Burtescu-45/+29
2016-12-28rustc: separate TraitItem from their parent Item, just like ImplItem.Eduard-Mihai Burtescu-1/+1
2016-12-26Refactor mir::dataflow: remove Ctxt associated type from BitDenotation trait.Felix S. Klock II-135/+144
I no longer remember why I needed this (or thought I did). The way that the `BitDenotation` is passed around in all existing use cases (and planned future ones), the thing that were in the `Ctxt` can just be part of `Self` instead. (I think ariel had been pushing me to do this back when I first put in this infrastructure; it took me a while to see how much of pain the `Ctxt` was causing.)
2016-12-25clear discriminant drop flag at the bottom of a ladderAriel Ben-Yehuda-38/+39
Fixes #38437.
2016-12-02Auto merge of #38053 - eddyb:lazy-9, r=nikomatsakisbors-3/+3
[9/n] rustc: move type information out of AdtDef and TraitDef. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37688) | [next]()) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well. If any motivation is unclear, please ask for additional PR description clarifications or code comments._ <hr> Both `AdtDef` and `TraitDef` contained type information (field types, generics and predicates) which was required to create them, preventing their use before that type information exists, or in the case of field types, *mutation* was required, leading to a variance-magicking implementation of `ivar`s. This PR takes that information out and the resulting cleaner setup could even eventually end up merged with HIR, because, just like `AssociatedItem` before it, there's no dependency on types anymore. (With one exception, variant discriminants should probably be moved into their own map later.)
2016-11-30Auto merge of #37800 - alexcrichton:new-bootstrap, r=eddybbors-2/+0
Update the bootstrap compiler Now that we've got a beta build, let's use it!
2016-11-30Update the bootstrap compilerAlex Crichton-2/+0
Now that we've got a beta build, let's use it!
2016-11-30Auto merge of #37954 - eddyb:rustdoc-2, r=alexcrichtonbors-2/+2
rustdoc: link to cross-crate sources directly. Fixes #37684 by implementing proper support for getting the `Span` of definitions across crates. In rustdoc this is used to generate direct links to the original source instead of fragile redirects. This functionality could be expanded further for making error reporting code more uniform and seamless across crates, although at the moment there is no actual source to print, only file/line/column information. Closes #37870 which is also "fixes" #37684 by throwing away the builtin macro docs from libcore. After this lands, #37727 could be reverted, although it doesn't matter much either way.
2016-11-30rustc: track the Span's of definitions across crates.Eduard-Mihai Burtescu-2/+2
2016-11-29Auto merge of #37965 - Mark-Simulacrum:trait-obj-to-exis-predicate, r=eddybbors-2/+1
Refactor TraitObject to Slice<ExistentialPredicate> For reference, the primary types changes in this PR are shown below. They may add in the understanding of what is discussed below, though they should not be required. We change `TraitObject` into a list of `ExistentialPredicate`s to allow for a couple of things: - Principal (ExistentialPredicate::Trait) is now optional. - Region bounds are moved out of `TraitObject` into `TyDynamic`. This permits wrapping only the `ExistentialPredicate` list in `Binder`. - `BuiltinBounds` and `BuiltinBound` are removed entirely from the codebase, to permit future non-constrained auto traits. These are replaced with `ExistentialPredicate::AutoTrait`, which only requires a `DefId`. For the time being, only `Send` and `Sync` are supported; this constraint can be lifted in a future pull request. - Binder-related logic is extracted from `ExistentialPredicate` into the parent (`Binder<Slice<EP>>`), so `PolyX`s are inside `TraitObject` are replaced with `X`. The code requires a sorting order for `ExistentialPredicate`s in the interned `Slice`. The sort order is asserted to be correct during interning, but the slices are not sorted at that point. 1. `ExistentialPredicate::Trait` are defined as always equal; **This may be wrong; should we be comparing them and sorting them in some way?** 1. `ExistentialPredicate::Projection`: Compared by `ExistentialProjection::sort_key`. 1. `ExistentialPredicate::AutoTrait`: Compared by `TraitDef.def_path_hash`. Construction of `ExistentialPredicate`s is conducted through `TyCtxt::mk_existential_predicates`, which interns a passed iterator as a `Slice`. There are no convenience functions to construct from a set of separate iterators; callers must pass an iterator chain. The lack of convenience functions is primarily due to few uses and the relative difficulty in defining a nice API due to optional parts and difficulty in recognizing which argument goes where. It is also true that the current situation isn't significantly better than 4 arguments to a constructor function; but the extra work is deemed unnecessary as of this time. ```rust // before this PR struct TraitObject<'tcx> { pub principal: PolyExistentialTraitRef<'tcx>, pub region_bound: &'tcx ty::Region, pub builtin_bounds: BuiltinBounds, pub projection_bounds: Vec<PolyExistentialProjection<'tcx>>, } // after pub enum ExistentialPredicate<'tcx> { // e.g. Iterator Trait(ExistentialTraitRef<'tcx>), // e.g. Iterator::Item = T Projection(ExistentialProjection<'tcx>), // e.g. Send AutoTrait(DefId), } ```
2016-11-29Auto merge of #37863 - mikhail-m1:mut_error, r=nikomatsakisbors-46/+83
add hint to fix error for immutable ref in arg fix #36412 part of #35233 r? @jonathandturner
2016-11-29rustc: simplify AdtDef by removing the field types and ty::ivar.Eduard-Mihai Burtescu-3/+3
2016-11-29revamp `Visitor` with a single method for controlling nested visitsNiko Matsakis-6/+6