about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2022-12-13Remove `hint` from help messageakida31-2/+2
2022-12-13Improve diagnostic when passing arg to closure and missing borrow.akida31-0/+73
This checks the number of references for the given and expected type and shows hints to the user if the numbers don't match.
2022-12-13Remove invalid case for mutable borrow suggestionDeep Majumder-0/+11
If we have a call such as `foo(&mut buf)` and after reference collapsing the type is inferred as `&T` where-as the required type is `&mut T`, don't suggest `foo(&mut mut buf)`. This is wrong syntactically and the issue lies elsewhere, not in the borrow. Fixes #105645
2022-12-13Use a label instead of a note for the drop site to create denser diagnosticsOli Scherer-10/+1
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-11/+10
available
2022-12-13Rollup merge of #105332 - estebank:iterator-chains, r=oli-obkMatthias Krüger-62/+420
Point out the type of associated types in every method call of iterator chains Partially address #105184 by pointing out the type of associated types in every method call of iterator chains: ``` note: the expression is of type `Map<std::slice::Iter<'_, {integer}>, [closure@src/test/ui/iterators/invalid-iterator-chain.rs:12:18: 12:21]>` --> src/test/ui/iterators/invalid-iterator-chain.rs:12:14 | 10 | vec![0, 1] | ---------- this expression has type `Vec<{integer}>` 11 | .iter() | ------ associated type `std::iter::Iterator::Item` is `&{integer}` here 12 | .map(|x| { x; }) | ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `()` here ``` We also reduce the number of impls we mention when any of the candidates is an "exact match". This benefits the output of cases with numerics greatly. Outstanding work would be to provide a structured suggestion for appropriate changes, like in this case detecting the spurious `;` in the closure.
2022-12-12Do not `skip_binder`sEsteban Küber-6/+9
2022-12-12Move logic to their own methodsEsteban Küber-362/+391
2022-12-11Point at method call when it is the source of the bound errorEsteban Küber-0/+10
2022-12-11Rollup merge of #105283 - compiler-errors:ty-var-in-hir-wfcheck, r=nagisaMatthias Krüger-0/+1
Don't call `diagnostic_hir_wf_check` query if we have infer variables Fixes #105260
2022-12-11Use `with_forced_trimmed_paths`Esteban Küber-13/+28
2022-12-11Only point at methods that might be relevantEsteban Küber-2/+17
2022-12-11Add label to method chains where assoc type remains the sameEsteban Küber-0/+5
2022-12-11Remove mention of "assoc type" in label as it is already in the `note` messageEsteban Küber-7/+5
2022-12-11Account for method call chains split across multiple bindingsEsteban Küber-0/+12
2022-12-11Mention only assoc types changesEsteban Küber-27/+69
2022-12-11Provide associated type information in method chainsMichael Goulet-34/+263
When encountering an unmet obligation that affects a method chain, like in iterator chains where one of the links has the wrong associated type, we point at every method call and mention their evaluated associated type at that point to give context to the user of where expectations diverged from the code as written. ``` note: the expression is of type `Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/invalid-iterator-chain.rs:12:18: 12:21]>` --> $DIR/invalid-iterator-chain.rs:12:14 | LL | vec![0, 1] | ---------- this expression has type `Vec<{integer}>` LL | .iter() | ------ associated type `std::iter::Iterator::Item` is `&{integer}` here LL | .map(|x| { x; }) | ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `()` here ```
2022-12-10Introduce `with_forced_trimmed_paths`Esteban Küber-3/+4
2022-12-09Introduce `Span::is_visible`Esteban Küber-3/+3
2022-12-09Rollup merge of #105443 - compiler-errors:move-more, r=oli-obkMatthias Krüger-517/+398
Move some queries and methods Each commit's title should be self-explanatory. Motivated to break up some large, general files and move queries into leaf crates.
2022-12-08Move codegen_select_candidate to a rustc_traitsMichael Goulet-90/+0
2022-12-08Move vtable methods into its own moduleMichael Goulet-378/+398
2022-12-08Move has_structural_eq_impls provider to rustc_ty_utilsMichael Goulet-49/+0
2022-12-07Rollup merge of #105400 - BoxyUwU:braced_param_evaluatability, r=oli-obkMatthias Krüger-1/+1
normalize before handling simple checks for evaluatability of `ty::Const` `{{{{{{{ N }}}}}}}` is desugared into a `ConstKind::Unevaluated` for an anonymous `const` item so when calling `is_const_evaluatable` on it we skip the `ConstKind::Param(_) => Ok(())` arm which is incorrect.
2022-12-06normalize before matching on `ConstKind`Boxy-1/+1
2022-12-06typo :(Boxy-1/+1
2022-12-06Rollup merge of #105342 - compiler-errors:note_cause_code-takes-predicate, ↵Matthias Krüger-50/+81
r=fee1-dead Make `note_obligation_cause_code` take a `impl ToPredicate` for predicate The only usecase that wasn't `impl ToPredicate` was noting overflow errors while revealing opaque types, which passed in an `Obligation<'tcx, Ty<'tcx>>`... Since this only happens in a `RevealAll` environment, which is after typeck (and probably primarily within `normalize_erasing_regions`) we're unlikely to display anything useful while noting this code, evidenced by the lack of UI test changes.
2022-12-06Rollup merge of #105340 - estebank:ice-ice-baby, r=compiler-errorsMatthias Krüger-1/+1
Avoid ICE by accounting for missing type Fix #105330
2022-12-06Rollup merge of #105339 - BoxyUwU:wf_ct_kind_expr, r=TaKO8KiMatthias Krüger-20/+57
support `ConstKind::Expr` in `is_const_evaluatable` and `WfPredicates::compute` Fixes #105205 Currently we haven't implemented a way to evaluate `ConstKind::Expr(Expr::Binop(Add, 1, 2))` so I just left that with a `FIXME` and a `delay_span_bug` since I have no idea how to do that and it would make this a much larger (and more complicated) PR :P
2022-12-05Avoid ICE by accounting for missing typeEsteban Küber-1/+1
Fix #105330
2022-12-06Rollup merge of #105338 - estebank:other-impls, r=compiler-errorsYuki Okushi-2/+10
Tweak "the following other types implement trait" When *any* of the suggested impls is an exact match, *only* show the exact matches. This is particularly relevant for integer types. r? `@compiler-errors`
2022-12-06Rollup merge of #105324 - compiler-errors:gat-where-clause-binding-obl, ↵Yuki Okushi-5/+25
r=jackh726 Point at GAT `where` clause when an obligation is unsatisfied Slightly helps with #105306
2022-12-06Avoid noting cause code (which is usually misc, b/c codegen) for opaque type ↵Michael Goulet-49/+80
reveal overflow
2022-12-06drive-by: Default param for ToPredicateMichael Goulet-1/+1
2022-12-05support `Expr` in `is_const_evaluatable` and `compute`Boxy-20/+57
2022-12-05Tweak "the following other types implement trait"Esteban Küber-2/+10
When *any* of the suggested impls is an exact match, *only* show the exact matches. This is particularly relevant for integer types. fix fmt
2022-12-05Point at GAT where clause when unsatisfiedMichael Goulet-5/+25
2022-12-05Don't call diagnostic_hir_wf_check query if we have infer variablesMichael Goulet-0/+1
2022-12-05Auto merge of #104920 - compiler-errors:avoid-infcx-build, r=jackh726bors-10/+6
Avoid some `InferCtxt::build` calls Either because we're inside of an `InferCtxt` already, or because we're not in a place where we'd ever see inference vars. r? types
2022-12-04Auto merge of #105094 - Swatinem:generator-not-future, r=compiler-errorsbors-1/+5
Make sure async constructs do not `impl Generator` Async lowering turns async functions and blocks into generators internally. Though these special kinds of generators should not `impl Generator` themselves. The other way around, normal generators should not `impl Future`. This was discovered in https://github.com/rust-lang/rust/pull/105082#issuecomment-1332210907 and is a regression from https://github.com/rust-lang/rust/pull/104321. r? `@compiler-errors`
2022-12-04Avoid InferCtxt::build in report_similar_impl_candidatesMichael Goulet-10/+6
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-20/+15
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-03Rollup merge of #105181 - bhbs:skip-note, r=estebankYuki Okushi-15/+20
Don't add a note for implementing a trait if its inner type is erroneous Fix #105138
2022-12-03Rollup merge of #104903 - ↵Yuki Okushi-21/+48
spastorino:consolidate-normalize-in-report_projection_error, r=lcnr Use ocx.normalize in report_projection_error r? `@lcnr` cc `@compiler-errors`
2022-12-03Don't add a note for implementing a trait if its inner type is erroneousbhbs-15/+20
2022-12-02Define values and err as non mutableSantiago Pastorino-7/+7
2022-12-02Use ocx.normalize in report_projection_errorSantiago Pastorino-17/+44
2022-12-01Document normalization methods on AtMichael Goulet-38/+20
2022-11-30Make sure async constructs do not `impl Generator`Arpad Borsos-1/+5
Async lowering turns async functions and blocks into generators internally. Though these special kinds of generators should not `impl Generator` themselves. The other way around, normal generators should not `impl Future`.
2022-11-30Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorinobors-73/+51
Some initial normalization method changes 1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`) 2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`) 3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize` 4. Remove some unused other normalization fns in `Inherited` and `FnCtxt` Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic. Stacked on top of #104835 for convenience. r? types