about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
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
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/+5
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-18Normalize obligations for closure confirmationjackh726-12/+38
2021-10-16Adopt let_else across the compilerest31-13/+5
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-15Move some outlives bounds things from rustc_trait_selection to rustc_typeckjackh726-97/+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
2021-10-08clippy::complexity fixesMatthias Krüger-3/+3
2021-10-08Auto merge of #89576 - tom7980:issue-89275-fix, r=estebankbors-13/+25
Prevent error reporting from outputting a recursion error if it finds an ambiguous trait impl during suggestions Closes #89275 This fixes the compiler reporting a recursion error during another already in progress error by trying to make a conversion method suggestion and encounters ambiguous trait implementations that can convert a the original type into a type that can then be recursively converted into itself via another method in the trait. Updated OverflowError struct to be an enum so I could differentiate between passes - it's no longer a ZST but I don't think that should be a problem as they only generate when there's an error in compiling code anyway
2021-10-07Auto merge of #89629 - GuillaumeGomez:rollup-s4r8me6, r=GuillaumeGomezbors-1/+79
Rollup of 7 pull requests Successful merges: - #89298 (Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers ) - #89461 (Add `deref_into_dyn_supertrait` lint.) - #89477 (Move items related to computing diffs to a separate file) - #89559 (RustWrapper: adapt for LLVM API change) - #89585 (Emit item no type error even if type inference fails) - #89596 (Make cfg imply doc(cfg)) - #89615 (Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-10-07Rollup merge of #89461 - crlf0710:dyn_upcasting_lint, r=nikomatsakisGuillaume Gomez-1/+79
Add `deref_into_dyn_supertrait` lint. Initial implementation of #89460. Resolves #89190. Maybe also worth a beta backport if necessary. r? `@nikomatsakis`
2021-10-06Introduce get_diagnostic_nameCameron Steffen-4/+4
2021-10-06Auto merge of #89323 - estebank:derive-binop, r=petrochenkovbors-1/+1
Consider unfulfilled obligations in binop errors When encountering a binop where the types would have been accepted, if all the predicates had been fulfilled, include information about the predicates and suggest appropriate `#[derive]`s if possible. Fix #84515.
2021-10-05Consider unfulfilled obligations in binop errorsEsteban Kuber-1/+1
When encountering a binop where the types would have been accepted, if all the predicates had been fulfilled, include information about the predicates and suggest appropriate `#[derive]`s if possible. Point at trait(s) that needs to be `impl`emented.
2021-10-05Issue 89275 fix and testTom Farmer-13/+25
Issue 89275 fix and test Fix librustdoc OverflowError usage rust tidy run Issue 89275 fix and test
2021-10-05Rollup merge of #89317 - JulianKnodt:precise_errors, r=BoxyUwUManish Goregaokar-43/+94
Move generic error message to separate branches This decomposes an error message in generic constants into more specific branches, for better readability. r? ``@lcnr``
2021-10-04Rollup merge of #89478 - zvavybir:master, r=jyn514Jubilee-2/+8
Fixed numerus of error message When there are redundant trait requirements and these are hidden, a message is generated by the following code snippet: `format!("{} redundant requirements hidden", count)` But if there is only a single hidden requirement, it will still print this message in plural instead of singular.
2021-10-04Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakisJubilee-1/+3
Correctly handle supertraits for min_specialization Supertraits of specialization markers could circumvent checks for min_specialization. Elaborating predicates prevents this. r? ````@nikomatsakis````
2021-10-04Move generic error message to separate brancheskadmin-43/+94
This decomposes an error message in generic constants into more specific branches, for better readability.