about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
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-24Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726bors-32/+189
Point at overlapping impls when type annotations are needed Address https://github.com/rust-lang/rust/issues/89254.
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-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
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
2021-10-22Fix debug method nameSantiago Pastorino-1/+1
2021-10-22Move const filter to filter_implsSantiago Pastorino-35/+44
2021-10-22Document overlap check filterSantiago Pastorino-1/+21
2021-10-22Rollup merge of #90028 - tmiasko:structural-match-closure, r=spastorinoYuki Okushi-1/+5
Reject closures in patterns Fixes #90013.
2021-10-21Rollup merge of #88644 - eopb:abstractconst_leaf_subst, r=lcnrYuki Okushi-23/+22
`AbstractConst` private fields Calls `subst` in `AbstractConst::root` when `Node` is `Leaf`. r? ``@lcnr``
2021-10-20Fix allow_negative_impls logicSantiago Pastorino-2/+2
2021-10-20Add TraitObligation::polarity() for better encapsulationSantiago Pastorino-14/+8
2021-10-20Filter candidates when goal and impl polarity doesn't matchSantiago Pastorino-9/+27
2021-10-20Use predicate_must_hold_modulo_regionsSantiago Pastorino-1/+1
2021-10-20Filter out Negative impls on intercrate mode's ambiguous reasoningSantiago Pastorino-23/+30
2021-10-20Make EvaluationCache consider polarity as cache's keySantiago Pastorino-6/+24
2021-10-20Only assemble_candidates_from_impls for polarity NegativeSantiago Pastorino-58/+62
2021-10-20Consider negative polarity on trait selectionSantiago Pastorino-25/+23
2021-10-20Consider negative polarity on overlap checkSantiago Pastorino-16/+32
2021-10-20Add polarity to TraitPredicateSantiago Pastorino-0/+5
2021-10-20remove duplicate substEthan Brierley-1/+0
2021-10-19Address lcnr reviewEthan Brierley-3/+5
2021-10-19Reject closures in patternsTomasz Miąsko-1/+5
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-13/+6
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-18Auto merge of #89229 - oli-obk:i_love_inferctxt, r=jackh726bors-142/+15
Remove redundant member-constraint check impl trait will, for each lifetime in the hidden type, register a "member constraint" that says the lifetime must be equal or outlive one of the lifetimes of the impl trait. These member constraints will be solved by borrowck But, as you can see in the big red block of removed code, there was an ad-hoc check for member constraints happening at the site where they get registered. This check had some minor effects on diagnostics, but will fall down on its feet with my big type alias impl trait refactor. So we removed it and I pulled the removal out into a (hopefully) reviewable PR that works on master directly.
2021-10-18Normalize obligations for closure confirmationjackh726-12/+38
2021-10-18Member constraints already covered all of E0482 already, so that error never ↵Oli Scherer-39/+2
occurred anymore
2021-10-18Guarding a loop with a check that it never runs is uselessOli Scherer-8/+5
2021-10-16Adopt let_else across the compilerest31-13/+6
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-15Remove a now-unused structOli Scherer-13/+0
2021-10-15simplify constrain_opaque_typesNiko Matsakis-90/+16
2021-10-15Move some outlives bounds things from rustc_trait_selection to rustc_typeckjackh726-146/+1
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-14Rollup merge of #89823 - jackh726:project-overflow, r=oli-obkMatthias Krüger-1/+1
Switch order of terms to prevent overflow Fixes #89639 r? ``@pnkfelix``
2021-10-14Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obkbors-2/+6
Add `const_eval_select` intrinsic Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime. See https://github.com/rust-lang/const-eval/issues/7 for previous discussion. r? `@oli-obk.`
2021-10-12Switch order of terms to prevent overflowjackh726-1/+1
2021-10-12Add const_eval_select intrinsicDeadbeef-2/+6
2021-10-11Fix ICE 89775Gary Guo-1/+3
2021-10-10Fix spelling: Cannonical -> CanonicalJohn Kugelman-5/+5
2021-10-08Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514Guillaume Gomez-3/+3
clippy::complexity fixes