about summary refs log tree commit diff
path: root/src/librustc_trait_selection/traits/project.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-1581/+0
2020-08-24hir: consistent use and naming of lang itemsDavid Wood-7/+5
This commit adjusts the naming of various lang items so that they are consistent and don't include prefixes containing the target or "LangItem". In addition, lang item variants are no longer exported from the `lang_items` module. Signed-off-by: David Wood <david@davidtw.co>
2020-08-20Don't immediately error for cycles during normalizationMatthew Jasper-29/+45
2020-08-12allow escaping bound vars when normalizing `ty::Opaque`Bastian Kauschke-5/+2
2020-07-27introduce PredicateAtomBastian Kauschke-13/+9
2020-07-27this might be unqualified, but at least it's now quantifiedBastian Kauschke-3/+3
2020-07-27split ignore_qualifiersBastian Kauschke-3/+3
2020-07-27reviewBastian Kauschke-2/+0
2020-07-27`PredicateKint` -> `PredicateKind`, the beginning of the endBastian Kauschke-23/+33
2020-07-15improve DiscriminantKind handlingBastian Kauschke-15/+5
This now reuses `fn discriminant_ty` in project, removing some code duplication. Doing so made me realize that we previously had a disagreement about the discriminant type of generators, with MIR using `u32` and codegen and trait selection using `i32`. We now always use `u32`.
2020-07-05Shrink ParamEnv to 16 bytesMark Rousskov-3/+3
2020-06-24Implement associated lang itemsAaron Hill-8/+7
Fixes #70718 This commit allows making associated items (e.g. associated functions and types) into lang items via the `#[lang]` attribute. This allows such items to be accessed directly, rather than by iterating over the parent item's associated items. I've added `FnOnce::Output` as a lang item, and updated one old usage to use the new lang item. The remaining uses can be updated separately.
2020-06-22remove leak-check from projectNiko Matsakis-2/+1
2020-06-22move leak-check to during coherence, candidate evalNiko Matsakis-5/+1
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-5/+7
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-20Auto merge of #73563 - Manishearth:rollup-oowgwwm, r=Manishearthbors-8/+13
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-20Consider fewer predicates for projection candidatesMatthew Jasper-8/+13
We now require that projection candidates are applicable with the idenitity substs of the trait, rather than allowing predicates that are only applicable for certain substs.
2020-06-20int -> i32Bastian Kauschke-1/+1
2020-06-19Rollup merge of #73452 - matthewjasper:auto-rec, r=nikomatsakisManish Goregaokar-1/+11
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-17Unify region variables when projecting associated typesmatthewjasper-1/+11
This is required to avoid cycles when evaluating auto trait predicates.
2020-06-15make all uses of ty::Error or ConstKind::Error delay a span bugmark-9/+11
2020-06-11Remove associated opaque typesMatthew Jasper-8/+3
They're unused now.
2020-06-05Rename traits::ImplSourceImpl to ImplSourceUserDefined.Ana-Maria Mihalache-5/+5
2020-06-05Rename traits::Vtable to ImplSource.Ana-Maria Mihalache-46/+49
2020-05-28standardize limit comparisons with `Limit` typeDavid Wood-5/+4
This commit introduces a `Limit` type which is used to ensure that all comparisons against limits within the compiler are consistent (which can result in ICEs if they aren't). Signed-off-by: David Wood <david@davidtw.co>
2020-05-23iterate List by valueBastian Kauschke-1/+1
2020-05-23take predicates by value instead of by referenceBastian Kauschke-2/+2
2020-05-22Use `OnceCell` instead of `Once`Dylan MacKenzie-3/+3
2020-05-21Rollup merge of #72055 - lcnr:predicate-kind, r=nikomatsakisRalf Jung-15/+16
Intern predicates Implements the first step of https://github.com/rust-lang/compiler-team/issues/285 Renames `ty::Predicate` to `ty::PredicateKind`, which is now interned. To ease the transition, `ty::Predicate` is now a struct containing a reference to `ty::PredicateKind`. r? @ghost
2020-05-20change `Predicate::kind` to return a referenceBastian Kauschke-7/+5
2020-05-20introduce newtype'd `Predicate<'tcx>`Bastian Kauschke-3/+3
2020-05-20make `to_predicate` take a `tcx` argumentNiko Matsakis-5/+6
2020-05-20rename `Predicate` to `PredicateKind`, introduce aliasBastian Kauschke-3/+5
2020-05-19auto impl`DiscriminantKind` for every typeBastian Kauschke-4/+81
2020-05-17Logically seperate lazy norm from `const_generics`Bastian Kauschke-1/+1
2020-05-17merge lazy_normalization_consts into const_genericsBastian Kauschke-1/+1
2020-05-17Put lazy normalization behind a feature gateBen Lewis-0/+9
2020-05-17Assume unevaluated consts are equal to the other consts and add ConstEquate ↵Ben Lewis-5/+0
obligation. This delays the need to evaluate consts eagerly and therefore gets around const eval query cycles.
2020-05-13use `require_lang_item` over `unwrap`.Bastian Kauschke-2/+3
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-2/+1
2020-05-07Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obkbors-1/+2
Prevent compiler stack overflow for deeply recursive code I was unable to write a test that 1. runs in under 1s 2. overflows on my machine without this patch The following reproduces the issue, but I don't think it's sensible to include a test that takes 30s to compile. We can now easily squash newly appearing overflows by the strategic insertion of calls to `ensure_sufficient_stack`. ```rust // compile-pass #![recursion_limit="1000000"] macro_rules! chain { (EE $e:expr) => {$e.sin()}; (RECURSE $i:ident $e:expr) => {chain!($i chain!($i chain!($i chain!($i $e))))}; (Z $e:expr) => {chain!(RECURSE EE $e)}; (Y $e:expr) => {chain!(RECURSE Z $e)}; (X $e:expr) => {chain!(RECURSE Y $e)}; (A $e:expr) => {chain!(RECURSE X $e)}; (B $e:expr) => {chain!(RECURSE A $e)}; (C $e:expr) => {chain!(RECURSE B $e)}; // causes overflow on x86_64 linux // less than 1 second until overflow on test machine // after overflow has been fixed, takes 30s to compile :/ (D $e:expr) => {chain!(RECURSE C $e)}; (E $e:expr) => {chain!(RECURSE D $e)}; (F $e:expr) => {chain!(RECURSE E $e)}; // more than 10 seconds (G $e:expr) => {chain!(RECURSE F $e)}; (H $e:expr) => {chain!(RECURSE G $e)}; (I $e:expr) => {chain!(RECURSE H $e)}; (J $e:expr) => {chain!(RECURSE I $e)}; (K $e:expr) => {chain!(RECURSE J $e)}; (L $e:expr) => {chain!(RECURSE L $e)}; } fn main() { let x = chain!(D 42.0_f32); } ``` fixes #55471 fixes #41884 fixes #40161 fixes #34844 fixes #32594 cc @alexcrichton @rust-lang/compiler I looked at all code that checks the recursion limit and inserted stack growth calls where appropriate.
2020-05-05Rebase and use ena 0.14Markus Westerlind-6/+6
2020-05-02Move ensure_sufficient_stack to data_structuresSimonas Kazlauskas-1/+1
We anticipate this to have uses in all sorts of crates and keeping it in `rustc_data_structures` enables access to it from more locations without necessarily pulling in the large `librustc` crate.
2020-05-02Prevent stack overflow for deeply recursive codeOliver Scherer-1/+2
2020-04-20Remove some `Vec` allocations in an effort to improve perfEsteban Küber-10/+6
2020-04-08Use `PredicateObligation`s instead of `Predicate`sEsteban Küber-2/+2
Keep more information about trait binding failures.
2020-04-03Minor follow-up after renaming librustc(_middle)Yuki Okushi-1/+1
2020-04-02add `STILL_FURTHER_SPECIALIZABLE` flagDavid Wood-1/+1
This commit adds a STILL_FURTHER_SPECIALIZABLE flag to `TypeFlags` which replaces `needs_infer` and `needs_subst` in `Instance::resolve` and `assemble_candidates_from_impls.` Signed-off-by: David Wood <david@davidtw.co>
2020-03-30Sync `Instance::resolve` with the projection codeJonas Schievink-1/+1
2020-03-30spec. graph: track defining and finalizing implsJonas Schievink-37/+11