about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2022-01-19remove `is_noop`lcnr-1/+1
2022-01-19skip some layers in const drop confirmationMichael Goulet-70/+91
2022-01-19never type is const DropMichael Goulet-3/+5
2022-01-18Properly track `DepNode`s in trait evaluation provisional cacheAaron Hill-12/+51
Fixes #92987 During evaluation of an auto trait predicate, we may encounter a cycle. This causes us to store the evaluation result in a special 'provisional cache;. If we later end up determining that the type can legitimately implement the auto trait despite the cycle, we remove the entry from the provisional cache, and insert it into the evaluation cache. Additionally, trait evaluation creates a special anonymous `DepNode`. All queries invoked during the predicate evaluation are added as outoging dependency edges from the `DepNode`. This `DepNode` is then store in the evaluation cache - if a different query ends up reading from the cache entry, it will also perform a read of the stored `DepNode`. As a result, the cached evaluation will still end up (transitively) incurring all of the same dependencies that it would if it actually performed the uncached evaluation (e.g. a call to `type_of` to determine constituent types). Previously, we did not correctly handle the interaction between the provisional cache and the created `DepNode`. Storing an evaluation result in the provisional cache would cause us to lose the `DepNode` created during the evaluation. If we later moved the entry from the provisional cache to the evaluation cache, we would use the `DepNode` associated with the evaluation that caused us to 'complete' the cycle, not the evaluatoon where we first discovered the cycle. As a result, future reads from the evaluation cache would miss some incremental compilation dependencies that would have otherwise been added if the evaluation was *not* cached. Under the right circumstances, this could lead to us trying to force a query with a no-longer-existing `DefPathHash`, since we were missing the (red) dependency edge that would have caused us to bail out before attempting forcing. This commit makes the provisional cache store the `DepNode` create during the provisional evaluation. When we move an entry from the provisional cache to the evaluation cache, we create a *new* `DepNode` that has dependencies going to *both* of the evaluation `DepNodes` we have available. This ensures that cached reads will incur all of the necessary dependency edges.
2022-01-18Rollup merge of #92780 - b-naber:postpone-const-eval-coherence, r=lcnrMatthias Krüger-8/+3
Directly use ConstValue for single literals in blocks Addresses the minimal repro in https://github.com/rust-lang/rust/issues/92186, but doesn't fix the underlying problem (which would be solved by solving the anon subst problem afaict). I do, however, think that it makes sense in general to treat single literals in anon blocks as const values directly, especially in light of the problem that the issue refers to (anon const evaluation being postponed until infer variables in substs can be resolved, which was introduced by https://github.com/rust-lang/rust/pull/90023), i.e. while we do get warnings for those unnecessary braces, we should try to avoid errors caused by those braces if possible.
2022-01-18Use let_else in even more placesest31-28/+27
2022-01-18Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obkbors-24/+33
allow eq constraints on associated constants Updates #70256 (cc `@varkor,` `@Centril)`
2022-01-18Check const Drop impls considering ConstIfConst boundsMichael Goulet-136/+170
2022-01-17Fix Inline MIR pass on a function with un-satisfiable boundsMichael Goulet-0/+2
2022-01-17Update with final commentskadmin-4/+4
2022-01-17Add term to ExistentialProjectionkadmin-6/+5
Also prevent ICE when adding a const in associated const equality.
2022-01-17Update w/ commentskadmin-2/+1
Removes uses of ty() where a method is implemented on TypeFoldable, and also directly formats a Term.
2022-01-17Update term for use in more placeskadmin-18/+28
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the future, but slightly worried it allows items which are consts which only accept types.
2022-01-17Use Term in ProjectionPredicatekadmin-13/+14
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
2022-01-17directly use ConstValue for single literals in blocksb-naber-8/+3
2022-01-17Auto merge of #90986 - camsteffen:nested-filter, r=cjgillotbors-18/+0
Replace `NestedVisitorMap` with generic `NestedFilter` This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting. With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted). One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-1/+1
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-18/+0
2022-01-16Rollup merge of #92710 - jackh726:issue-92280, r=nikomatsakisMatthias Krüger-1/+3
Include Projections when elaborating TypeOutlives Fixes #92280 In `Elaborator`, we elaborate that `Foo<<Bar as Baz>::Assoc>: 'a` -> `<Bar as Baz>::Assoc: 'a`. This is the same rule that would be applied to any other `Param`. If there are escaping vars, we continue to do nothing. r? `@nikomatsakis`
2022-01-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-59/+34
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-3/+4
2022-01-15Return a LocalDefId in get_parent_item.Camille GILLOT-2/+2
2022-01-15Rollup merge of #92191 - jackh726:issue-89352, r=nikomatsakisMatthias Krüger-19/+29
Prefer projection candidates instead of param_env candidates for Sized predicates Fixes #89352 Also includes some drive by logging and verbose printing changes that I found useful when debugging this, but I can remove this if needed. This is a little hacky - but imo no more than the rest of `candidate_should_be_dropped_in_favor_of`. Importantly, in a Chalk-like world, both candidates should be completely compatible. r? ```@nikomatsakis```
2022-01-15nyahggdshjjghsdfhgsfEllen-2/+0
2022-01-15unrevert # 88557Ellen-28/+5
2022-01-15attempt to re-add `ty::Unevaluated` visitor and friendsEllen-57/+41
2022-01-15initial revertEllen-93/+109
2022-01-13Rollup merge of #92006 - oli-obk:welcome_opaque_types_into_the_fold, ↵Matthias Krüger-19/+42
r=nikomatsakis Welcome opaque types into the fold r? ```@nikomatsakis``` because idk who else to bug on the type_op changes The commits have explanations in them. The TLDR is that * 5c4600227329a273c0c6c844e4a10ce650ead601 stops the "recurse and replace" scheme that replaces opaque types with their canonical inference var by just doing that ahead of time * bdeeb07bf6400622074f04ca2523dac1512ab662 does not affect anything on master afaict, but since opaque types generate obligations when instantiated, and lazy TAIT instantiates opaque types *everywhere*, we need to properly handle obligations here instead of just hoping no problematic obligations ever come up.
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-1/+1
2022-01-11Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, ↵bors-3/+3
r=Mark-Simulacrum Replace usages of vec![].into_iter with [].into_iter `[].into_iter` is idiomatic over `vec![].into_iter` because its simpler and faster (unless the vec is optimized away in which case it would be the same) So we should change all the implementation, documentation and tests to use it. I skipped: * `src/tools` - Those are copied in from upstream * `src/test/ui` - Hard to tell if `vec![].into_iter` was used intentionally or not here and not much benefit to changing it. * any case where `vec![].into_iter` was used because we specifically needed a `Vec::IntoIter<T>` * any case where it looked like we were intentionally using `vec![].into_iter` to test it.
2022-01-10Rollup merge of #92248 - compiler-errors:normalize-type-for-pointee, r=jackh726Matthias Krüger-6/+32
Normalize struct tail type when checking Pointee trait Let's go ahead and implement the FIXMEs by properly normalizing the struct-tail type when satisfying a Pointee obligation. This should fix the ICE when we try to calculate a layout depending on `<Ty as Pointee>::Metadata` later. Fixes #92128 Fixes #92577 Additionally, mark the obligation as ambiguous if there are any infer types in that struct-tail type. This has the effect of causing `<_ as Pointee>::Metadata` to be properly replaced with an infer variable ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/project.rs#L813)) and registered as an obligation... this turns out to be very important in unifying function parameters with formals that are assoc types. Fixes #91446
2022-01-10Elaborate param_env predicates when checking if type outlives involving ↵Jack Huey-1/+3
projection holds
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-3/+3
2022-01-07Add query to avoid name comparison in `leaf_def`Matthew Jasper-28/+34
2021-12-29Auto merge of #92244 - petrochenkov:alltraits, r=cjgillotbors-6/+6
rustc_metadata: Encode list of all crate's traits into metadata While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree. This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-28Rollup merge of #92076 - Aaron1011:rustdoc-auto-trait-ignore, r=cjgillotMatthias Krüger-1/+11
Ignore other `PredicateKind`s in rustdoc auto trait finder Fixes #92073 There's not really anything we can do with them, and they're causing ICEs. I'm not using a wildcard match, as we should check that any new `PredicateKind`s are handled properly by rustdoc.
2021-12-28rustc_metadata: Encode list of all crate's traits into metadataVadim Petrochenkov-6/+6
2021-12-25normalize env constness for nested obligationsDeadbeef-0/+33
2021-12-24Normalize struct tail type when checking Pointee traitMichael Goulet-6/+32
2021-12-22When obligation is a sized predicate, prefer projection or object candidates ↵Jack Huey-19/+29
instead of param_env candidates
2021-12-21remove obligation deduplcnr-22/+0
2021-12-21Fix bad caching of `~const Drop` boundsDeadbeef-3/+3
2021-12-20Auto merge of #92041 - Aaron1011:remove-speculative-evaluation, r=jackh726bors-18/+1
Remove 'speculative evaluation' of predicates Performing 'speculative evaluation' introduces caching bugs that cannot be fixed without invasive changes to projection. Hopefully, we can win back most of the performance lost by re-adding 'cache completion' Fixes #90662
2021-12-20Eliminate `ObligationCauseData`.Nicholas Nethercote-56/+54
This makes `Obligation` two words bigger, but avoids allocating a lot of the time. I previously tried this in #73983 and it didn't help much, but local timings look more promising now.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18Re-introduce concept of projection cache 'completion'Aaron Hill-3/+68
Instead of clearing out the cache entirely, we store the intermediate evaluation result into the cache entry. This accomplishes several things: * We avoid the performance hit associated with re-evaluating the sub-obligations * We avoid causing issues with incremental compilation, since the final evaluation result is always the same * We avoid affecting other uses of the same `InferCtxt` which might care about 'side effects' from processing the sub-obligations (e,g. region constraints). Only code that is specifically aware of the new 'complete' code is affected
2021-12-18Ignore other `PredicateKind`s in rustdoc auto trait finderAaron Hill-1/+11
Fixes #92073 There's not really anything we can do with them, and they're causing ICEs. I'm not using a wildcard match, as we should check that any new `PredicateKind`s are handled properly by rustdoc.
2021-12-17Remove 'speculative evaluation' of predicatesAaron Hill-18/+1
Performing 'speculative evaluation' introduces caching bugs that cannot be fixed without invasive changes to projection. Hopefully, we can win back most of the performance lost by re-adding 'cache completion' Fixes #90662
2021-12-16Prove obligations to termination instead of ignoring ambiguities.Oli Scherer-19/+42
Sometimes an obligation depends on a later one, so we can't just process them in order like it was done previously. This is not a problem in our test suite, but there may be ICEs out there and it will definitely be a problem with lazy TAIT.
2021-12-16Rollup merge of #91904 - ↵Matthias Krüger-50/+60
SylvanB:remove_in_band_lifetimes_rustc_trait_selection, r=petrochenkov Remove `in_band_lifetimes` from `rustc_trait_selection` Another one for #91867