about summary refs log tree commit diff
path: root/src/librustc_infer
AgeCommit message (Collapse)AuthorLines
2020-07-06Auto merge of #73978 - Mark-Simulacrum:shrink-paramenv, r=nnethercotebors-3/+3
Shrink ParamEnv to 16 bytes r? @nnethercote x.py check passes but I haven't tried running perf or tests
2020-07-05Shrink ParamEnv to 16 bytesMark Rousskov-3/+3
2020-07-05expected found `&T` -> `T`Bastian Kauschke-4/+4
2020-07-02Remove `TypeckTables::empty(None)` and make hir_owner non-optional.Eduard-Mihai Burtescu-2/+2
2020-06-30change `skip_binder` to use T by valueBastian Kauschke-13/+12
2020-06-30stop taking references in RelateBastian Kauschke-72/+72
2020-06-28Auto merge of #72437 - ecstatic-morse:stabilize-const-if-match, r=oli-obkbors-1/+1
Stabilize `#![feature(const_if_match)]` Quoting from the [stabilization report](https://github.com/rust-lang/rust/issues/49146#issuecomment-616301045): > `if` and `match` expressions as well as the short-circuiting logic operators `&&` and `||` will become legal in all [const contexts](https://doc.rust-lang.org/reference/const_eval.html#const-context). A const context is any of the following: > > - The initializer of a `const`, `static`, `static mut` or enum discriminant. > - The body of a `const fn`. > - The value of a const generic (nightly only). > - The length of an array type (`[u8; 3]`) or an array repeat expression (`[0u8; 3]`). > > Furthermore, the short-circuiting logic operators will no longer be lowered to their bitwise equivalents (`&` and `|` respectively) in `const` and `static` initializers (see #57175). As a result, `let` bindings can be used alongside short-circuiting logic in those initializers. Resolves #49146. Ideally, we would resolve :whale: #66753 before this lands on stable, so it might be worth pushing this back a release. Also, this means we should get the process started for #52000, otherwise people will have no recourse except recursion for iterative `const fn`. r? @oli-obk
2020-06-28Remove `const_if_match` feature gate from librariesDylan MacKenzie-1/+1
2020-06-28Rollup merge of #73833 - bjorn3:remove_gcx_enter_local, r=matthewjasperManish Goregaokar-19/+17
Remove GlobalCtxt::enter_local
2020-06-28Remove GlobalCtxt::enter_localbjorn3-19/+17
2020-06-27Rollup merge of #73796 - lcnr:LocalDefId, r=matthewjasperManish Goregaokar-226/+223
replace more `DefId`s with `LocalDefId` part of https://github.com/rust-lang/rust/issues/70853
2020-06-27more LocalDefId cleanupBastian Kauschke-227/+223
2020-06-27more LocalDefId in ty::contextBastian Kauschke-1/+2
2020-06-26Explain move errors that occur due to method calls involving `self`Aaron Hill-1/+1
This is a re-attempt of #72389 (which was reverted in #73594) Instead of using `ExpnKind::Desugaring` to represent operators, this PR checks the lang item directly.
2020-06-23Rollup merge of #73630 - estebank:fn-item-e0308, r=davidtwcoManish Goregaokar-1/+1
Provide context on E0308 involving fn items Fix #73487.
2020-06-23Rollup merge of #73496 - estebank:opaque-missing-lts-in-fn-3, r=nikomatsakisManish Goregaokar-34/+62
Account for multiple impl/dyn Trait in return type when suggesting `'_` Make `impl` and `dyn` Trait lifetime suggestions a bit more resilient. Follow up to #72804. r? @nikomatsakis
2020-06-23Rollup merge of #72493 - nikomatsakis:move-leak-check, r=matthewjasperManish Goregaokar-132/+435
move leak-check to during coherence, candidate eval Implementation of MCP https://github.com/rust-lang/compiler-team/issues/295. I'd like to do a crater run on this. Note to @rust-lang/lang: This PR is a breaking change (bugfix). It causes tests like the following to go from a future-compatibility warning #56105 to a hard error: ```rust trait Trait {} impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {} impl Trait for for<'c> fn(&'c u32, &'c u32) {} // now rejected, used to warn ``` I am not aware of any instances of this code in the wild, but that is why we are doing a crater run. The reason for this change is that those two types are, in fact, the same type, and hence the two impls are overlapping. There will still be impls that trigger #56105 after this lands, however -- I hope that we will eventually just accept those impls without warning, for the most part. One example of such an impl is this pattern, which is used by wasm-bindgen and other crates as well: ```rust trait Trait {} impl<T> Trait for fn(&T) { } impl<T> Trait for fn(T) { } // still accepted, but warns ```
2020-06-22review commentsEsteban Küber-3/+4
2020-06-22Provide context on E0308 involving fn itemsEsteban Küber-1/+1
2020-06-22fix subtle bug in NLL type checkerNiko Matsakis-1/+7
The bug was revealed by the behavior of the old-lub-glb-hr-noteq1.rs test. The old-lub-glb-hr-noteq2 test shows the current 'order dependent' behavior of coercions around higher-ranked functions, at least when running with `-Zborrowck=mir`. Also, run compare-mode=nll.
2020-06-22remove `leak_check` from the outlives predicate evaluationsNiko Matsakis-5/+2
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-1/+1
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-22move leak-check to during coherence, candidate evalNiko Matsakis-4/+15
In particular, it no longer occurs during the subtyping check. This is important for enabling lazy normalization, because the subtyping check will be producing sub-obligations that could affect its results. Consider an example like for<'a> fn(<&'a as Mirror>::Item) = fn(&'b u8) where `<T as Mirror>::Item = T` for all `T`. We will wish to produce a new subobligation like <'!1 as Mirror>::Item = &'b u8 This will, after being solved, ultimately yield a constraint that `'!1 = 'b` which will fail. But with the leak-check being performed on subtyping, there is no opportunity to normalize `<'!1 as Mirror>::Item` (unless we invoke that normalization directly from within subtyping, and I would prefer that subtyping and unification are distinct operations rather than part of the trait solving stack). The reason to keep the leak check during coherence and trait evaluation is partly for backwards compatibility. The coherence change permits impls for `fn(T)` and `fn(&T)` to co-exist, and the trait evaluation change means that we can distinguish those two cases without ambiguity errors. It also avoids recreating #57639, where we were incorrectly choosing a where clause that would have failed the leak check over the impl which succeeds. The other reason to keep the leak check in those places is that I think it is actually close to the model we want. To the point, I think the trait solver ought to have the job of "breaking down" higher-ranked region obligation like ``!1: '2` into into region obligations that operate on things in the root universe, at which point they should be handed off to polonius. The leak check isn't *really* doing that -- these obligations are still handed to the region solver to process -- but if/when we do adopt that model, the decision to pass/fail would be happening in roughly this part of the code. This change had somewhat more side-effects than I anticipated. It seems like there are cases where the leak-check was not being enforced during method proving and trait selection. I haven't quite tracked this down but I think it ought to be documented, so that we know what precisely we are committing to. One surprising test was `issue-30786.rs`. The behavior there seems a bit "fishy" to me, but the problem is not related to the leak check change as far as I can tell, but more to do with the closure signature inference code and perhaps the associated type projection, which together seem to be conspiring to produce an unexpected signature. Nonetheless, it is an example of where changing the leak-check can have some unexpected consequences: we're now failing to resolve a method earlier than we were, which suggests we might change some method resolutions that would have been ambiguous to be successful. TODO: * figure out remainig test failures * add new coherence tests for the patterns we ARE disallowing
2020-06-22rewrite leak check to be based on universesNiko Matsakis-125/+414
In the new leak check, instead of getting a list of placeholders to track, we look for any placeholder that is part of a universe which was created during the snapshot. We are looking for the following error patterns: * P1: P2, where P1 != P2 * P1: R, where R is in some universe that cannot name P1 This new leak check is more precise than before, in that it accepts this patterns: * R: P1, even if R cannot name P1, because R = 'static is a valid sol'n * R: P1, R: P2, as above Note that this leak check, when running during subtyping, is less efficient than before in some sense because it is going to check and re-check all the universes created since the snapshot. We're going to move when the leak check runs to try and correct that.
2020-06-22Revert "modify leak-check to track only outgoing edges from placeholders"Niko Matsakis-17/+4
This reverts commit 2e01db4b396a1e161f7a73933fff34bc9421dba0.
2020-06-22modify leak-check to track only outgoing edges from placeholdersNiko Matsakis-4/+17
Also, update the affected tests. This seems strictly better but it is actually more permissive than I initially intended. In particular it accepts this ``` forall<'a, 'b> { exists<'intersection> { 'a: 'intersection, 'b: 'intersection, } } ``` and I'm not sure I want to accept that. It implies that we have a `'empty` in the new universe intoduced by the `forall`.
2020-06-20Auto merge of #73563 - Manishearth:rollup-oowgwwm, r=Manishearthbors-15/+8
Rollup of 9 pull requests Successful merges: - #72456 (Try to suggest dereferences on trait selection failed) - #72788 (Projection bound validation) - #72790 (core/time: Add Duration methods for zero) - #73227 (Allow multiple `asm!` options groups and report an error on duplicate options) - #73287 (lint: normalize projections using opaque types) - #73291 (Pre-compute `LocalDefId` <-> `HirId` mappings and remove `NodeId` <-> `HirId` conversion APIs) - #73378 (Remove use of specialization from librustc_arena) - #73411 (Update bootstrap to rustc 1.45.0-beta.2 (1dc0f6d8e 2020-06-15)) - #73443 (ci: allow gating GHA on everything but macOS) Failed merges: r? @ghost
2020-06-20Move bounds on associated types to the typeMatthew Jasper-15/+8
Given `trait X { type U; }` the bound `<Self as X>::U` now lives on the type, rather than the trait. This is feature gated on `feature(generic_associated_types)` for now until more testing can be done. The also enabled type-generic associated types since we no longer need "implies bounds".
2020-06-20remove `pop_placeholders`Bastian Kauschke-80/+3
2020-06-20int -> i32Bastian Kauschke-4/+4
2020-06-20skol -> placeholderBastian Kauschke-2/+2
2020-06-19Rollup merge of #73452 - matthewjasper:auto-rec, r=nikomatsakisManish Goregaokar-32/+33
Unify region variables when projecting associated types This is required to avoid cycles when evaluating auto trait predicates. Notably, this is required to be able add Chalk types to `CtxtInterners` for `cfg(parallel_compiler)`. r? @nikomatsakis
2020-06-19Rollup merge of #73027 - doctorn:issue-72690, r=estebankManish Goregaokar-2/+15
Make `need_type_info_err` more conservative Makes sure arg patterns we are going to suggest on are actually contained within the span of the obligation that caused the inference error (credit to @lcnr for suggesting this fix). There's a subtle trade-off regarding the handling of local patterns which I've left a comment about. Resolves #72690
2020-06-19Account for multiple impl/dyn Trait in return type when suggesting `'_`Esteban Küber-32/+59
2020-06-18Rollup merge of #72804 - estebank:opaque-missing-lts-in-fn-2, r=nikomatsakisManish Goregaokar-35/+158
Further tweak lifetime errors involving `dyn Trait` and `impl Trait` in return position * Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static` instead of `Trait + 'static + '_` * When `'static` is explicit, also suggest constraining argument with it * Reduce verbosity of suggestion message and mention lifetime in label * Tweak output for overlapping required/captured spans * Give these errors an error code Follow up to #72543. r? @nikomatsakis
2020-06-18Rollup merge of #70551 - mark-i-m:ty-err-2, r=varkorManish Goregaokar-11/+12
Make all uses of ty::Error delay a span bug r? @eddyb A second attempt at https://github.com/rust-lang/rust/pull/70245 resolves https://github.com/rust-lang/rust/issues/70866
2020-06-18Add helper method for reusing an existing interned regionMatthew Jasper-8/+2
2020-06-17Unify region variables when projecting associated typesmatthewjasper-32/+39
This is required to avoid cycles when evaluating auto trait predicates.
2020-06-16Auto merge of #72962 - lcnr:ObligationCause-lrc, r=ecstatic-morsebors-5/+7
store `ObligationCause` on the heap Stores `ObligationCause` on the heap using an `Rc`. This PR trades off some transient memory allocations to reduce the size of–and thus the number of instructions required to memcpy–a few widely used data structures in trait solving.
2020-06-15make all uses of ty::Error or ConstKind::Error delay a span bugmark-11/+12
2020-06-15fix rebaseEsteban Küber-1/+1
2020-06-15Change E0758 to E0759 to avoid conflict with #72912Esteban Küber-1/+1
2020-06-15small tweaksEsteban Küber-6/+14
2020-06-15Use note for requirement source spanEsteban Küber-8/+2
2020-06-15review comments: wordingEsteban Küber-27/+31
2020-06-15Tweak wording and add error codeEsteban Küber-16/+19
2020-06-15Tweak output for overlapping required/captured spansEsteban Küber-6/+4
2020-06-15Move overlapping span to a noteEsteban Küber-1/+30
2020-06-15Reduce verbosity of suggestion message and mention lifetime in labelEsteban Küber-40/+47
2020-06-15When `'static` is explicit, suggest constraining argument with itEsteban Küber-43/+75