summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2022-01-05Combine drain_filter callsAaron Hill-4/+4
2022-01-05Use SsoHashSetAaron Hill-2/+2
2022-01-05Deduplicate projection sub-obligationsAaron Hill-0/+6
2021-11-24Add impl polarity to fieldsDeadbeef-26/+27
2021-11-24Allow more cases to match ~const Drop.Deadbeef-32/+48
2021-11-22Use `derive_default_enum` in the compilerJacob Pratt-10/+6
2021-11-21Simplify for loop desugarCameron Steffen-4/+3
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-9/+3
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-7/+19
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-3/+4
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-17Rollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebankMatthias Krüger-1/+2
Fix span for non-satisfied trivial trait bounds The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before. Now they only reference the obligation itself (`String: Copy`) Address #90869
2021-11-16Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkovYuki Okushi-38/+21
Fixes incorrect handling of TraitRefs when emitting suggestions. Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE. Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations. This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
2021-11-15refactor is_param_boundTaylor Yu-8/+2
2021-11-15check where clause before suggesting unsizedTaylor Yu-0/+19
2021-11-14Fix span for non-satisfied trivial trait boundsNilstrieb-1/+2
The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before. Now they only reference the obligation itself (`String: Copy`) Address #90869
2021-11-13Fix handling of substitutions and binders when deciding whether to suggest ↵Jakob Degen-38/+21
references When suggesting references, substitutions were being forgotten and some types were misused. This led to at least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to diagnostics changing, and tests have been adjusted.
2021-11-11Use `associated_item_def_ids` moreMatthew Jasper-7/+1
2021-11-11Auto merge of #90648 - matthewjasper:assoc-item-cleanup, r=cjgillotbors-11/+4
Assoc item cleanup This removes some fields from ObligationCauseCode Split out of #90639
2021-11-10don't inline `report_overlap_conflict`lcnr-0/+5
2021-11-10no overlap errors after failing the orphan checklcnr-2/+6
2021-11-09Auto merge of #90734 - matthiaskrgr:rollup-e1euotp, r=matthiaskrgrbors-3/+3
Rollup of 7 pull requests Successful merges: - #89561 (Type inference for inline consts) - #90035 (implement rfc-2528 type_changing-struct-update) - #90613 (Allow to run a specific rustdoc-js* test) - #90683 (Make `compiler-docs` only control the default instead of being a hard off-switch) - #90685 (x.py: remove fixme by deleting code) - #90701 (Record more artifact sizes during self-profiling.) - #90723 (Better document `Box` and `alloc::alloc::box_free` connection) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-3/+3
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-09Auto merge of #86041 - bstrie:unmagic-array-copy, r=jackh726bors-7/+4
Replace Copy/Clone compiler magic on arrays with library impls With const generics the compiler no longer needs to fake these impls.
2021-11-08impl Copy/Clone for arrays in std, not in compilerbstrie-7/+4
2021-11-08fmtDeadbeef-28/+8
2021-11-08Make select_* methods return Vec for TraitEngineDeadbeef-63/+81
2021-11-07more clippy fixesMatthias Krüger-13/+8
2021-11-07Remove some fields from `ObligationCauseCode`Matthew Jasper-11/+4
2021-11-07Rename functions reflect that inline const is also "typeck_child"Gary Guo-1/+1
2021-11-07Give inline const separate DefKindGary Guo-2/+2
2021-11-06use matches!() macro in more placesMatthias Krüger-4/+1
2021-11-06Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakisbors-12/+38
Normalize obligations for closure confirmation Based on #90017 Fixes #74261 Fixes #71955 Fixes #88459 r? `@nikomatsakis`
2021-11-05Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkovbors-1/+1
clippy::perf fixes
2021-11-04clippy::perf fixesMatthias Krüger-1/+1
2021-11-04Erase regions within `vtable_trait_first_method_offset`.Charles Lew-1/+4
2021-11-02Rollup merge of #90417 - lcnr:stabilize-relaxed-struct-unsizing, r=wesleywiserMatthias Krüger-40/+12
stabilize `relaxed_struct_unsize` closes #81793 the fcp is already complete.
2021-10-30stabilize `relaxed_struct_unsize`lcnr-40/+12
2021-10-28Reformat the changed line to make tidy happyIlya Yanok-2/+3
2021-10-28Use `is_global` in `candidate_should_be_dropped_in_favor_of`Ilya Yanok-1/+1
This manifistated in #90195 with compiler being unable to keep one candidate for a trait impl, if where is a global impl and more than one trait bound in the where clause. Before #87280 `candidate_should_be_dropped_in_favor_of` was using `TypeFoldable::is_global()` that was enough to discard the two `ParamCandidate`s. But #87280 changed it to use `TypeFoldable::is_known_global()` instead, which is pessimistic, so now the compiler drops the global impl instead (because `is_known_global` is not sure) and then can't decide between the two `ParamCandidate`s. Switching it to use `is_global` again solves the issue. Fixes #90195.
2021-10-25fix(rustc_typeck): report function argument errors on matching typeMichael Howell-0/+6
Fixes #90101
2021-10-25Rollup merge of #89889 - estebank:unmet-send-bound-on-foreign-future, r=tmandryMatthias Krüger-77/+70
Use the "nice E0277 errors"[1] for `!Send` `impl Future` from foreign crate Partly address #78543 by making the error quieter. We don't have access to the `typeck` tables from foreign crates, so we used to completely skip the new code when checking foreign crates. Now, we carry on and don't provide as nice output (we don't clarify *what* is making the `Future: !Send`), but at least we no longer emit a sea of derived obligations in the output. [1]: https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html r? `@tmandry`
2021-10-24Use the "nice E0277 errors"[1] for `!Send` `impl Future` from foreign crateEsteban Kuber-77/+70
Partly address #78543 by making the error quieter. We don't have access to the `typeck` tables from foreign crates, so we used to completely skip the new code when checking foreign crates. Now, we carry on and don't provide as nice output (we don't clarify *what* is making the `Future: !Send`), but at least we no longer emit a sea of derived obligations in the output. [1]: https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html
2021-10-24Point at overlapping impls when type annotations are neededEsteban Kuber-32/+189
2021-10-23Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakisbors-154/+265
Implement coherence checks for negative trait impls The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3). This feature is necessary to handle the following from impl on box. ```rust impl From<&str> for Box<dyn Error> { ... } ``` Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile. We would have this in `alloc`: ```rust impl From<&str> for Box<dyn Error> {} // A impl<E> From<E> for Box<dyn Error> where E: Error {} // B ``` and this in `core`: ```rust trait Error {} impl !Error for &str {} ``` r? `@nikomatsakis` This PR was built on top of `@yaahc` PR #85764. Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
2021-10-23Avoid code duplication by extracting checks into fnsSantiago Pastorino-11/+18
2021-10-22Hide negative coherence checks under negative_impls feature flagSantiago Pastorino-4/+5
2021-10-22Assemple trait alias candidates for negative polaritySantiago Pastorino-0/+1
This doesn't work properly yet, we would probably need to implement an `assembly_neg_candidates` and consider things like `T: !AB` as `T: !A` || `T: !B`
2021-10-22Add rustc_strict_coherence attribute and use it to check overlapSantiago Pastorino-2/+13
2021-10-22Add comment about the only way to prove NotImplemented hereSantiago Pastorino-0/+2
2021-10-22Fix filter_impls commentSantiago Pastorino-2/+2