about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2024-03-14rebaselcnr-1/+1
2024-03-14eagerly instantiate binders to avoid relying on `sub`lcnr-22/+48
2024-03-14Consolidate WF for aliasesMichael Goulet-20/+8
2024-03-14Rollup merge of #122238 - fee1-dead-contrib:builtin-impl-next-solver-dox, r=lcnrMatthias Krüger-0/+18
Document some builtin impls in the next solver This does not cover all builtin impls, but ones that I were able to go over within a cycle. r? `@lcnr` Let me know if the place isn't correct for these, or if you'd like me to change how the impls are presented ^^
2024-03-14move impl documentation to their actual locationsDeadbeef-33/+12
2024-03-14Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`Guillaume Gomez-1/+1
2024-03-13Rollup merge of #122438 - jswrenn:check-referent-size, r=compiler-errorsMatthias Krüger-0/+7
Safe Transmute: Require that source referent is smaller than destination `BikeshedIntrinsicFrom` currently models transmute-via-union; i.e., it attempts to provide a `where` bound for this function: ```rust pub unsafe fn transmute_via_union<Src, Dst>(src: Src) -> Dst { use core::mem::*; #[repr(C)] union Transmute<T, U> { src: ManuallyDrop<T>, dst: ManuallyDrop<U>, } let transmute = Transmute { src: ManuallyDrop::new(src) }; // SAFETY: The caller must guarantee that the transmutation is safe. let dst = transmute.dst; ManuallyDrop::into_inner(dst) } ``` A quirk of this model is that it admits padding extensions in value-to-value transmutation: The destination type can be bigger than the source type, so long as the excess consists of uninitialized bytes. However, this isn't permissible for reference-to-reference transmutations (introduced in #110662) — extra referent bytes cannot come from thin air. This PR patches our analysis for reference-to-reference transmutations to require that the destination referent is no larger than the source referent. r? `@compiler-errors`
2024-03-13safe transmute: require that src referent is smaller than dstJack Wrenn-0/+7
The source referent absolutely must be smaller than the destination referent of a ref-to-ref transmute; the excess bytes referenced cannot arise from thin air, even if those bytes are uninitialized.
2024-03-13Rollup merge of #122360 - veera-sivarajan:bugfix-121941, r=compiler-errorsMatthias Krüger-0/+7
Don't Create `ParamCandidate` When Obligation Contains Errors Fixes #121941 I'm not sure if I understand this correctly but this bug was caused by an error type incorrectly matching against `ParamCandidate`. This was introduced by the changes made in #72621 (figured using cargo-bisect-rustc). This PR fixes it by skipping `ParamCandidate` generation when an error type is involved. Also, this is similar to #73005 but addresses `ParamCandidate` instead of `ImplCandidate`.
2024-03-12Don't Create `ParamCandidate` When Obligation Contains ErrorsVeera-0/+7
Fixes #121941
2024-03-12Fix discriminant_kind copy paste from the pointee trait caseDaria Sukhonina-2/+3
2024-03-12Rollup merge of #122319 - ↵Matthias Krüger-1/+3
compiler-errors:next-solver-normalizing-self-constrains-args, r=lcnr Don't ICE when non-self part of trait goal is constrained in new solver Self-explanatory. See test for example when this can happen.
2024-03-11Don't ICE when non-self part of trait goal is constrained in new solverMichael Goulet-1/+3
2024-03-11Eliminate `DefiningAnchor::Error`, it is indistinguishable from ↵Oli Scherer-5/+2
`DefiningAnchor::Bind` with an empty list
2024-03-11Make `DefiningAnchor::Bind` only store the opaque types that may be ↵Oli Scherer-13/+6
constrained, instead of the current infcx root item. This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely
2024-03-11Auto merge of #122132 - nnethercote:diag-renaming3, r=nnethercotebors-6/+6
Diagnostic renaming 3 A sequel to https://github.com/rust-lang/rust/pull/121780. r? `@davidtwco`
2024-03-11Rename `AddToDiagnostic` as `Subdiagnostic`.Nicholas Nethercote-4/+4
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-4/+4
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-10fix metadata for dyn-star in new solverLukas Markeffsky-2/+3
2024-03-09Document some builtin impls in the next solverDeadbeef-0/+39
2024-03-09Auto merge of #122150 - ShoyuVanilla:replace-typewalker, r=lcnrbors-300/+301
Replace `TypeWalker` usage with `TypeVisitor` in `wf.rs` Resolves #121693
2024-03-08Stabilize associated type boundsMichael Goulet-3/+2
2024-03-08diagnostics: suggest `Clone` bounds when noop `clone()`Michael Howell-10/+50
2024-03-08Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkovMatthias Krüger-14/+13
Use `ControlFlow` in visitors. Follow up to #121256 This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
2024-03-08Replace `TypeWalker` usage with `TypeVisitor`Shoyu Vanilla-300/+301
2024-03-07Rollup merge of #122123 - compiler-errors:object-trait-alias-bounds, r=oli-obkGuillaume Gomez-1/+1
Don't require specifying unrelated assoc types when trait alias is in `dyn` type Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in `conv_object_ty_poly_trait_ref`. **NOTE**: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines. r? oli-obk or please feel free to reassign. Fixes #122118
2024-03-07Rollup merge of #122043 - Y-Nak:move-early-binder, r=lcnrGuillaume Gomez-22/+21
Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader` Resolves #121852 This PR 1. Moves `EarlyBinder` to `TraitRef` inside `ImplTraitHeader`, 2. Changes visibility of `coherence::builtin::check_trait` to `pub(super)` from `pub` as it seems not being re-exported from the `coherence` module.
2024-03-07Rollup merge of #121863 - lukas-code:silence-mismatched-super-projections, ↵Guillaume Gomez-66/+110
r=lcnr silence mismatched types errors for implied projections Currently, if a trait bound is not satisfied, then we suppress any errors for the trait's supertraits not being satisfied, but still report errors for super projections not being satisfied. For example: ```rust trait Super { type Assoc; } trait Sub: Super<Assoc = ()> {} ``` Before this PR, if `T: Sub` is not satisfied, then errors for `T: Super` are suppressed, but errors for `<T as Super>::Assoc == ()` are still shown. This PR makes it so that errors about super projections not being satisfied are also suppressed. The errors are only suppressed if the span of the trait obligation matches the span of the super predicate obligation to avoid silencing error that are not related. This PR removes some differences between the spans of supertraits and super projections to make the suppression work correctly. This PR fixes the majority of the diagnostics fallout when making `Thin` a supertrait of `Sized` (in a future PR). cc https://github.com/rust-lang/rust/pull/120354#issuecomment-1930585382 cc `@lcnr`
2024-03-07Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`Yoshitomo Nakanishi-22/+21
2024-03-07improve debug loggingLukas Markeffsky-14/+3
2024-03-07Don't require specifying unrelated assoc types when trait alias is in dyn typeMichael Goulet-1/+1
2024-03-06remove outdated fixme commentDeadbeef-1/+0
The `TraitPredicate` no longer has constness as we have desugared it to work with the type system through const generics instead.
2024-03-06Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgrbors-2/+0
Rollup of 9 pull requests Successful merges: - #121065 (Add basic i18n guidance for `Display`) - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check) - #121829 (Dummy tweaks (attempt 2)) - #121857 (Implement async closure signature deduction) - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now) - #122014 (Change some attributes to only_local.) - #122016 (will_wake tests fail on Miri and that is expected) - #122018 (only set noalias on Box with the global allocator) - #122028 (Remove some dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Use `ControlFlow` in HIR visitorsJason Newcomb-14/+13
2024-03-05Rollup merge of #121744 - oli-obk:eager_opaque_checks2, r=lcnrMatthias Krüger-2/+0
Stop using Bubble in coherence and instead emulate it with an intercrate check r? `````@compiler-errors````` This change is kinda funny, because all I've done is reimplement `Bubble` behaviour for coherence without using `Bubble` explicitly.
2024-03-05Convert `ProofTreeVisitor` to use `VisitorResult`Jason Newcomb-31/+28
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-45/+30
2024-03-05Stop using Bubble in coherence and instead emulate it with an intercrate checkOli Scherer-2/+0
2024-03-05Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obkMatthias Krüger-5/+54
Use root obligation on E0277 for some cases When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change), cc #121398 (doesn't fix the underlying issue).
2024-03-05Rename `SubdiagnosticMessageOp` as `SubdiagMessageOp`.Nicholas Nethercote-2/+2
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-2/+1
2024-03-04address review feedbackLukas Markeffsky-30/+56
2024-03-04suppress fulfillment errors for super projectionsLukas Markeffsky-31/+38
2024-03-04adjust obligation spans for super projectionsLukas Markeffsky-35/+57
2024-03-04Rollup merge of #121912 - fmease:diag-method-chains-gat, ↵Matthias Krüger-16/+14
r=compiler-errors,estebank Properly deal with GATs when looking for method chains to point at Fixes #121898. ~~While it prevents an ICE and the structured suggestion is correct, the method chain diagnostic notes are weird / useless / incorrect judging by a quick look. I guess I should improve that in this PR.~~ Sufficiently taken care of. r? estebank or compiler-errors (#105332, #105674).
2024-03-03Use `can_eq` instead of `Ty<'_> == Ty<'_>`Esteban Küber-4/+12
2024-03-03Use root obligation on E0277 for some casesEsteban Küber-5/+46
When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change).
2024-03-03Properly deal with GATs when looking for method chains to point atLeón Orell Valerian Liehr-16/+14
2024-03-02Rollup merge of #121895 - matthiaskrgr:devec, r=fee1-deadMatthias Krüger-1/+1
avoid collecting into vecs in some places
2024-03-02avoid collecting into vecs in some placesMatthias Krüger-1/+1