about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2024-01-24remove StructuralEq traitRalf Jung-1/+1
2024-01-24Deduplicate more sized errors on call exprsEsteban Küber-2/+10
Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-24Remove extra # from urlest31-1/+1
2024-01-23Rollup merge of #120270 - compiler-errors:randos, r=lcnrLeón Orell Valerian Liehr-35/+13
A bunch of random modifications r? oli-obk Kitchen sink of changes that I didn't know where to put elsewhere. Documentation tweaks mostly, but also removing some unreachable code and simplifying the pretty printing for closures/coroutines.
2024-01-23Rollup merge of #119805 - chenyukang:yukang-fix-119530, r=davidtwcoLeón Orell Valerian Liehr-0/+4
Suggest array::from_fn for array initialization Fixes #119530
2024-01-23Random type checker changesMichael Goulet-35/+13
2024-01-23Auto merge of #120017 - nnethercote:lint-api, r=oli-obkbors-9/+9
Fix naming in the lint API Methods for emit lints are named very inconsistently. This PR fixes that up. r? `@compiler-errors`
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-6/+6
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-2/+2
2024-01-23Rename `LintLevelsBuilder::struct_lint` as `LintLevelsBuilder::opt_span_lint`.Nicholas Nethercote-1/+1
2024-01-22Account for single `where` bound being removedEsteban Küber-3/+19
2024-01-22Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin"Oli Scherer-0/+51
This reverts commit 6d2b84b3ed7848fd91b8d6151d4451b3103ed816, reversing changes made to 73bc12199ea8c7651ed98b069c0dd6b0bb5fabcf.
2024-01-21Suggest arry::from_fn for array initializationyukang-0/+4
2024-01-20Rollup merge of #119613 - gavinleroy:expose-obligations, r=lcnrMatthias Krüger-60/+76
Expose Obligations created during type inference. This PR is a first pass at exposing the trait obligations generated and solved for during the type-check progress. Exposing these obligations allows for rustc plugins to use the public interface for proof trees (provided by the next gen trait solver). The changes proposed track *all* obligations during the type-check process, this is desirable to not only look at the trees of failed obligations, but also those of successfully proved obligations. This feature is placed behind an unstable compiler option `track-trait-obligations` which should be used together with the `next-solver` option. I should note that the main interface is the function `inspect_typeck` made public in `rustc_hir_typeck/src/lib.rs` which allows the caller to provide a callback granting access to the `FnCtxt`. r? `@lcnr`
2024-01-19Account for trailing comma in removal suggestionEsteban Küber-3/+26
2024-01-19Provide more context on recursive `impl` evaluation overflowEsteban Küber-45/+156
When an associated type `Self::Assoc` is part of a `where` clause, we end up unable to evaluate the requirement and emit a E0275. We now point at the associated type if specified in the `impl`. If so, we also suggest using that type instead of `Self::Assoc`. Otherwise, we explain that these are not allowed. ``` error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _` --> $DIR/impl-wf-cycle-1.rs:15:1 | LL | / impl<T: Grault> Grault for (T,) LL | | LL | | where LL | | Self::A: Baz, LL | | Self::B: Fiz, | |_________________^ LL | { LL | type A = (); | ------ associated type `<(T,) as Grault>::A` is specified here | note: required for `(T,)` to implement `Grault` --> $DIR/impl-wf-cycle-1.rs:15:17 | LL | impl<T: Grault> Grault for (T,) | ^^^^^^ ^^^^ ... LL | Self::A: Baz, | --- unsatisfied trait bound introduced here = note: 1 redundant requirement hidden = note: required for `(T,)` to implement `Grault` help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound | LL - Self::A: Baz, LL + , | ``` ``` error[E0275]: overflow evaluating the requirement `<T as B>::Type == <T as B>::Type` --> $DIR/impl-wf-cycle-3.rs:7:1 | LL | / impl<T> B for T LL | | where LL | | T: A<Self::Type>, | |_____________________^ LL | { LL | type Type = bool; | --------- associated type `<T as B>::Type` is specified here | note: required for `T` to implement `B` --> $DIR/impl-wf-cycle-3.rs:7:9 | LL | impl<T> B for T | ^ ^ LL | where LL | T: A<Self::Type>, | ------------- unsatisfied trait bound introduced here help: replace the associated type with the type specified in this `impl` | LL | T: A<bool>, | ~~~~ ``` ``` error[E0275]: overflow evaluating the requirement `<T as Filter>::ToMatch == <T as Filter>::ToMatch` --> $DIR/impl-wf-cycle-4.rs:5:1 | LL | / impl<T> Filter for T LL | | where LL | | T: Fn(Self::ToMatch), | |_________________________^ | note: required for `T` to implement `Filter` --> $DIR/impl-wf-cycle-4.rs:5:9 | LL | impl<T> Filter for T | ^^^^^^ ^ LL | where LL | T: Fn(Self::ToMatch), | ----------------- unsatisfied trait bound introduced here note: associated types for the current `impl` cannot be restricted in `where` clauses --> $DIR/impl-wf-cycle-4.rs:7:11 | LL | T: Fn(Self::ToMatch), | ^^^^^^^^^^^^^ ``` Fix #116925
2024-01-19Add trait obligation tracking to FulfillCtxt and expose FnCtxt in ↵Gavin Gray-60/+76
rustc_infer using callback. Pass each obligation to an fn callback with its respective inference context. This avoids needing to keep around copies of obligations or inference contexts. Specify usability of inspect_typeck in comment.
2024-01-19use implied bounds compat mode in MIR borrowcklcnr-2/+10
2024-01-17Don't use compat versions of implied bounds in ImpliedOutlivesBounds queryJack Huey-2/+2
2024-01-17Add -Zno-implied-bounds-compat option and use itJack Huey-3/+17
2024-01-17Correctly handle normalization in implied boundsAli MJ Al-Nasrawy-95/+191
Special-case Bevy dependents to not error
2024-01-17Auto merge of #120019 - lcnr:fn-wf, r=BoxyUwUbors-22/+49
fix fn/const items implied bounds and wf check (rebase) A rebase of #104098, see that PR for discussion. This is pretty much entirely the work of `@aliemjay.` I received his permission for this rebase. --- These are two distinct changes (edit: actually three, see below): 1. Wf-check all fn item args. This is a soundness fix. Fixes #104005 2. Use implied bounds from impl header in borrowck of associated functions/consts. This strictly accepts more code and helps to mitigate the impact of other breaking changes. Fixes #98852 Fixes #102611 The first is a breaking change and will likely have a big impact without the the second one. See the first commit for how it breaks libstd. Landing the second one without the first will allow more incorrect code to pass. For example an exploit of #104005 would be as simple as: ```rust use core::fmt::Display; trait ExtendLt<Witness> { fn extend(self) -> Box<dyn Display>; } impl<T: Display> ExtendLt<&'static T> for T { fn extend(self) -> Box<dyn Display> { Box::new(self) } } fn main() { let val = (&String::new()).extend(); println!("{val}"); } ``` The third change is to to check WF of user type annotations before normalizing them (fixes #104764, fixes #104763). It is mutually dependent on the second change above: an attempt to land it separately in #104746 caused several crater regressions that can all be mitigated by using the implied from the impl header. It is also necessary for the soundness of associated consts that use the implied bounds of impl header. See #104763 and how the third commit fixes the soundness issue in `tests/ui/wf/wf-associated-const.rs` that was introduces by the previous commit. r? types
2024-01-16Rollup merge of #119816 - oli-obk:tait_ice_unify_obligations, r=lcnrMatthias Krüger-1/+1
Define hidden types in confirmation fixes #111470 r? `@lcnr` or `@compiler-errors` explanation in the newly added test
2024-01-16try fast path for wf type opsAli MJ Al-Nasrawy-0/+17
2024-01-16wf-check type annotations before normalizationAli MJ Al-Nasrawy-22/+32
2024-01-15Rollup merge of #119963 - clubby789:spec-allow-internal-unstable, ↵Matthias Krüger-3/+23
r=compiler-errors Fix `allow_internal_unstable` for `(min_)specialization` Fixes #119950 Blocked on #119949 (comment doesn't make sense until that merges) I'd like to follow this up and look for more instances of not properly checking spans for features but I wanted to fix the motivating issue.
2024-01-15Rollup merge of #119897 - compiler-errors:fulfillment-errors, r=lcnrMatthias Krüger-59/+55
`OutputTypeParameterMismatch` -> `SignatureMismatch` I'm probably missing something that made this rename more complicated. What did you end up getting stuck on when renaming this selection error, `@lcnr?` **also** I renamed the `FulfillmentErrorCode` variants. This is just churn but I wanted to do it forever. I can move it out of this PR if desired. r? lcnr
2024-01-14`allow_internal_unstable(min_specialization)` on `newtype_index`clubby789-13/+19
2024-01-14Fix `allow_internal_unstable` for `(min_)specialization`clubby789-3/+17
2024-01-14Auto merge of #119361 - sjwang05:issue-119352, r=WaffleLapkinbors-0/+8
Fix ICE when suggesting dereferencing binop operands Fixes #119352
2024-01-14Auto merge of #119934 - compiler-errors:could-impl, r=jackh726bors-58/+43
Make `InferCtxtExt::could_impl_trait` more precise, less ICEy The implementation for `InferCtxtExt::could_impl_trait` was very wrong. Along with being pretty poorly named, way too specific to ADTs, it was also doing impl substitution wrong -- this caused an ICE (#119915). This PR generalizes that code, gives it a clearer name, makes it stop using the new trait solver (lol), and fixes some fallout bad suggestions that are made worse with the code fix. Fixes #119915
2024-01-13assert that trait solver is only created in proper infcxMichael Goulet-0/+10
2024-01-13Make InferCtxtExt::could_impl_trait less messed upMichael Goulet-58/+33
2024-01-13Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, ↵bors-26/+17
r=Nilstrieb Suggest Upgrading Compiler for Gated Features This PR addresses #117318 I have a few questions: 1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag a. How can I handle the changing message in the tests? 3. Do we want to only show this message when the compiler is old? a. How can we determine when the compiler is old? I'll wait until we figure out the message to bless the tests
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-26/+17
2024-01-13Rollup merge of #119898 - compiler-errors:error-reporting, r=oli-obkMatthias Krüger-10/+3
Remove unused `ErrorReporting` variant from overflow handling r? oli-obk
2024-01-13Rollup merge of #119891 - lcnr:rename-field, r=compiler-errorsMatthias Krüger-3/+1
rename `reported_signature_mismatch` to reflect its use it's used for a lot of things, not only closures
2024-01-12Fix ICE when suggesting dereferencing binop operandssjwang05-0/+8
2024-01-12Remove unused ErrorReporting variant from overflow handlingMichael Goulet-10/+3
2024-01-12OutputTypeParameterMismatch -> SignatureMismatchMichael Goulet-20/+17
2024-01-12Remove redundant Code from FulfillmentErrorCode variantsMichael Goulet-39/+38
2024-01-12rename `reported_signature_mismatch` to reflect its uselcnr-3/+1
2024-01-12Rollup merge of #119817 - compiler-errors:normalize-opaques, r=lcnrGuillaume Gomez-21/+23
Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver This fixes a few inconsistencies around where we don't eagerly resolve opaques to their (locally-defined) hidden types in the new solver. It essentially allows this code to work: ```rust fn main() { type Tait = impl Sized; struct S { i: i32, } let x: Tait = S { i: 0 }; println!("{}", x.i); } ``` Since `Tait` is defined in `main`, we are able to poke through the type of `x` with deref. r? lcnr
2024-01-12Auto merge of #119879 - matthiaskrgr:rollup-y710der, r=matthiaskrgrbors-34/+34
Rollup of 4 pull requests Successful merges: - #119781 (fix typo) - #119865 (Set `c_str_literals` stabilization version back to `CURRENT_RUSTC_VERSION`) - #119866 (Convert `effects` description to doc comment) - #119868 (Register even erroneous impls) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-12Auto merge of #119735 - lcnr:provisional-cache-readd, r=compiler-errorsbors-111/+266
next solver: provisional cache this adds the cache removed in #115843. However, it should now correctly track whether a provisional result depends on an inductive or coinductive stack. While working on this, I was using the following doc: https://hackmd.io/VsQPjW3wSTGUSlmgwrDKOA. I don't think it's too helpful to understanding this, but am somewhat hopeful that the inline comments are more useful. There are quite a few future perf improvements here. Given that this is already very involved I don't believe it is worth it (for now). While working on this PR one of my few attempts to significantly improve perf ended up being unsound again because I was not careful enough :sparkles: r? `@compiler-errors`
2024-01-11`specialization_graph_of`'s `errored` field is used in the only call site, ↵Oli Scherer-34/+34
and used to immediately throw away the rest of the value. Let's use `Result` to statically signal that this is happening
2024-01-11Remove special-casing around aliaskind in new solverMichael Goulet-21/+23
2024-01-11Rollup merge of #118915 - compiler-errors:alias-nits, r=lcnrMatthias Krüger-22/+46
Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur` Follow-up from #117278, since I was recently re-reviewing this code.
2024-01-10Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obkbors-42/+37
Diagnostic API fixes Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods. r? `@compiler-errors`
2024-01-10More commentsMichael Goulet-10/+30