about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-12-14Make report_projection_error more term agnosticMichael Goulet-18/+26
2022-12-14drive-by: Fix path spansMichael Goulet-1/+1
2022-12-14Use impl's def id when calculating type to specify UFCSMichael Goulet-4/+5
2022-12-14Fix a freshly detected wrong TraitRefOli Scherer-9/+5
2022-12-14Prevent the creation of `TraitRef` without dedicated methodsOli Scherer-5/+2
2022-12-14Ensure no one constructs `AliasTy`s themselvesOli Scherer-8/+8
2022-12-14Remove many more cases of `mk_substs_trait` that can now use the iterator ↵Oli Scherer-8/+3
scheme`
2022-12-14Rename to match similar methodsOli Scherer-4/+4
2022-12-14Guard `AliasTy` creation against passing the wrong number of substsOli Scherer-17/+9
2022-12-14skip if val has ecaping bound varsouz-a-13/+15
2022-12-14Rollup merge of #105595 - TaKO8Ki:suggest-dereferencing-receiver-argument, ↵Matthias Krüger-6/+28
r=compiler-errors Suggest dereferencing receiver arguments properly Fixes #105429
2022-12-14Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errorsMatthias Krüger-56/+23
Suggest `collect`ing into `Vec<_>` Fix #105510.
2022-12-14Clean up mut keyword checkDeep Majumder-7/+3
2022-12-14Auto merge of #104986 - compiler-errors:opaques, r=oli-obkbors-117/+101
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` Implements https://github.com/rust-lang/types-team/issues/79. This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so: ``` enum AliasKind { Projection, Opaque, } struct AliasTy<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, } ``` Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example: ```diff match ty.kind() { - ty::Opaque(..) => + ty::Alias(ty::Opaque, ..) => {} _ => {} } ``` This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically. r? `@ghost`
2022-12-13Auto merge of #105667 - matthiaskrgr:rollup-fexlc0b, r=matthiaskrgrbors-21/+11
Rollup of 7 pull requests Successful merges: - #105147 (Allow unsafe through inline const) - #105438 (Move some codegen-y methods from `rustc_hir_analysis::collect` -> `rustc_codegen_ssa`) - #105464 (Support #[track_caller] on async closures) - #105476 (Change pattern borrowing suggestions to be verbose and remove invalid suggestion) - #105500 (Make some diagnostics not depend on the source of what they reference being available) - #105628 (Small doc fixes) - #105659 (Don't require owned data in `MaybeStorageLive`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-14suggest dereferencing receiver arguments properlyTakayuki Maeda-6/+28
fix a stderr
2022-12-13Mention implementations that satisfy the traitEsteban Küber-2/+19
2022-12-13Remove unnecessary code and account for turbofish suggestionEsteban Küber-54/+4
Remove previously existing fallback that tried to give a good turbofish suggestion, `need_type_info` is already good enough. Special case `::<Vec<_>` suggestion for `Iterator::collect`.
2022-12-13Address nitsMichael Goulet-6/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-12-13Combine identical alias armsMichael Goulet-26/+13
2022-12-13Combine projection and opaque into aliasMichael Goulet-50/+59
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-26/+23
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-55/+49
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-12/+14
2022-12-13tidy: ignore filelengthakida31-0/+1
2022-12-13reduce to single suggestion for all argumentsakida31-13/+24
2022-12-13remove manual `fn_decl` extractionakida31-17/+3
2022-12-13change error messageakida31-2/+2
2022-12-13move changes to an extra functionakida31-66/+76
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