about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
2021-12-16Remove some noise from opaque type errors around associated typesOli Scherer-0/+14
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+1
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-13Remove `in_band_lifetimes` from `rustc_infer`LegionMammal978-49/+48
This crate actually had a typo `'ctx` in one of its functions: ```diff -pub fn same_type_modulo_infer(a: Ty<'tcx>, b: Ty<'ctx>) -> bool { +pub fn same_type_modulo_infer<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool { ```
2021-12-13Instead of checking for exact bounds, try to prove themJack Huey-2/+2
2021-12-12Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"Deadbeef-24/+16
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.
2021-12-11Auto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obkbors-3/+36
Tweak assoc type obligation spans * Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors r? `@oli-obk` This is a(n uncontroversial) subset of #85799.
2021-12-11Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgrbors-49/+130
Rollup of 6 pull requests Successful merges: - #83174 (Suggest using a temporary variable to fix borrowck errors) - #89734 (Point at capture points for non-`'static` reference crossing a `yield` point) - #90270 (Make `Borrow` and `BorrowMut` impls `const`) - #90741 (Const `Option::cloned`) - #91548 (Add spin_loop hint for RISC-V architecture) - #91721 (Minor improvements to `future::join!`'s implementation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-11Rollup merge of #91640 - cjgillot:in-band-collect, r=oli-obkMatthias Krüger-24/+18
Simplify collection of in-band lifetimes Split from https://github.com/rust-lang/rust/pull/91403 r? ````@oli-obk````
2021-12-11Tweak assoc type obligation spansEsteban Kuber-3/+36
* Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors
2021-12-10fmtEsteban Kuber-16/+17
2021-12-10review commentEsteban Kuber-3/+3
2021-12-10Remove field from `ErrorValue`Esteban Kuber-12/+12
2021-12-10Review commentsEsteban Kuber-10/+12
2021-12-10Tweak wordingEsteban Kuber-3/+3
2021-12-10Use a more accurate `Span` for `'static` obligation from return typeEsteban Kuber-5/+23
2021-12-10Point at return type when it introduces `'static` obligationEsteban Kuber-0/+20
2021-12-10Add filtering based on involved required lifetimeEsteban Kuber-17/+20
More accurate filtering still needed.
2021-12-10review commentsEsteban Kuber-21/+29
* take diagnostic logic out of happy-path * sort/dedup once * add more comments
2021-12-10Clean up visual output logicEsteban Kuber-71/+21
2021-12-10Point at capture points for non-`'static` reference crossing a `yield` pointEsteban Kuber-16/+95
``` error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-72312.rs:10:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... ... LL | require_static(async move { | -------------- ...is required to live as long as `'static` here... LL | &self; | ----- ...and is captured here | note: `'static` lifetime requirement introduced by this trait bound --> $DIR/issue-72312.rs:2:22 | LL | fn require_static<T: 'static>(val: T) -> T { | ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0759`. ``` Fix #72312.
2021-12-08Rollup merge of #90709 - estebank:erase-known-type-params, r=nagisaMatthias Krüger-6/+131
Only shown relevant type params in E0283 label When we point at a binding to suggest giving it a type, erase all the type for ADTs that have been resolved, leaving only the ones that could not be inferred. For small shallow types this is not a problem, but for big nested types with lots of params, this can otherwise cause a lot of unnecessary visual output.
2021-12-07Simplify match.Camille GILLOT-25/+15
2021-12-07Store impl_trait_fn inside OpaqueTyOrigin.Camille GILLOT-10/+14
2021-12-07Rollup merge of #91493 - oli-obk:cleanup, r=michaelwoeristerMatthias Krüger-5/+8
Remove a dead code path. It is neither documented nor can I see any way it could ever be reached. Also, no tests fail when turning that arm into an ICE
2021-12-07Add test with multiple type params failing inferenceEsteban Kuber-3/+1
2021-12-07Refer to const params as "const params" and not "type params"Esteban Kuber-36/+46
2021-12-07Refer to uninferred `const` params by their name, instead of `{ _: _ }`Esteban Kuber-6/+25
When the value of a const param isn't inferred, replace it with the param name from the definition.
2021-12-07Only shown relevant type params in E0283 labelEsteban Kuber-1/+99
When we point at a binding to suggest giving it a type, erase all the type for ADTs that have been resolved, leaving only the ones that could not be inferred. For small shallow types this is not a problem, but for big nested types with lots of params, this can otherwise cause a lot of unnecessary visual output.
2021-12-05Rollup merge of #90023 - b-naber:postpone_const_eval_infer_vars, r=nikomatsakisMatthias Krüger-30/+85
Postpone the evaluation of constant expressions that depend on inference variables Previously `delay_span_bug` calls were triggered once an inference variable was included in the substs of a constant that was to be evaluated. Some of these would merely have resulted in trait candidates being rejected, hence no real error was ever encountered, but the triggering of the `delay_span_bug` then caused an ICE in later stages of the compiler due to no error ever occurring. We now postpone the evaluation of these constants, so any trait obligation fulfillment will simply stall on this constant and the existing type inference machinery of the compiler handles any type errors if present. Fixes https://github.com/rust-lang/rust/issues/89320 Fixes https://github.com/rust-lang/rust/issues/89146 Fixes https://github.com/rust-lang/rust/issues/87964 Fixes https://github.com/rust-lang/rust/issues/87470 Fixes https://github.com/rust-lang/rust/issues/83288 Fixes https://github.com/rust-lang/rust/issues/83249 Fixes https://github.com/rust-lang/rust/issues/90654 I want to thank `@BoxyUwU` for cooperating on this and for providing some help. r? `@lcnr` maybe?
2021-12-03Remove a code path that is neither documented nor can I see the reason it ↵Oli Scherer-5/+8
existed. Also, no tests fail when turning that arm into an ICE
2021-12-03Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"Santiago Pastorino-16/+24
This reverts commit 18bb8c61a975fff6424cda831ace5b0404277145, reversing changes made to d9baa361902b172be716f96619b909f340802dea.
2021-12-02Rename TypeFolderFallible to FallibleTypeFolderAlan Egerton-4/+4
2021-12-02Reduce boilerplate around infallible foldersAlan Egerton-207/+196
2021-12-02Auto merge of #91354 - fee1-dead:const_env, r=spastorinobors-24/+16
Cleanup: Eliminate ConstnessAnd This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature. We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`. This is a continuation of https://github.com/rust-lang/rust/pull/90274. r? `@oli-obk` cc `@spastorino` `@ecstatic-morse`
2021-11-29Reformat everythingDeadbeef-4/+2
2021-11-29Completely remove ConstnessAndOli Scherer-2/+2
2021-11-29Avoid storing the ImplPolarity and Constness next to a TraitRef and use ↵Oli Scherer-4/+4
TraitPredicate instead
2021-11-29Use the constness from the param env instead of having a separate dimension ↵Oli Scherer-18/+12
for it This breaks a ~const test that will be fixed in a follow up commit of this PR
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-1/+1
2021-11-28Auto merge of #91230 - eggyal:fallible-type-fold, r=jackh726bors-216/+220
Make `TypeFolder::fold_*` return `Result` Implements rust-lang/compiler-team#432. Initially this is just a rebase of `@LeSeulArtichaut's` work in #85469 (abandoned; see https://github.com/rust-lang/rust/pull/85485#issuecomment-908781112). At that time, it caused a regression in performance that required some further exploration... with this rebased PR bors can hopefully report some perf analysis from which we can investigate further (if the regression is indeed still present). r? `@jackh726` cc `@nikomatsakis`
2021-11-26Use `TypeFolder::Error` for `FullTypeResolver` and `QueryNormalizer`LeSeulArtichaut-21/+7
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26Unwrap the results of type foldersLeSeulArtichaut-107/+112
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26Adapt `TypeFolder` implementors to return a `Result`LeSeulArtichaut-88/+101
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26Make `TypeFoldable` implementors short-circuit on errorLeSeulArtichaut-5/+5
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-25Visit `param_env` field in Obligation's `TypeFoldable` implAaron Hill-1/+2
This oversight appears to have gone unnoticed for a long time without causing issues, but it should still be fixed.
2021-11-22Use `derive_default_enum` in the compilerJacob Pratt-7/+3
2021-11-21Simplify for loop desugarCameron Steffen-6/+18
2021-11-21Auto merge of #91104 - matthiaskrgr:rollup-duk33o1, r=matthiaskrgrbors-6/+18
Rollup of 4 pull requests Successful merges: - #91008 (Adds IEEE 754-2019 minimun and maximum functions for f32/f64) - #91070 (Make `LLVMRustGetOrInsertGlobal` always return a `GlobalVariable`) - #91097 (Add spaces in opaque `impl Trait` with more than one trait) - #91098 (Don't suggest certain fixups (`.field`, `.await`, etc) when reporting errors while matching on arrays ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-21Auto merge of #89580 - estebank:trait-bounds-are-tricky, r=nagisabors-5/+16
Point at source of trait bound obligations in more places 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*`). We no longer point at associated items (`ImplObligation`), as they didn't add any user actionable information, they just added noise. Address part of #89418.