about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2021-01-16Remove PredicateKind::AtomJack Huey-37/+39
2021-01-15Make hitting the recursion limit in projection non-fatalMatthew Jasper-12/+3
This is relied on by wundergraph.
2021-01-15Rollup merge of #80944 - LingMan:map_or, r=nagisaYuki Okushi-1/+1
Use Option::map_or instead of `.map(..).unwrap_or(..)` ``@rustbot`` modify labels +C-cleanup +T-compiler
2021-01-15Rollup merge of #80254 - Aaron1011:rustdoc-auto-param-env, r=estebankYuki Okushi-6/+4
Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv` Fixes #80233 We already have logic in `evaluate_predicates` that tries to add unimplemented predicates to our `ParamEnv`. Trying to add a predicate that already holds can lead to errors later on, since projection will prefer trait candidates from the `ParamEnv` to predicates from an impl.
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-1/+1
2021-01-14Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasperbors-0/+6
Reintroduce hir::ExprKind::If Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications. The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome. - [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051) - [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d) - [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5) - [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691) - [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95) - [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-4/+6
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-4/+6
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-1/+1
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-10Note inference failures using `?` conversionWilliam Bain-11/+3
2021-01-07Reintroduce hir::ExprKind::IfCaio-0/+6
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-1/+1
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2021-01-02use hir::Place instead of Symbol in closure_kind_originRoxane-4/+4
2021-01-02reduce borrowing and (de)referencing around match patterns ↵Matthias Krüger-11/+11
(clippy::match_ref_pats)
2020-12-30remove unused return types such as empty Results or Options that would ↵Matthias Krüger-35/+21
always be Some(..) remove unused return type of dropck::check_drop_obligations() don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..) remove redundant return type of back::write::optimize() don't Option-wrap return type of compute_type_parameters() since we always return Some(..) don't return empty Result in assemble_generator_candidates() don't return empty Result in assemble_closure_candidates() don't return empty result in assemble_fn_pointer_candidates() don't return empty result in assemble_candidates_from_impls() don't return empty result in assemble_candidates_from_auto_impls() don't return emtpy result in assemble_candidates_for_trait_alias() don't return empty result in assemble_builtin_bound_candidates() don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait() remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..) remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-29Remove `compile-fail` test suiteVadim Petrochenkov-2/+2
2020-12-29Stabilize by-value `[T; N]` iterator `core::array::IntoIter`Simon Sapin-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/65798 This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135. This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method. `new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2020-12-28Rollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPCDylan DPC-24/+9
use matches!() macro in more places
2020-12-26Auto merge of #80246 - matthewjasper:projection-cycle-caching, r=Mark-Simulacrumbors-7/+20
Prevent caching normalization results with a cycle When normalizing a projection which results in a cycle, we would cache the result of `project_type` without the nested obligations (because they're not needed for inference). This would result in the nested obligations only being handled once in fulfill, which would avoid the cycle error. `get_paranoid_cache_value_obligation` used to add an obligation that resulted in a cycle in this case previously, but was removed by #73905. This PR makes the projection cache not cache the value of a projection if it was ever normalized in a cycle (except in a snapshot that's rolled back). Fixes #79714. r? `@nikomatsakis`
2020-12-24use matches!() macro in more placesMatthias Krüger-24/+9
2020-12-20Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv`Aaron Hill-6/+4
Fixes #80233 We already have logic in `evaluate_predicates` that tries to add unimplemented predicates to our `ParamEnv`. Trying to add a predicate that already holds can lead to errors later on, since projection will prefer trait candidates from the `ParamEnv` to predicates from an impl.
2020-12-20Prevent caching projections in the case of cyclesMatthew Jasper-6/+12
When normalizing a projection which results in a cycle, we would cache the result of `project_type` without the nested obligations (because they're not needed for inference). This would result in the nested obligations only being handled once in fulfill, which would avoid the cycle error. Fixes #79714, a regresion from #79305 caused by the removal of `get_paranoid_cache_value_obligation`.
2020-12-20Make recursion limit fatal in projectMatthew Jasper-1/+8
This avoid the hang/oom from #79714
2020-12-19Handle desugaring in impl trait bound suggestionWilliam Bain-12/+6
2020-12-19Auto merge of #80132 - matthewjasper:revert-eval-order, r=nikomatsakisbors-3/+3
Revert change to trait evaluation order This change breaks some code and doesn't appear to enable any new code. closes #79902 r? `@nikomatsakis`
2020-12-19More rebindsJack Huey-46/+47
2020-12-17Revert change to evaluation orderMatthew Jasper-3/+3
This change breaks some code and doesn't appear to enable any new code.
2020-12-17Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakisbors-44/+45
Move binder for dyn to each list item This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`. This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.` r? `@nikomatsakis`
2020-12-11use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns ↵Matthias Krüger-21/+20
that return () (clippy::option_map_unit_fn)
2020-12-11don't clone types that are copy (clippy::clone_on_copy)Matthias Krüger-2/+2
2020-12-11Move binder for dyn to each list itemJack Huey-44/+45
2020-12-05remove redundant clonesMatthias Krüger-1/+1
2020-12-03Auto merge of #79637 - spastorino:revert-trait-inheritance-self, ↵bors-2/+1
r=Mark-Simulacrum Revert "Auto merge of #79209 r? `@nikomatsakis` This has caused some issues (#79560) so better to revert and try to come up with a proper fix without rush.
2020-12-02Revert "Auto merge of #79209 - spastorino:trait-inheritance-self, ↵Santiago Pastorino-2/+1
r=nikomatsakis" This reverts commit 349b3b324dade7ca638091db93ba08bbc443c63d, reversing changes made to b776d1c3e3db8befabb123ebb1e46c3531eaed46.
2020-12-01Ignore trait implementations with negative polarity when suggesting trait ↵ThePuzzlemaker-1/+11
implementations in diagnostics
2020-11-29Remove extra call to upvar_tysAman Arora-10/+0
Fixes #78720
2020-11-29Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakisbors-1/+2
Allow Trait inheritance with cycles on associated types Fixes #35237 r? `@nikomatsakis` cc `@estebank`
2020-11-29Rollup merge of #79516 - jyn514:cleanup-trait-solver, r=Aaron1011Dylan DPC-2/+1
Remove unnecessary `mut` binding Found while fiddling around with https://github.com/rust-lang/rust/issues/77459.
2020-11-28Remove unnecessary `mut` bindingJoshua Nelson-2/+1
2020-11-27Change comments on types to doc-commentsJoshua Nelson-6/+6
2020-11-27Allow to self reference associated types in where clausesSantiago Pastorino-1/+2
2020-11-23Rollup merge of #79325 - LingMan:try_op, r=jonas-schievinkJonas Schievink-7/+3
Reduce boilerplate with the `?` operator `@rustbot` modify labels to +C-cleanup.
2020-11-23Reduce boilerplate with the `?` operatorLingMan-7/+3
2020-11-22winnow: drop non-const cand. in favor of constJonas Schievink-1/+9
2020-11-22Thread `Constness` through selectionJonas Schievink-15/+17
2020-11-19Move `rustc_ty` -> `rustc_ty_utils`LeSeulArtichaut-1/+1
2020-11-19Rollup merge of #79110 - estebank:issue-58964, r=oli-obkDylan DPC-6/+40
Remove redundant notes in E0275 Fix #58964.
2020-11-18review commentEsteban Küber-3/+1
2020-11-18Account for indirect cyclic requirementsEsteban Küber-1/+13
2020-11-18Remove redundant notes in E0275Esteban Küber-6/+30
Fix #58964.