about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-01-26Improve selection errors for `~const` trait boundsDeadbeef-144/+174
2022-01-25Rollup merge of #93175 - spastorino:negative-traits-coherence-new, ↵Matthias Krüger-61/+201
r=nikomatsakis Implement stable overlap check considering negative traits This PR implement the new disjointness rules for overlap check described in https://rust-lang.github.io/negative-impls-initiative/explainer/coherence-check.html#new-disjointness-rules r? ``@nikomatsakis``
2022-01-25Rollup merge of #93064 - Aaron1011:provisional-dep-node, r=michaelwoeristerMatthias Krüger-12/+51
Properly track `DepNode`s in trait evaluation provisional cache 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-24Auto merge of #93028 - compiler-errors:const_drop_bounds, r=fee1-deadbors-136/+194
Check `const Drop` impls considering `~const` Bounds This PR adds logic to trait selection to account for `~const` bounds in custom `impl const Drop` for types, elaborates the `const Drop` check in `rustc_const_eval` to check those bounds, and steals some drop linting fixes from #92922, thanks `@DrMeepster.` r? `@fee1-dead` `@oli-obk` <sup>(edit: guess I can't request review from two people, lol)</sup> since each of you wrote and reviewed #88558, respectively. Since the logic here is more complicated than what existed, it's possible that this is a perf regression. But it works correctly with tests, and that makes me happy. Fixes #92881
2022-01-23FIXME include regions tooSantiago Pastorino-1/+4
2022-01-23Rename strict_check to negative_impl_existsSantiago Pastorino-4/+8
2022-01-23Document OverlapModeSantiago Pastorino-0/+5
2022-01-22Restructure the code leveraging in abilities more than modesSantiago Pastorino-51/+47
2022-01-21Remove intermediate function doesn't make more senseSantiago Pastorino-28/+11
2022-01-21Make strict_disjoint use explicit_disjointSantiago Pastorino-9/+12
2022-01-21Do not pass OverlapMode down, just create a closure to properly set the ↵Santiago Pastorino-16/+33
filtering
2022-01-21Implement stable with negative coherence modeSantiago Pastorino-4/+95
2022-01-21Add overlap modeSantiago Pastorino-9/+27
2022-01-21Extract stable_disjoint fnSantiago Pastorino-21/+41
2022-01-21Rollup merge of #93046 - est31:let_else, r=davidtwcoMatthias Krüger-28/+27
Use let_else in even more places Followup of #89933, #91018, #91481.
2022-01-21Move auxiliary fns out of overlap_with_probeSantiago Pastorino-19/+19
2022-01-21Use impl1 and impl2 instead of a and b prefixesSantiago Pastorino-16/+16
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-1/+4
2022-01-19Foreign types are trivially dropMichael Goulet-2/+3
- Also rename a trivial_const_drop to match style of other functions in the util module. - Also add a test for `const Drop` that doesn't depend on a `~const` bound. - Also comment a bit why we remove the const bound during dropck impl check.
2022-01-19Store a `Symbol` instead of an `Ident` in `AssocItem`Aaron Hill-13/+20
This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
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.