about summary refs log tree commit diff
path: root/src/librustc_traits/chalk_context
AgeCommit message (Collapse)AuthorLines
2020-03-02Remove chalk integrationCAD97-1804/+0
2020-02-16Make librustc_traits compile.Camille GILLOT-15/+15
2020-02-10Reduce the number of `RefCell`s in `InferCtxt`.Nicholas Nethercote-1/+3
`InferCtxt` contains six structures within `RefCell`s. Every time we create and dispose of (commit or rollback) a snapshot we have to `borrow_mut` each one of them. This commit moves the six structures under a single `RefCell`, which gives significant speed-ups by reducing the number of `borrow_mut` calls. To avoid runtime errors I had to reduce the lifetimes of dynamic borrows in a couple of places.
2020-02-06index ReEmpty by universeNiko Matsakis-3/+5
We now make `'empty` indexed by a universe index, resulting in a region lattice like this: ``` static ----------+-----...------+ (greatest) | | | early-bound and | | free regions | | | | | scope regions | | | | | empty(root) placeholder(U1) | | / | | / placeholder(Un) empty(U1) -- / | / ... / | / empty(Un) -------- (smallest) ``` Therefore, `exists<A> { forall<B> { B: A } }` is now unprovable, because A must be at least Empty(U1) and B is placeholder(U2), and hence the two regions are unrelated.
2020-01-16don't clone types that are copyMatthias Krüger-1/+1
found via clippy
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-5/+5
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-3/+3
2019-12-22Format the worldMark Rousskov-433/+263
2019-12-201. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.Mazdak Farrokhzad-2/+2
2. mir::Mutability -> ast::Mutability.
2019-11-18Retire BraceStructLiftImpl.Camille GILLOT-10/+2
2019-11-17Auto merge of #66384 - cjgillot:typefoldable, r=Zoxcbors-7/+2
Derive TypeFoldable using a proc-macro A new proc macro is added in librustc_macros. It is used to derive TypeFoldable inside librustc and librustc_traits. For now, the macro uses the `'tcx` lifetime implicitly, and does not allow for a more robust selection of the adequate lifetime. The Clone-based TypeFoldable implementations are not migrated. Closes #65674
2019-11-13Use TypeFoldable derive macro in librustc_traits.Camille GILLOT-7/+2
2019-11-12Rename in librustc_traits.Camille GILLOT-6/+4
2019-11-10Merge hir::Mutability into ast::Mutability.Camille GILLOT-2/+2
2019-10-21Rename `ConstValue::Infer(InferConst::Canonical(..))` to `ConstValue::Bound(..)`varkor-15/+6
2019-10-04Rollup merge of #64817 - csmoe:closure, r=nikomatsakisMazdak Farrokhzad-1/+4
Replace ClosureSubsts with SubstsRef Addresses https://github.com/rust-lang/rust/issues/42340 part 3 https://github.com/rust-lang/rust/pull/59312 might benefit from this clean up. r? @nikomatsakis
2019-10-03generate ClosureSubsts from SubstsRefcsmoe-1/+4
2019-10-01Improve HRTB error span when -Zno-leak-check is usedAaron Hill-1/+1
As described in #57374, NLL currently produces unhelpful higher-ranked trait bound (HRTB) errors when '-Zno-leak-check' is enabled. This PR tackles one half of this issue - making the error message point at the proper span. The error message itself is still the very generic "higher-ranked subtype error", but this can be improved in a follow-up PR. The root cause of the bad spans lies in how NLL attempts to compute the 'blamed' region, for which it will retrieve a span for. Consider the following code, which (correctly) does not compile: ```rust let my_val: u8 = 25; let a: &u8 = &my_val; let b = a; let c = b; let d: &'static u8 = c; ``` This will cause NLL to generate the following subtype constraints: d :< c c :< b b <: a Since normal Rust lifetimes are covariant, this results in the following region constraints (I'm using 'd to denote the lifetime of 'd', 'c to denote the lifetime of 'c, etc.): 'c: 'd 'b: 'c 'a: 'b From this, we can derive that 'a: 'd holds, which implies that 'a: 'static must hold. However, this is not the case, since 'a refers to 'my_val', which does not outlive the current function. When NLL attempts to infer regions for this code, it will see that the region 'a has grown 'too large' - it will be inferred to outlive 'static, despite the fact that is not declared as outliving 'static We can find the region responsible, 'd, by starting at the *end* of the 'constraint chain' we generated above. This works because for normal (non-higher-ranked) lifetimes, we generally build up a 'chain' of lifetime constraints *away* from the original variable/lifetime. That is, our original lifetime 'a is required to outlive progressively more regions. If it ends up living for too long, we can look at the 'end' of this chain to determine the 'most recent' usage that caused the lifetime to grow too large. However, this logic does not work correctly when higher-ranked trait bounds (HRTBs) come into play. This is because HRTBs have *contravariance* with respect to their bound regions. For example, this code snippet compiles: ```rust let a: for<'a> fn(&'a ()) = |_| {}; let b: fn(&'static ()) = a; ``` Here, we require that 'a' is a subtype of 'b'. Because of contravariance, we end up with the region constraint 'static: 'a, *not* 'a: 'static This means that our 'constraint chains' grow in the opposite direction of 'normal lifetime' constraint chains. As we introduce subtypes, our lifetime ends up being outlived by other lifetimes, rather than outliving other lifetimes. Therefore, starting at the end of the 'constraint chain' will cause us to 'blame' a lifetime close to the original definition of a variable, instead of close to where the bad lifetime constraint is introduced. This PR improves how we select the region to blame for 'too large' universal lifetimes, when bound lifetimes are involved. If the region we're checking is a 'placeholder' region (e.g. the region 'a' in for<'a>, or the implicit region in fn(&())), we start traversing the constraint chain from the beginning, rather than the end. There are two (maybe more) different ways we generate region constraints for NLL: requirements generated from trait queries, and requirements generated from MIR subtype constraints. While the former always use explicit placeholder regions, the latter is more tricky. In order to implement contravariance for HRTBs, TypeRelating replaces placeholder regions with existential regions. This requires us to keep track of whether or not an existential region was originally a placeholder region. When we look for a region to blame, we check if our starting region is either a placeholder region or is an existential region created from a placeholder region. If so, we start iterating from the beginning of the constraint chain, rather than the end.
2019-09-27Remove lift_to_globalMark Rousskov-1/+1
2019-09-26Rename `subst::Kind` to `subst::GenericArg`varkor-17/+17
2019-09-25Rename `sty` to `kind`varkor-8/+8
2019-08-05Fiddle param env through to `try_eval_bits` in most placesOliver Scherer-0/+5
2019-07-03Remove needless lifetimesJeremy Stucki-8/+8
2019-07-02introduce `QueryRegionConstraints` struct (no-op)Niko Matsakis-2/+3
2019-06-18rustc: remove 'x: 'y bounds (except from comments/strings).Eduard-Mihai Burtescu-3/+3
2019-06-14Run `rustfmt --file-lines ...` for changes from previous commits.Eduard-Mihai Burtescu-19/+8
2019-06-14Unify all uses of 'gcx and 'tcx.Eduard-Mihai Burtescu-88/+88
2019-06-12Run `rustfmt --file-lines ...` for changes from previous commits.Eduard-Mihai Burtescu-28/+16
2019-06-12rustc: replace `TyCtxt<'tcx, 'gcx, 'tcx>` with `TyCtxt<'gcx, 'tcx>`.Eduard-Mihai Burtescu-19/+19
2019-06-12Fix fallout from `deny(unused_lifetimes)`.Eduard-Mihai Burtescu-1/+1
2019-06-12rustc: replace `TyCtxt<'a, 'gcx, 'tcx>` with `TyCtxt<'tcx, 'gcx, 'tcx>`.Eduard-Mihai Burtescu-24/+24
2019-06-11rustc_traits: deny(unused_lifetimes).Eduard-Mihai Burtescu-1/+1
2019-05-28Rename `OpportunisticTypeResolver` to `OpportunisticVarResolver`varkor-4/+4
2019-05-01Create ShallowResolvervarkor-1/+1
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-05-01Fix rebase from LazyConst removalvarkor-9/+9
2019-05-01Implement TypeRelation::constsvarkor-2/+43
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-04-28Fix lint findings in librustc_traitsflip1995-25/+25
2019-04-27Rollup merge of #60292 - varkor:ty-tuple-substs, r=nikomatsakisMazdak Farrokhzad-10/+15
Replace the `&'tcx List<Ty<'tcx>>` in `TyKind::Tuple` with `SubstsRef<'tcx>` Part of the suggested refactoring for https://github.com/rust-lang/rust/issues/42340. As expected, this is a little messy, because there are many places that the components of tuples are expected to be types, rather than arbitrary kinds. However, it should open up the way for a refactoring of `TyS` itself. r? @nikomatsakis
2019-04-27Auto merge of #59540 - Zoxc:the-arena-2, r=michaelwoeristerbors-4/+3
Use arenas to avoid Lrc in queries #1 Based on https://github.com/rust-lang/rust/pull/59536.
2019-04-26Update handling of Tuplevarkor-10/+15
2019-04-25Update trait queriesJohn Kåre Alsaker-4/+3
2019-04-24Add builtin impls for int and float inference vars in chalkTyler Mandry-14/+19
2019-04-24chalkify: Add Copy/Clone builtinsTyler Mandry-21/+149
2019-03-20Add unsize impls for arraysscalexm-0/+88
2019-03-20Reorganize `chalk_context::program_clauses`scalexm-319/+343
2019-03-20Gather region constraints not coming from unificationscalexm-28/+33
2019-03-16Revert the `LazyConst` PROliver Scherer-8/+5
2019-03-05Handle const generics elsewherevarkor-1/+12
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-27Rename variadic to c_variadicDan Robertson-4/+4
Function signatures with the `variadic` member set are actually C-variadic functions. Make this a little more explicit by renaming the `variadic` boolean value, `c_variadic`.
2019-02-27rename Substs to InternalSubstscsmoe-2/+2
Change-Id: I3fa00e999a2ee4eb72db1fdf53a8633b49176a18